diff options
Diffstat (limited to 'org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core')
37 files changed, 4112 insertions, 682 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/Activator.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/Activator.java index defb6d04c..2d221996e 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/Activator.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/Activator.java @@ -16,21 +16,20 @@ import org.eclipse.core.runtime.Status; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; -/** - * Make the PackageAdmin service accessible to tests. - * - * @deprecated uses deprecated class PackageAdmin. - */ @SuppressWarnings({"rawtypes", "unchecked"}) public class Activator extends Plugin { private static final String PLUGIN_ID = "org.eclipse.jdt.core.tests.model"; + /** + * @deprecated uses deprecated class PackageAdmin. + */ static org.osgi.service.packageadmin.PackageAdmin packageAdmin = null; static Plugin instance; + @SuppressWarnings("deprecation") public void start(BundleContext context) throws Exception { ServiceReference ref= context.getServiceReference(org.osgi.service.packageadmin.PackageAdmin.class.getName()); @@ -46,6 +45,11 @@ public class Activator extends Plugin { // nothing } + /** + * Make the PackageAdmin service accessible to tests. + * + * @deprecated uses deprecated class PackageAdmin. + */ public static org.osgi.service.packageadmin.PackageAdmin getPackageAdmin() { return packageAdmin; } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/APIDocumentationTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/APIDocumentationTests.java index d59474add..25368a365 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/APIDocumentationTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/APIDocumentationTests.java @@ -141,7 +141,7 @@ public void testJavaCoreAPI() throws CoreException, IllegalArgumentException, Il // fetch JavaCore source file // 1. attempt: workspace relative location in project org.eclipse.jdt.core: - @SuppressWarnings("deprecation")Bundle bundle = org.eclipse.jdt.core.tests.Activator.getInstance().getBundle(); + Bundle bundle = org.eclipse.jdt.core.tests.Activator.getInstance().getBundle(); URL url = bundle.getEntry("/"); IPath path = new Path(FileLocator.toFileURL(url).getPath()); path = path.removeLastSegments(1).append(ORG_ECLIPSE_JDT_CORE); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java index bf98fb74e..c0b797ccc 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java @@ -12499,4 +12499,124 @@ public void testBug497245b() { "}"; formatSource(source); } +/** + * https://bugs.eclipse.org/500443 - [formatter] NPE on block comment before 'force-wrap' element + */ +public void testBug500443() { + this.formatterPrefs.alignment_for_enum_constants = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + this.formatterPrefs.alignment_for_superclass_in_type_declaration = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + String source = + "public class SomeClass\n" + + " /* */ extends\n" + + " Object {\n" + + " enum MyEnum {\n" + + " /* 1 */ ONE\n" + + " }\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/500092 - [formatter] Blank lines at beginning of method body doesn't work in constructors + */ +public void testBug500092() { + this.formatterPrefs.blank_lines_at_beginning_of_method_body = 1; + String source = + "public class Test {\n" + + " public Test() { int a; }\n" + + "}"; + formatSource(source, + "public class Test {\n" + + " public Test() {\n" + + "\n" + + " int a;\n" + + " }\n" + + "}" + ); +} +/** + * https://bugs.eclipse.org/500135 - [formatter] 'Parenthesis positions' ignores single member annotations + */ +public void testBug500135() { + this.formatterPrefs.parenthesis_positions_in_annotation = DefaultCodeFormatterConstants.SEPARATE_LINES; + String source = + "@SomeAnnotation(\n" + + " \"some value\"\n" + + ")\n" + + "public class Test {\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/500096 - [formatter] Indent declarations within enum declaration doesn't affect enum constants + */ +public void testBug500096a() { + this.formatterPrefs.indent_body_declarations_compare_to_enum_declaration_header = false; + String source = + "public enum Test {\n" + + "AAA, BBB;\n" + + "Test() {\n" + + "}\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/500096 - [formatter] Indent declarations within enum declaration doesn't affect enum constants + */ +public void testBug500096b() { + this.formatterPrefs.indent_body_declarations_compare_to_enum_declaration_header = false; + this.formatterPrefs.alignment_for_enum_constants = Alignment.M_COMPACT_SPLIT + Alignment.M_INDENT_BY_ONE; + String source = + "public enum Test {\n" + + " AAA, BBB;\n" + + "Test() {\n" + + "}\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/500093 - [formatter] AssertionError with 'Next line on wrap' for array initializers + */ +public void testBug500093() { + this.formatterPrefs.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP; + this.formatterPrefs.page_width = 60; + this.formatterPrefs.use_tabs_only_for_leading_indentations = true; + String source = + "public class SomeClass {\n" + + " void foo() {\n" + + " Arrays.asList(new String[] { \"ddd\", \"eee\", \"fff\" });\n" + + " Arrays.asList(new String[] { \"a\", \"b\", \"c\" },\n" + + " new String[]\n" + + " { \"a\", \"b\", \"c\", });\n" + + " Arrays.asList(//\n" + + " new String[]\n" + + " { \"ddd\", \"eee\", \"fff\" });\n" + + " Arrays.asList(\n" + + " new String[]\n" + + " { \"eedd\", \"eee\", \"fff\" });\n" + + " Arrays.asList(\n" + + " new String[]\n" + + " { \"aa\", \"bb\", \"cc\", \"dd\", \"ee\", \"ff\", \"gg\",\n" + + " \"hh\", \"ii\" });\n" + + " String[][] test = { { \"aaaaaa\", \"bbbbb\", \"ccccc\" },\n" + + " { \"aaaa\", \"bb\", \"ccc\" } };\n" + + " test[123456 //\n" + + " * (234567 + 345678 + 456789 - 567890\n" + + " - 678901)] = new String[]\n" + + " { \"a\", \"b\", \"c\" };\n" + + " }\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/500853 - [Formatter] java code formatter doesn't honour new parentheses settings + */ +public void testBug500853() { + this.formatterPrefs.parenthesis_positions_in_method_declaration = new String(DefaultCodeFormatterConstants.PRESERVE_POSITIONS); + String source = + "public class SomeClass {\n" + + " void foo() {\n" + + " }\n" + + "}"; + formatSource(source); +} } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java index b67a696c4..9edcdc6bd 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java @@ -76,20 +76,6 @@ public void setUpSuite() throws Exception { super.setUpSuite(); } -/** - * Reset the jar placeholder and delete project. - */ -public void tearDownSuite() throws Exception { - if (ALL_TEST_SUITES == null) { - deleteProject(JAVA_PROJECT); //$NON-NLS-1$ - } else { - ALL_TEST_SUITES.remove(getClass()); - if (ALL_TEST_SUITES.size() == 0) { - deleteProject(JAVA_PROJECT); //$NON-NLS-1$ - } - } -} - void compareFormattedSource(ICompilationUnit compilationUnit) throws JavaModelException { DefaultCodeFormatter codeFormatter = codeFormatter(); String source = compilationUnit.getSource(); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java index a04e27998..2659d9960 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,11 +32,13 @@ import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.core.ClasspathEntry; import org.eclipse.jdt.internal.core.JavaCorePreferenceInitializer; import org.eclipse.jdt.internal.core.JavaElement; +import org.eclipse.jdt.internal.core.JavaElementDelta; import org.eclipse.jdt.internal.core.JavaModelManager; import org.eclipse.jdt.internal.core.JavaProject; import org.eclipse.jdt.internal.core.NameLookup; import org.eclipse.jdt.internal.core.ResolvedSourceMethod; import org.eclipse.jdt.internal.core.ResolvedSourceType; +import org.eclipse.jdt.internal.core.nd.indexer.Indexer; import org.eclipse.jdt.internal.core.search.BasicSearchEngine; import org.eclipse.jdt.internal.core.util.Util; @@ -238,10 +240,17 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases { public synchronized String stackTraces() { return this.stackTraces.toString(); } + public synchronized String toString() { - StringBuffer buffer = new StringBuffer(); - for (int i=0, length= this.deltas.length; i<length; i++) { + StringBuilder buffer = new StringBuilder(); + for (int i = 0, length= this.deltas.length; i < length; i++) { IJavaElementDelta delta = this.deltas[i]; + if (((JavaElementDelta) delta).ignoreFromTests) { + continue; + } + if (buffer.length() != 0) { + buffer.append("\n\n"); + } IJavaElementDelta[] children = delta.getAffectedChildren(); int childrenLength=children.length; IResourceDelta[] resourceDeltas = delta.getResourceDeltas(); @@ -250,28 +259,23 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases { buffer.append(delta); } else { sortDeltas(children); - for (int j=0; j<childrenLength; j++) { - buffer.append(children[j]); - if (j != childrenLength-1) { - buffer.append("\n"); + for (int j = 0; j < childrenLength; j++) { + if (buffer.length() != 0 && buffer.charAt(buffer.length() - 1) != '\n') { + buffer.append('\n'); } + buffer.append(children[j]); } - for (int j=0; j<resourceDeltasLength; j++) { - if (j == 0 && buffer.length() != 0) { - buffer.append("\n"); + for (int j = 0; j < resourceDeltasLength; j++) { + if (buffer.length() != 0 && buffer.charAt(buffer.length() - 1) != '\n') { + buffer.append('\n'); } buffer.append(resourceDeltas[j]); - if (j != resourceDeltasLength-1) { - buffer.append("\n"); - } } } - if (i != length-1) { - buffer.append("\n\n"); - } } return buffer.toString(); } + public void waitForResourceDelta() { long start = System.currentTimeMillis(); while (!this.gotResourceDelta) { @@ -2422,6 +2426,7 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases { protected void refreshExternalArchives(IJavaProject p) throws JavaModelException { waitForAutoBuild(); // ensure that the auto-build job doesn't interfere with external jar refreshing getJavaModel().refreshExternalArchives(new IJavaElement[] {p}, null); + Indexer.getInstance().waitForIndex(null); } protected void removeJavaNature(String projectName) throws CoreException { @@ -3139,6 +3144,7 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases { do { try { Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null); + Indexer.getInstance().waitForIndex(null); wasInterrupted = false; } catch (OperationCanceledException e) { e.printStackTrace(); @@ -3153,6 +3159,7 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases { do { try { Job.getJobManager().join(ResourcesPlugin.FAMILY_MANUAL_REFRESH, null); + Indexer.getInstance().waitForIndex(null); wasInterrupted = false; } catch (OperationCanceledException e) { e.printStackTrace(); @@ -3167,6 +3174,7 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases { SearchEngine engine = new SearchEngine(); IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); try { + Indexer.getInstance().waitForIndex(null); engine.searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java index 6c82e92a4..24aaeeee1 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,6 +16,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import org.eclipse.jdt.core.tests.junit.extension.TestCase; +import org.eclipse.jdt.core.tests.nd.RunIndexTests; import junit.framework.Test; import junit.framework.TestSuite; @@ -57,6 +58,9 @@ private static Class[] getAllTestClasses() { // Java search tests RunJavaSearchTests.class, + // Testss for the new index + RunIndexTests.class, + // Working copy tests WorkingCopyTests.class, WorkingCopyNotInClasspathTests.class, diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java index 9376aa60e..203b2bcd2 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -260,20 +260,7 @@ public class AttachedJavadocTests extends ModifyingResourceTests { try { IClasspathEntry[] entries = this.project.getRawClasspath(); savedEntries = entries.clone(); - IResource resource = this.project.getProject().findMember("/doc.zip"); //$NON-NLS-1$ - assertNotNull("doc folder cannot be null", resource); //$NON-NLS-1$ - URI locationURI = resource.getLocationURI(); - assertNotNull("doc folder cannot be null", locationURI); //$NON-NLS-1$ - URL docUrl = null; - try { - docUrl = locationURI.toURL(); - } catch (MalformedURLException e) { - assertTrue("Should not happen", false); //$NON-NLS-1$ - } catch(IllegalArgumentException e) { - assertTrue("Should not happen", false); //$NON-NLS-1$ - } - final String path = "jar:" + docUrl.toExternalForm() + "!/doc"; //$NON-NLS-1$ //$NON-NLS-2$ - //final String path = "jar:" + "platform:/resource/AttachedJavadocProject/doc.zip" + "!/doc"; + final String path = "jar:" + "platform:/resource/AttachedJavadocProject/doc.zip" + "!/doc"; IClasspathAttribute attribute = JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, path); for (int i = 0, max = entries.length; i < max; i++) { final IClasspathEntry entry = entries[i]; @@ -1315,5 +1302,27 @@ public class AttachedJavadocTests extends ModifyingResourceTests { assertTrue("Should not happen", false); } } + public void testBug499196() throws JavaModelException { + try { + IClasspathAttribute attribute = + JavaCore.newClasspathAttribute( + IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, + "jar:platform:/resource/AttachedJavadocProject/bug499196_doc.zip!/"); + IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/bug499196.jar"), null, null, null, new IClasspathAttribute[] {attribute}, true); + this.project.setRawClasspath(new IClasspathEntry[]{newEntry}, null); + this.project.getResolvedClasspath(false); + + IPackageFragmentRoot jarRoot = this.project.getPackageFragmentRoot(getFile("/AttachedJavadocProject/bug499196.jar")); + final IType type = jarRoot.getPackageFragment("p1.p2").getClassFile("Bug499196.class").getType(); + assertNotNull(type); + IMethod method = type.getMethod("Bug499196", new String[] {}); //$NON-NLS-1$ + assertNotNull("Constructor should not be null", method); + assertTrue(method.exists()); + String javadoc = method.getAttachedJavadoc(new NullProgressMonitor()); //$NON-NLS-1$ + assertNotNull("Should have a javadoc", javadoc); //$NON-NLS-1$ + } catch (IndexOutOfBoundsException e) { + assertTrue("Should not happen", false); + } + } } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java index 2a52510a6..3c431dd94 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -2580,6 +2580,34 @@ public void testBug246594a() throws CoreException { typeParameters[0].getBoundsSignatures()); } - - +public void testBug495598_001() throws CoreException { + try { + createFolder("/P/src/a/b/C"); + createFile("/P/src/a/b/C/readme.txt", "This is not a Java file"); + + createFile( + "/P/src/a/b/C.java", + "package a.b;\n" + + "public class C{};\n" + ); + + createFile("/P/src/X.java", + "import a.b.C;\n" + + "public class X {}\n"); + ICompilationUnit cuD = getCompilationUnit("/P/src/X.java"); + + ASTParser parser = ASTParser.newParser(AST.JLS8); + parser.setProject(this.testProject); + parser.setSource(cuD); + parser.setResolveBindings(true); + org.eclipse.jdt.core.dom.CompilationUnit cuAST = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null); + IProblem[] problems = cuAST.getProblems(); + assertEquals("Should have 1 problem", 1, problems.length); + assertEquals("Should have only an unused warning", "The import a.b.C is never used", problems[0].getMessage()); + } finally { + deleteFile("/P/src/X.java"); + deleteFile("/P/src/a/b/C.java"); + deleteFolder("/P/src/a"); + } +} } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java index 2be5e055d..7a5ecdaac 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java @@ -20676,11 +20676,11 @@ public void test276526a() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); // In the absence of the fix, it would have been: - // "IBar[TYPE_REF]{IBar, test, Ltest.IBar;, null, 44}\n" + - // "IFoo[TYPE_REF]{IFoo, test, Ltest.IFoo;, null, 44}" + // "IBar[TYPE_REF]{IBar, test, Ltest.IBar;, null, " + (R_DEFAULT + 39) + "}\n" + + // "IFoo[TYPE_REF]{IFoo, test, Ltest.IFoo;, null, " + (R_DEFAULT + 39) + "}" this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "IBar[TYPE_REF]{IBar, test, Ltest.IBar;, null, 44}", + "IBar[TYPE_REF]{IBar, test, Ltest.IBar;, null, " + (R_DEFAULT + 39) + "}", requestor.getResults()); } @@ -20712,8 +20712,8 @@ public void test276526b() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( // In the absence of the fix, it would also complete to Interface1: - //"Interface1[TYPE_REF]{Interface1, test, Ltest.Interface1;, null, 44}\n"+ - "Interface2[TYPE_REF]{Interface2, test, Ltest.Interface2;, null, 44}", + //"Interface1[TYPE_REF]{Interface1, test, Ltest.Interface1;, null, " + (R_DEFAULT + 39) + "}\n"+ + "Interface2[TYPE_REF]{Interface2, test, Ltest.Interface2;, null, " + (R_DEFAULT + 39) + "}", requestor.getResults()); } @@ -20743,7 +20743,7 @@ public void test276526c() throws JavaModelException { assertResults( // In the absence of the fix, it would suggest both p.Enclosing.Interface2, and // p.Enclosing.Interface1 while it should have suppressed the latter which is in use. - "Enclosing.Interface2[TYPE_REF]{p.Enclosing.Interface2, p, Lp.Enclosing$Interface2;, null, 44}", + "Enclosing.Interface2[TYPE_REF]{p.Enclosing.Interface2, p, Lp.Enclosing$Interface2;, null, " + (R_DEFAULT + 39) + "}", requestor.getResults()); } @@ -20778,8 +20778,8 @@ public void test276526d() throws JavaModelException { assertResults( // In the absence of the fix, it would suggest only p.Enclosing.Interface2, as it // was wrongly suppressing p.Enclosing.Interface1 confusing it with p.Interface1. - "Enclosing.Interface1[TYPE_REF]{p.Enclosing.Interface1, p, Lp.Enclosing$Interface1;, null, 44}\n" + - "Enclosing.Interface2[TYPE_REF]{p.Enclosing.Interface2, p, Lp.Enclosing$Interface2;, null, 44}", + "Enclosing.Interface1[TYPE_REF]{p.Enclosing.Interface1, p, Lp.Enclosing$Interface1;, null, " + (R_DEFAULT + 39) + "}\n" + + "Enclosing.Interface2[TYPE_REF]{p.Enclosing.Interface2, p, Lp.Enclosing$Interface2;, null, " + (R_DEFAULT + 39) + "}", requestor.getResults()); } @@ -21182,9 +21182,9 @@ public void testBug292087() throws JavaModelException { assertResults( // without the fix no proposals obtained. - "Tr[POTENTIAL_METHOD_DECLARATION]{Tr, Ltest.Try;, ()V, Tr, null, 14}\n" + - "transient[KEYWORD]{transient, null, null, transient, null, 14}\n" + - "Try[TYPE_REF]{Try, test, Ltest.Try;, null, null, 27}", + "Tr[POTENTIAL_METHOD_DECLARATION]{Tr, Ltest.Try;, ()V, Tr, null, " + (R_DEFAULT + 9) + "}\n" + + "transient[KEYWORD]{transient, null, null, transient, null, " + (R_DEFAULT + 9) + "}\n" + + "Try[TYPE_REF]{Try, test, Ltest.Try;, null, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } @@ -21220,10 +21220,10 @@ public void testBug249704() throws JavaModelException { assertResults( // without the fix no proposals obtained. - "Error[TYPE_REF]{Error, java.lang, Ljava.lang.Error;, null, null, 17}\n" + - "Exception[TYPE_REF]{Exception, java.lang, Ljava.lang.Exception;, null, null, 17}\n" + - "equals[METHOD_REF]{Try.this.equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 24}\n" + - "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 27}", + "Error[TYPE_REF]{Error, java.lang, Ljava.lang.Error;, null, null, " + (R_DEFAULT + 12) + "}\n" + + "Exception[TYPE_REF]{Exception, java.lang, Ljava.lang.Exception;, null, null, " + (R_DEFAULT + 12) + "}\n" + + "equals[METHOD_REF]{Try.this.equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_DEFAULT + 19) + "}\n" + + "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_DEFAULT + 22) + "}", requestor.getResults()); } @@ -21322,7 +21322,7 @@ public void testBug308980a() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "AClass[TYPE_REF]{AClass, test, Ltest.AClass;, null, null, 27}", + "AClass[TYPE_REF]{AClass, test, Ltest.AClass;, null, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } @@ -21366,7 +21366,7 @@ public void testBug308980b() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "AClass[TYPE_REF]{AClass, test, Ltest.AClass;, null, null, 27}", + "AClass[TYPE_REF]{AClass, test, Ltest.AClass;, null, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } @@ -21396,10 +21396,10 @@ public void testBug267091a() throws JavaModelException { assertResults( // without the fix no proposals obtained. - "Inn.Inn2[TYPE_REF]{test.Inn.Inn2, test, Ltest.Inn$Inn2;, null, null, 44}\n" + - "ABC.ABCInterface[TYPE_REF]{ABCInterface, test, Ltest.ABC$ABCInterface;, null, null, 47}\n" + - "In[TYPE_REF]{In, test, Ltest.In;, null, null, 47}\n" + - "Inn[TYPE_REF]{Inn, test, Ltest.Inn;, null, null, 47}", + "Inn.Inn2[TYPE_REF]{test.Inn.Inn2, test, Ltest.Inn$Inn2;, null, null, " + (R_DEFAULT + 39) + "}\n" + + "ABC.ABCInterface[TYPE_REF]{ABCInterface, test, Ltest.ABC$ABCInterface;, null, null, " + (R_DEFAULT + 42) + "}\n" + + "In[TYPE_REF]{In, test, Ltest.In;, null, null, " + (R_DEFAULT + 42) + "}\n" + + "Inn[TYPE_REF]{Inn, test, Ltest.Inn;, null, null, " + (R_DEFAULT + 42) + "}", requestor.getResults()); } @@ -21430,11 +21430,11 @@ public void testBug267091b() throws JavaModelException { assertResults( // without the fix no proposals obtained. - "Inn.Inn2[TYPE_REF]{test.Inn.Inn2, test, Ltest.Inn$Inn2;, null, null, 44}\n" + - "Inn.Inn2.Inn3[TYPE_REF]{test.Inn.Inn2.Inn3, test, Ltest.Inn$Inn2$Inn3;, null, null, 44}\n" + - "ABC[TYPE_REF]{ABC, test, Ltest.ABC;, null, null, 47}\n" + - "In[TYPE_REF]{In, test, Ltest.In;, null, null, 47}\n" + - "Inn[TYPE_REF]{Inn, test, Ltest.Inn;, null, null, 47}", + "Inn.Inn2[TYPE_REF]{test.Inn.Inn2, test, Ltest.Inn$Inn2;, null, null, " + (R_DEFAULT + 39) + "}\n" + + "Inn.Inn2.Inn3[TYPE_REF]{test.Inn.Inn2.Inn3, test, Ltest.Inn$Inn2$Inn3;, null, null, " + (R_DEFAULT + 39) + "}\n" + + "ABC[TYPE_REF]{ABC, test, Ltest.ABC;, null, null, " + (R_DEFAULT + 42) + "}\n" + + "In[TYPE_REF]{In, test, Ltest.In;, null, null, " + (R_DEFAULT + 42) + "}\n" + + "Inn[TYPE_REF]{Inn, test, Ltest.Inn;, null, null, " + (R_DEFAULT + 42) + "}", requestor.getResults()); } @@ -21463,9 +21463,9 @@ public void testBug310747() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - int relevance1 = R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_EXACT_EXPECTED_TYPE; - int relevance2 = R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC; - int relevance3 = R_RESOLVED + R_CASE + R_NON_STATIC; + int relevance1 = R_DEFAULT + 52; + int relevance2 = R_DEFAULT + 22; + int relevance3 = R_DEFAULT + 17; int start1 = str.lastIndexOf("/**/") + "".length(); int end1 = start1 + "/**/".length(); assertResults( @@ -21620,7 +21620,7 @@ public void testBug310427b() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "myVar1[LOCAL_VARIABLE_REF]{myVar1, null, I, myVar1, null, 57}", + "myVar1[LOCAL_VARIABLE_REF]{myVar1, null, I, myVar1, null, " + (R_DEFAULT + 52) + "}", requestor.getResults()); } @@ -21942,10 +21942,10 @@ public void test325481() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, " + (R_NON_STATIC + R_UNQUALIFIED) + "}\n" + - "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE) + "}\n" + - "myString[FIELD_REF]{myString, Ltest.X;, Ljava.lang.String;, myString, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED) + "}\n" + - "myString2[FIELD_REF]{myString2, Ltest.X;, Ljava.lang.String;, myString2, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED) + "}", + "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_DEFAULT + 19) + "}\n" + + "myString[FIELD_REF]{myString, Ltest.X;, Ljava.lang.String;, myString, null, " + (R_DEFAULT + 22) + "}\n" + + "myString2[FIELD_REF]{myString2, Ltest.X;, Ljava.lang.String;, myString2, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=312603 @@ -21969,9 +21969,9 @@ public void test312603() throws JavaModelException { this.wcOwner); assertResults( - "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, 14}\n" + - "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, 24}\n" + - "myString[FIELD_REF]{myString, Ltest.X;, Ljava.lang.String;, myString, null, 57}", + "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_DEFAULT + 19) + "}\n" + + "myString[FIELD_REF]{myString, Ltest.X;, Ljava.lang.String;, myString, null, " + (R_DEFAULT + 52) + "}", requestor.getResults()); } @@ -22001,10 +22001,10 @@ public void test328674a() throws JavaModelException { this.wcOwner); assertResults( - "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, " + (R_NON_STATIC + R_UNQUALIFIED) + "}\n" + - "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE) + "}\n" + - "myString[LOCAL_VARIABLE_REF]{myString, null, Ljava.lang.String;, myString, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}\n" + - "myString2[LOCAL_VARIABLE_REF]{myString2, null, Ljava.lang.String;, myString2, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}", + "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_DEFAULT + 19) + "}\n" + + "myString[LOCAL_VARIABLE_REF]{myString, null, Ljava.lang.String;, myString, null, " + (R_DEFAULT + 52) + "}\n" + + "myString2[LOCAL_VARIABLE_REF]{myString2, null, Ljava.lang.String;, myString2, null, " + (R_DEFAULT + 52) + "}", requestor.getResults()); } @@ -22034,10 +22034,10 @@ public void test328674b() throws JavaModelException { this.wcOwner); assertResults( - "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, " + (R_NON_STATIC + R_UNQUALIFIED) + "}\n" + - "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE) + "}\n" + - "myString[LOCAL_VARIABLE_REF]{myString, null, Ljava.lang.String;, myString, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}\n" + - "myString1[LOCAL_VARIABLE_REF]{myString1, null, Ljava.lang.String;, myString1, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}", + "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_DEFAULT + 19) + "}\n" + + "myString[LOCAL_VARIABLE_REF]{myString, null, Ljava.lang.String;, myString, null, " + (R_DEFAULT + 52) + "}\n" + + "myString1[LOCAL_VARIABLE_REF]{myString1, null, Ljava.lang.String;, myString1, null, " + (R_DEFAULT + 52) + "}", requestor.getResults()); } @@ -22058,7 +22058,7 @@ public void test325481b() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); cu.codeComplete(cursorLocation, requestor); - int relevance = R_INTERFACE + R_UNQUALIFIED + R_NON_RESTRICTED; + int relevance = R_DEFAULT + 21; assumeEquals( "should have two completions", "element:ADD_CUSTOM_ATTRIBUTES completion:ADD_CUSTOM_ATTRIBUTES relevance:" + relevance +"\n" + @@ -23979,7 +23979,7 @@ public void testBug401487a() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "def[POTENTIAL_METHOD_DECLARATION]{def, Ltest.P;, ()V, def, null, 14}\n" + "default[KEYWORD]{default, null, null, default, null, 24}" , + "def[POTENTIAL_METHOD_DECLARATION]{def, Ltest.P;, ()V, def, null, " + (R_DEFAULT + 9) + "}\n" + "default[KEYWORD]{default, null, null, default, null, " + (R_DEFAULT + 19) + "}" , requestor.getResults()); } finally { // Restore compliance settings. @@ -24043,7 +24043,7 @@ public void testBug401487c() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "def[POTENTIAL_METHOD_DECLARATION]{def, Ltest.P;, ()V, def, null, 14}" , + "def[POTENTIAL_METHOD_DECLARATION]{def, Ltest.P;, ()V, def, null, " + (R_DEFAULT + 9) + "}" , requestor.getResults()); } finally { // Restore compliance settings. @@ -24109,7 +24109,7 @@ public void testBug401487e() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "def[POTENTIAL_METHOD_DECLARATION]{def, Ltest.ZZ$I;, ()V, def, null, 14}\n" + "default[KEYWORD]{default, null, null, default, null, 24}" , + "def[POTENTIAL_METHOD_DECLARATION]{def, Ltest.ZZ$I;, ()V, def, null, " + (R_DEFAULT + 9) + "}\n" + "default[KEYWORD]{default, null, null, default, null, " + (R_DEFAULT + 19) + "}" , requestor.getResults()); } finally { // Restore compliance settings. @@ -24573,10 +24573,10 @@ public void testBug351444() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor); assertResults( - "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<TT;>;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), 30}\n" + - " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, 30}\n" + - "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<TT;>;, (TT;)V, TXYU, (t), 30}\n" + - " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, 30}", + "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<TT;>;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), " + (R_DEFAULT + 25) + "}\n" + + " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, " + (R_DEFAULT + 25) + "}\n" + + "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<TT;>;, (TT;)V, TXYU, (t), " + (R_DEFAULT + 25) + "}\n" + + " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, " + (R_DEFAULT + 25) + "}", requestor.getResults()); assertEquals(true, requestor.canUseDiamond(0)); @@ -24616,10 +24616,10 @@ public void testBug351444a() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor); assertResults( - "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<TT;>;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), 30}\n" + - " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, 30}\n" + - "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<TT;>;, (TT;)V, TXYU, (t), 30}\n" + - " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, 30}", + "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<TT;>;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), " + (R_DEFAULT + 25) + "}\n" + + " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, " + (R_DEFAULT + 25) + "}\n" + + "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<TT;>;, (TT;)V, TXYU, (t), " + (R_DEFAULT + 25) + "}\n" + + " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, " + (R_DEFAULT + 25) + "}", requestor.getResults()); assertEquals(false, requestor.canUseDiamond(1)); @@ -24662,10 +24662,10 @@ public void testBug351444b() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor); assertResults( - "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.Test<Ljava.lang.Object;>.TXYU;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), 30}\n" + - " Test.TXYU[TYPE_REF]{TXYU, test, Ltest.Test$TXYU;, null, null, 30}\n" + - "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.Test<Ljava.lang.Object;>.TXYU;, (TT;)V, TXYU, (t), 30}\n" + - " Test.TXYU[TYPE_REF]{TXYU, test, Ltest.Test$TXYU;, null, null, 30}", + "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.Test<Ljava.lang.Object;>.TXYU;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), " + (R_DEFAULT + 25) + "}\n" + + " Test.TXYU[TYPE_REF]{TXYU, test, Ltest.Test$TXYU;, null, null, " + (R_DEFAULT + 25) + "}\n" + + "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.Test<Ljava.lang.Object;>.TXYU;, (TT;)V, TXYU, (t), " + (R_DEFAULT + 25) + "}\n" + + " Test.TXYU[TYPE_REF]{TXYU, test, Ltest.Test$TXYU;, null, null, " + (R_DEFAULT + 25) + "}", requestor.getResults()); assertEquals(true, requestor.canUseDiamond(0)); @@ -24708,10 +24708,10 @@ public void testBug351444c() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor); assertResults( - "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.Test<Ljava.lang.Object;>.TXYU;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), 30}\n" + - " Test.TXYU[TYPE_REF]{TXYU, test, Ltest.Test$TXYU;, null, null, 30}\n" + - "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.Test<Ljava.lang.Object;>.TXYU;, (TT;)V, TXYU, (t), 30}\n" + - " Test.TXYU[TYPE_REF]{TXYU, test, Ltest.Test$TXYU;, null, null, 30}", + "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.Test<Ljava.lang.Object;>.TXYU;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), " + (R_DEFAULT + 25) + "}\n" + + " Test.TXYU[TYPE_REF]{TXYU, test, Ltest.Test$TXYU;, null, null, " + (R_DEFAULT + 25) + "}\n" + + "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.Test<Ljava.lang.Object;>.TXYU;, (TT;)V, TXYU, (t), " + (R_DEFAULT + 25) + "}\n" + + " Test.TXYU[TYPE_REF]{TXYU, test, Ltest.Test$TXYU;, null, null, " + (R_DEFAULT + 25) + "}", requestor.getResults()); assertEquals(false, requestor.canUseDiamond(1)); @@ -24757,10 +24757,10 @@ public void testBug351444d() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor); assertResults( - "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<LNumber;>;, (LNumber;)V, TXYU, (t), 60}\n" + - " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, 60}\n" + - "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<LNumber;>;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), 60}\n" + - " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, 60}", + "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<LNumber;>;, (LNumber;)V, TXYU, (t), " + (R_DEFAULT + 55) + "}\n" + + " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, " + (R_DEFAULT + 55) + "}\n" + + "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<LNumber;>;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), " + (R_DEFAULT + 55) + "}\n" + + " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, " + (R_DEFAULT + 55) + "}", requestor.getResults()); assertEquals(false, requestor.canUseDiamond(0)); @@ -24806,10 +24806,10 @@ public void testBug351444e() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor); assertResults( - "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<LNumber;>;, (LNumber;)V, TXYU, (t), 60}\n" + - " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, 60}\n" + - "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<LNumber;>;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), 60}\n" + - " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, 60}", + "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<LNumber;>;, (LNumber;)V, TXYU, (t), " + (R_DEFAULT + 55) + "}\n" + + " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, " + (R_DEFAULT + 55) + "}\n" + + "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<LNumber;>;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), " + (R_DEFAULT + 55) + "}\n" + + " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, " + (R_DEFAULT + 55) + "}", requestor.getResults()); assertEquals(true, requestor.canUseDiamond(1)); @@ -24850,11 +24850,11 @@ public void testBug292087b() throws JavaModelException { "expectedTypesKeys={Ltest/Try~MyClass;}", requestor.getContext()); assertResults( - "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_NON_STATIC + R_UNQUALIFIED) + "}\n" + - "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE) + "}\n" + - "MyClass[TYPE_REF]{MyClass, test, Ltest.MyClass;, null, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}\n" + - "MyClassField[FIELD_REF]{MyClassField, Ltest.Try;, Ltest.MyClass;, MyClassField, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}\n" + - "MyClassMethod[METHOD_REF]{MyClassMethod(), Ltest.Try;, ()Ltest.MyClass;, MyClassMethod, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}", + "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_DEFAULT + 9) + "}\n" + + "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, " + (R_DEFAULT + 19) + "}\n" + + "MyClass[TYPE_REF]{MyClass, test, Ltest.MyClass;, null, null, " + (R_DEFAULT + 52) + "}\n" + + "MyClassField[FIELD_REF]{MyClassField, Ltest.Try;, Ltest.MyClass;, MyClassField, null, " + (R_DEFAULT + 52) + "}\n" + + "MyClassMethod[METHOD_REF]{MyClassMethod(), Ltest.Try;, ()Ltest.MyClass;, MyClassMethod, null, " + (R_DEFAULT + 52) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=292087 @@ -24888,21 +24888,21 @@ public void testBug292087c() throws JavaModelException { "expectedTypesKeys={Ltest/Try~MyClass;}", requestor.getContext()); assertResults( - "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" + - "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" + - "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" + - "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" + - "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" + - "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" + - "Try[TYPE_REF]{Try, test, Ltest.Try;, null, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" + - "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" + - "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" + - "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" + - "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" + - "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" + - "MyClass[TYPE_REF]{MyClass, test, Ltest.MyClass;, null, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_EXACT_EXPECTED_TYPE) + "}\n" + - "MyClassField[FIELD_REF]{MyClassField, Ltest.Try;, Ltest.MyClass;, MyClassField, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_EXACT_EXPECTED_TYPE) + "}\n" + - "MyClassMethod[METHOD_REF]{MyClassMethod(), Ltest.Try;, ()Ltest.MyClass;, MyClassMethod, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_EXACT_EXPECTED_TYPE) + "}", + "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, " + (R_DEFAULT + 17) + "}\n" + + "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, " + (R_DEFAULT + 17) + "}\n" + + "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, " + (R_DEFAULT + 17) + "}\n" + + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, " + (R_DEFAULT + 17) + "}\n" + + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), " + (R_DEFAULT + 17) + "}\n" + + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), " + (R_DEFAULT + 17) + "}\n" + + "Try[TYPE_REF]{Try, test, Ltest.Try;, null, null, " + (R_DEFAULT + 22) + "}\n" + + "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_DEFAULT + 22) + "}\n" + + "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_DEFAULT + 22) + "}\n" + + "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, " + (R_DEFAULT + 22) + "}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_DEFAULT + 22) + "}\n" + + "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_DEFAULT + 22) + "}\n" + + "MyClass[TYPE_REF]{MyClass, test, Ltest.MyClass;, null, null, " + (R_DEFAULT + 52) + "}\n" + + "MyClassField[FIELD_REF]{MyClassField, Ltest.Try;, Ltest.MyClass;, MyClassField, null, " + (R_DEFAULT + 52) + "}\n" + + "MyClassMethod[METHOD_REF]{MyClassMethod(), Ltest.Try;, ()Ltest.MyClass;, MyClassMethod, null, " + (R_DEFAULT + 52) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=292087 @@ -24938,21 +24938,21 @@ public void testBug292087d() throws JavaModelException { "expectedTypesKeys={Ltest/Try~MyClass;}", requestor.getContext()); assertResults( - "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" + - "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" + - "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" + - "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" + - "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" + - "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" + - "Try[TYPE_REF]{Try, test, Ltest.Try;, null, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" + - "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" + - "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" + - "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" + - "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" + - "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" + - "MyClass[TYPE_REF]{MyClass, test, Ltest.MyClass;, null, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_EXACT_EXPECTED_TYPE) + "}\n" + - "MyClassField[FIELD_REF]{MyClassField, Ltest.Try;, Ltest.MyClass;, MyClassField, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_EXACT_EXPECTED_TYPE) + "}\n" + - "MyClassMethod[METHOD_REF]{MyClassMethod(), Ltest.Try;, ()Ltest.MyClass;, MyClassMethod, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_EXACT_EXPECTED_TYPE) + "}", + "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, " + (R_DEFAULT + 17) + "}\n" + + "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, " + (R_DEFAULT + 17) + "}\n" + + "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, " + (R_DEFAULT + 17) + "}\n" + + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, " + (R_DEFAULT + 17) + "}\n" + + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), " + (R_DEFAULT + 17) + "}\n" + + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), " + (R_DEFAULT + 17) + "}\n" + + "Try[TYPE_REF]{Try, test, Ltest.Try;, null, null, " + (R_DEFAULT + 22) + "}\n" + + "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_DEFAULT + 22) + "}\n" + + "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_DEFAULT + 22) + "}\n" + + "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, " + (R_DEFAULT + 22) + "}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_DEFAULT + 22) + "}\n" + + "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_DEFAULT + 22) + "}\n" + + "MyClass[TYPE_REF]{MyClass, test, Ltest.MyClass;, null, null, " + (R_DEFAULT + 52) + "}\n" + + "MyClassField[FIELD_REF]{MyClassField, Ltest.Try;, Ltest.MyClass;, MyClassField, null, " + (R_DEFAULT + 52) + "}\n" + + "MyClassMethod[METHOD_REF]{MyClassMethod(), Ltest.Try;, ()Ltest.MyClass;, MyClassMethod, null, " + (R_DEFAULT + 52) + "}", requestor.getResults()); } @@ -25181,15 +25181,15 @@ public void testBug402574() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor); assertResults( - "IT_MAY_BE_DUE_TO_MIXING_PERHAPS[FIELD_REF]{IT_MAY_BE_DUE_TO_MIXING_PERHAPS, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, IT_MAY_BE_DUE_TO_MIXING_PERHAPS, null, 26}\n" + - "MORE_STUFF[FIELD_REF]{MORE_STUFF, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, MORE_STUFF, null, 26}\n" + - "OTHER[FIELD_REF]{OTHER, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, OTHER, null, 26}\n" + - "STILL_OTHER[FIELD_REF]{STILL_OTHER, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, STILL_OTHER, null, 26}\n" + - "STUFF[FIELD_REF]{STUFF, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, STUFF, null, 26}\n" + - "THINGS[FIELD_REF]{THINGS, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, THINGS, null, 26}\n" + - "class[FIELD_REF]{class, null, Ljava.lang.Class<Ltest.ExampleEnumNoAutocomplete;>;, class, null, 26}\n" + - "valueOf[METHOD_REF]{valueOf(), Ltest.ExampleEnumNoAutocomplete;, (Ljava.lang.String;)Ltest.ExampleEnumNoAutocomplete;, valueOf, (arg0), 26}\n" + - "values[METHOD_REF]{values(), Ltest.ExampleEnumNoAutocomplete;, ()[Ltest.ExampleEnumNoAutocomplete;, values, null, 26}", + "IT_MAY_BE_DUE_TO_MIXING_PERHAPS[FIELD_REF]{IT_MAY_BE_DUE_TO_MIXING_PERHAPS, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, IT_MAY_BE_DUE_TO_MIXING_PERHAPS, null, " + (R_DEFAULT + 21) + "}\n" + + "MORE_STUFF[FIELD_REF]{MORE_STUFF, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, MORE_STUFF, null, " + (R_DEFAULT + 21) + "}\n" + + "OTHER[FIELD_REF]{OTHER, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, OTHER, null, " + (R_DEFAULT + 21) + "}\n" + + "STILL_OTHER[FIELD_REF]{STILL_OTHER, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, STILL_OTHER, null, " + (R_DEFAULT + 21) + "}\n" + + "STUFF[FIELD_REF]{STUFF, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, STUFF, null, " + (R_DEFAULT + 21) + "}\n" + + "THINGS[FIELD_REF]{THINGS, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, THINGS, null, " + (R_DEFAULT + 21) + "}\n" + + "class[FIELD_REF]{class, null, Ljava.lang.Class<Ltest.ExampleEnumNoAutocomplete;>;, class, null, " + (R_DEFAULT + 21) + "}\n" + + "valueOf[METHOD_REF]{valueOf(), Ltest.ExampleEnumNoAutocomplete;, (Ljava.lang.String;)Ltest.ExampleEnumNoAutocomplete;, valueOf, (arg0), " + (R_DEFAULT + 21) + "}\n" + + "values[METHOD_REF]{values(), Ltest.ExampleEnumNoAutocomplete;, ()[Ltest.ExampleEnumNoAutocomplete;, values, null, " + (R_DEFAULT + 21) + "}", requestor.getResults()); assertEquals(false, requestor.canUseDiamond(0)); @@ -25242,7 +25242,7 @@ public void testBug402812a() throws Exception { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor); assertResults( - "staticMethod[METHOD_REF]{staticMethod(), Ltest.Test;, ()V, staticMethod, null, 27}", + "staticMethod[METHOD_REF]{staticMethod(), Ltest.Test;, ()V, staticMethod, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } finally { deleteProject("P"); @@ -25297,7 +25297,7 @@ public void testBug402812b() throws Exception { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor); assertResults( - "staticMethod[METHOD_REF]{staticMethod(), Ltest.I;, ()V, staticMethod, null, 26}", + "staticMethod[METHOD_REF]{staticMethod(), Ltest.I;, ()V, staticMethod, null, " + (R_DEFAULT + 21) + "}", requestor.getResults()); } finally { deleteProject("P"); @@ -25353,7 +25353,7 @@ public void testBug402812c() throws Exception { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor); assertResults( - "defaultMethod[METHOD_REF]{defaultMethod(), Ltest.I;, ()V, defaultMethod, null, 35}", + "defaultMethod[METHOD_REF]{defaultMethod(), Ltest.I;, ()V, defaultMethod, null, " + (R_DEFAULT + 30) + "}", requestor.getResults()); } finally { deleteProject("P"); @@ -25408,7 +25408,7 @@ public void testBug402812d() throws Exception { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor); assertResults( - "defaultMethod[METHOD_REF]{defaultMethod(), Ltest.I;, ()V, defaultMethod, null, 27}", + "defaultMethod[METHOD_REF]{defaultMethod(), Ltest.I;, ()V, defaultMethod, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } finally { deleteProject("P"); @@ -25452,7 +25452,7 @@ public void testBug370971() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor); assertResults( - "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, 65}", + "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_DEFAULT + 60) + "}", requestor.getResults()); assertEquals(false, requestor.canUseDiamond(0)); @@ -25492,12 +25492,12 @@ public void testBug406468a() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "I[TYPE_REF]{I, test, Ltest.I;, null, null, 27}\n" + - "X[TYPE_REF]{X, test, Ltest.X;, null, null, 27}\n" + - "args[LOCAL_VARIABLE_REF]{args, null, [Ljava.lang.String;, args, null, 27}\n" + - "i[LOCAL_VARIABLE_REF]{i, null, Ltest.I;, i, null, 27}\n" + - "main[METHOD_REF]{main(), Ltest.X;, ([Ljava.lang.String;)V, main, (args), 27}\n" + - "x[LOCAL_VARIABLE_REF]{x, null, [[[Ltest.X;, x, null, 27}", + "I[TYPE_REF]{I, test, Ltest.I;, null, null, " + (R_DEFAULT + 22) + "}\n" + + "X[TYPE_REF]{X, test, Ltest.X;, null, null, " + (R_DEFAULT + 22) + "}\n" + + "args[LOCAL_VARIABLE_REF]{args, null, [Ljava.lang.String;, args, null, " + (R_DEFAULT + 22) + "}\n" + + "i[LOCAL_VARIABLE_REF]{i, null, Ltest.I;, i, null, " + (R_DEFAULT + 22) + "}\n" + + "main[METHOD_REF]{main(), Ltest.X;, ([Ljava.lang.String;)V, main, (args), " + (R_DEFAULT + 22) + "}\n" + + "x[LOCAL_VARIABLE_REF]{x, null, [[[Ltest.X;, x, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } finally { // Restore compliance settings. @@ -25534,13 +25534,13 @@ public void testBug406468b() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "I[TYPE_REF]{I, test, Ltest.I;, null, null, 27}\n" + - "S[TYPE_REF]{S, null, TS;, null, null, 27}\n" + - "X<S>[TYPE_REF]{X, test, Ltest.X<TS;>;, null, null, 27}\n" + - "args[LOCAL_VARIABLE_REF]{args, null, [Ljava.lang.String;, args, null, 27}\n" + - "i[LOCAL_VARIABLE_REF]{i, null, Ltest.I;, i, null, 27}\n" + - "main[METHOD_REF]{main(), Ltest.X<TS;>;, ([Ljava.lang.String;)V, main, (args), 27}\n" + - "x[LOCAL_VARIABLE_REF]{x, null, Ltest.X;, x, null, 27}", + "I[TYPE_REF]{I, test, Ltest.I;, null, null, " + (R_DEFAULT + 22) + "}\n" + + "S[TYPE_REF]{S, null, TS;, null, null, " + (R_DEFAULT + 22) + "}\n" + + "X<S>[TYPE_REF]{X, test, Ltest.X<TS;>;, null, null, " + (R_DEFAULT + 22) + "}\n" + + "args[LOCAL_VARIABLE_REF]{args, null, [Ljava.lang.String;, args, null, " + (R_DEFAULT + 22) + "}\n" + + "i[LOCAL_VARIABLE_REF]{i, null, Ltest.I;, i, null, " + (R_DEFAULT + 22) + "}\n" + + "main[METHOD_REF]{main(), Ltest.X<TS;>;, ([Ljava.lang.String;)V, main, (args), " + (R_DEFAULT + 22) + "}\n" + + "x[LOCAL_VARIABLE_REF]{x, null, Ltest.X;, x, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } finally { // Restore compliance settings. @@ -25694,7 +25694,7 @@ public void testBug421469() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "pqrqwerty[LOCAL_VARIABLE_REF]{pqrqwerty, null, I, pqrqwerty, null, 27}", + "pqrqwerty[LOCAL_VARIABLE_REF]{pqrqwerty, null, I, pqrqwerty, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } finally { // Restore compliance settings. @@ -25739,7 +25739,7 @@ public void testBug421469a() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "pqrqwerty[LOCAL_VARIABLE_REF]{pqrqwerty, null, I, pqrqwerty, null, 27}", + "pqrqwerty[LOCAL_VARIABLE_REF]{pqrqwerty, null, I, pqrqwerty, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } finally { // Restore compliance settings. diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java index 9002b4431..705605423 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java @@ -26,7 +26,7 @@ import org.eclipse.jdt.internal.codeassist.RelevanceConstants; public class CompletionTests18 extends AbstractJavaModelCompletionTests { static { -// TESTS_NAMES = new String[] {"test001"}; +// TESTS_NAMES = new String[] {"test001"}; } public CompletionTests18(String name) { @@ -63,7 +63,7 @@ public void test001() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "first[LOCAL_VARIABLE_REF]{first, null, I, first, null, 27}", + "first[LOCAL_VARIABLE_REF]{first, null, I, first, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } public void test002() throws JavaModelException { @@ -86,7 +86,7 @@ public void test002() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "first[LOCAL_VARIABLE_REF]{first, null, I, first, null, 27}", + "first[LOCAL_VARIABLE_REF]{first, null, I, first, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } public void test003() throws JavaModelException { @@ -118,22 +118,22 @@ public void test003() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "CASE_INSENSITIVE_ORDER[FIELD_REF]{CASE_INSENSITIVE_ORDER, Ljava.lang.String;, Ljava.util.Comparator<Ljava.lang.String;>;, CASE_INSENSITIVE_ORDER, null, 14}\n" + - "copyValueOf[METHOD_REF]{copyValueOf(), Ljava.lang.String;, ([C)Ljava.lang.String;, copyValueOf, (arg0), 24}\n" + - "copyValueOf[METHOD_REF]{copyValueOf(), Ljava.lang.String;, ([CII)Ljava.lang.String;, copyValueOf, (arg0, arg1, arg2), 24}\n" + - "charAt[METHOD_REF]{charAt(), Ljava.lang.String;, (I)C, charAt, (arg0), 35}\n" + - "chars[METHOD_REF]{chars(), Ljava.lang.CharSequence;, ()Ljava.util.stream.IntStream;, chars, null, 35}\n" + - "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 35}\n" + - "codePointAt[METHOD_REF]{codePointAt(), Ljava.lang.String;, (I)I, codePointAt, (arg0), 35}\n" + - "codePointBefore[METHOD_REF]{codePointBefore(), Ljava.lang.String;, (I)I, codePointBefore, (arg0), 35}\n" + - "codePointCount[METHOD_REF]{codePointCount(), Ljava.lang.String;, (II)I, codePointCount, (arg0, arg1), 35}\n" + - "codePoints[METHOD_REF]{codePoints(), Ljava.lang.CharSequence;, ()Ljava.util.stream.IntStream;, codePoints, null, 35}\n" + - "compareTo[METHOD_REF]{compareTo(), Ljava.lang.String;, (Ljava.lang.String;)I, compareTo, (arg0), 35}\n" + - "compareToIgnoreCase[METHOD_REF]{compareToIgnoreCase(), Ljava.lang.String;, (Ljava.lang.String;)I, compareToIgnoreCase, (arg0), 35}\n" + - "concat[METHOD_REF]{concat(), Ljava.lang.String;, (Ljava.lang.String;)Ljava.lang.String;, concat, (arg0), 35}\n" + - "contains[METHOD_REF]{contains(), Ljava.lang.String;, (Ljava.lang.CharSequence;)Z, contains, (arg0), 35}\n" + - "contentEquals[METHOD_REF]{contentEquals(), Ljava.lang.String;, (Ljava.lang.CharSequence;)Z, contentEquals, (arg0), 35}\n" + - "contentEquals[METHOD_REF]{contentEquals(), Ljava.lang.String;, (Ljava.lang.StringBuffer;)Z, contentEquals, (arg0), 35}", + "CASE_INSENSITIVE_ORDER[FIELD_REF]{CASE_INSENSITIVE_ORDER, Ljava.lang.String;, Ljava.util.Comparator<Ljava.lang.String;>;, CASE_INSENSITIVE_ORDER, null, " + (R_DEFAULT + 9) + "}\n" + + "copyValueOf[METHOD_REF]{copyValueOf(), Ljava.lang.String;, ([C)Ljava.lang.String;, copyValueOf, (arg0), " + (R_DEFAULT + 19) + "}\n" + + "copyValueOf[METHOD_REF]{copyValueOf(), Ljava.lang.String;, ([CII)Ljava.lang.String;, copyValueOf, (arg0, arg1, arg2), " + (R_DEFAULT + 19) + "}\n" + + "charAt[METHOD_REF]{charAt(), Ljava.lang.String;, (I)C, charAt, (arg0), " + (R_DEFAULT + 30) + "}\n" + + "chars[METHOD_REF]{chars(), Ljava.lang.CharSequence;, ()Ljava.util.stream.IntStream;, chars, null, " + (R_DEFAULT + 30) + "}\n" + + "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_DEFAULT + 30) + "}\n" + + "codePointAt[METHOD_REF]{codePointAt(), Ljava.lang.String;, (I)I, codePointAt, (arg0), " + (R_DEFAULT + 30) + "}\n" + + "codePointBefore[METHOD_REF]{codePointBefore(), Ljava.lang.String;, (I)I, codePointBefore, (arg0), " + (R_DEFAULT + 30) + "}\n" + + "codePointCount[METHOD_REF]{codePointCount(), Ljava.lang.String;, (II)I, codePointCount, (arg0, arg1), " + (R_DEFAULT + 30) + "}\n" + + "codePoints[METHOD_REF]{codePoints(), Ljava.lang.CharSequence;, ()Ljava.util.stream.IntStream;, codePoints, null, " + (R_DEFAULT + 30) + "}\n" + + "compareTo[METHOD_REF]{compareTo(), Ljava.lang.String;, (Ljava.lang.String;)I, compareTo, (arg0), " + (R_DEFAULT + 30) + "}\n" + + "compareToIgnoreCase[METHOD_REF]{compareToIgnoreCase(), Ljava.lang.String;, (Ljava.lang.String;)I, compareToIgnoreCase, (arg0), " + (R_DEFAULT + 30) + "}\n" + + "concat[METHOD_REF]{concat(), Ljava.lang.String;, (Ljava.lang.String;)Ljava.lang.String;, concat, (arg0), " + (R_DEFAULT + 30) + "}\n" + + "contains[METHOD_REF]{contains(), Ljava.lang.String;, (Ljava.lang.CharSequence;)Z, contains, (arg0), " + (R_DEFAULT + 30) + "}\n" + + "contentEquals[METHOD_REF]{contentEquals(), Ljava.lang.String;, (Ljava.lang.CharSequence;)Z, contentEquals, (arg0), " + (R_DEFAULT + 30) + "}\n" + + "contentEquals[METHOD_REF]{contentEquals(), Ljava.lang.String;, (Ljava.lang.StringBuffer;)Z, contentEquals, (arg0), " + (R_DEFAULT + 30) + "}", requestor.getResults()); } public void test004() throws JavaModelException { @@ -154,8 +154,8 @@ public void test004() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "lpx5[LOCAL_VARIABLE_REF]{lpx5, null, I, lpx5, null, 27}\n" + - "lpx6[LOCAL_VARIABLE_REF]{lpx6, null, I, lpx6, null, 27}", + "lpx5[LOCAL_VARIABLE_REF]{lpx5, null, I, lpx5, null, " + (R_DEFAULT + 22) + "}\n" + + "lpx6[LOCAL_VARIABLE_REF]{lpx6, null, I, lpx6, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } @@ -183,7 +183,7 @@ public void test005() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "argument[LOCAL_VARIABLE_REF]{argument, null, I, argument, null, 57}", + "argument[LOCAL_VARIABLE_REF]{argument, null, I, argument, null, " + (R_DEFAULT + 52) + "}", requestor.getResults()); } public void test006() throws JavaModelException { @@ -208,7 +208,7 @@ public void test006() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "argument[LOCAL_VARIABLE_REF]{argument, null, I, argument, null, 27}", + "argument[LOCAL_VARIABLE_REF]{argument, null, I, argument, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=405126, [1.8][code assist] Lambda parameters incorrectly recovered as fields. @@ -236,10 +236,10 @@ public void test007() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "class[FIELD_REF]{class, null, Ljava.lang.Class<LX;>;, class, null, 26}\n" + - "f[FIELD_REF]{f, LX;, LFoo;, f, null, 26}\n" + - "this[KEYWORD]{this, null, null, this, null, 26}\n" + - "x1[FIELD_REF]{x1, LX;, I, x1, null, 56}", + "class[FIELD_REF]{class, null, Ljava.lang.Class<LX;>;, class, null, " + (R_DEFAULT + 21) + "}\n" + + "f[FIELD_REF]{f, LX;, LFoo;, f, null, " + (R_DEFAULT + 21) + "}\n" + + "this[KEYWORD]{this, null, null, this, null, " + (R_DEFAULT + 21) + "}\n" + + "x1[FIELD_REF]{x1, LX;, I, x1, null, " + (R_DEFAULT + 51) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=422107, [1.8][code assist] Invoking code assist just before and after a variable initialized using lambda gives different result @@ -265,35 +265,35 @@ public void test008() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "[POTENTIAL_METHOD_DECLARATION]{, LX;, ()V, , null, 14}\n" + - "abstract[KEYWORD]{abstract, null, null, abstract, null, 24}\n" + + "[POTENTIAL_METHOD_DECLARATION]{, LX;, ()V, , null, " + (R_DEFAULT + 9) + "}\n" + + "abstract[KEYWORD]{abstract, null, null, abstract, null, " + (R_DEFAULT + 19) + "}\n" + //{ObjectTeams: - "callin[KEYWORD]{callin, null, null, callin, null, 24}\n" + + "callin[KEYWORD]{callin, null, null, callin, null, " + (R_DEFAULT + 19) + "}\n" + // SH} - "class[KEYWORD]{class, null, null, class, null, 24}\n" + - "enum[KEYWORD]{enum, null, null, enum, null, 24}\n" + - "final[KEYWORD]{final, null, null, final, null, 24}\n" + - "interface[KEYWORD]{interface, null, null, interface, null, 24}\n" + - "native[KEYWORD]{native, null, null, native, null, 24}\n" + - "private[KEYWORD]{private, null, null, private, null, 24}\n" + - "protected[KEYWORD]{protected, null, null, protected, null, 24}\n" + - "public[KEYWORD]{public, null, null, public, null, 24}\n" + - "static[KEYWORD]{static, null, null, static, null, 24}\n" + - "strictfp[KEYWORD]{strictfp, null, null, strictfp, null, 24}\n" + - "synchronized[KEYWORD]{synchronized, null, null, synchronized, null, 24}\n" + + "class[KEYWORD]{class, null, null, class, null, " + (R_DEFAULT + 19) + "}\n" + + "enum[KEYWORD]{enum, null, null, enum, null, " + (R_DEFAULT + 19) + "}\n" + + "final[KEYWORD]{final, null, null, final, null, " + (R_DEFAULT + 19) + "}\n" + + "interface[KEYWORD]{interface, null, null, interface, null, " + (R_DEFAULT + 19) + "}\n" + + "native[KEYWORD]{native, null, null, native, null, " + (R_DEFAULT + 19) + "}\n" + + "private[KEYWORD]{private, null, null, private, null, " + (R_DEFAULT + 19) + "}\n" + + "protected[KEYWORD]{protected, null, null, protected, null, " + (R_DEFAULT + 19) + "}\n" + + "public[KEYWORD]{public, null, null, public, null, " + (R_DEFAULT + 19) + "}\n" + + "static[KEYWORD]{static, null, null, static, null, " + (R_DEFAULT + 19) + "}\n" + + "strictfp[KEYWORD]{strictfp, null, null, strictfp, null, " + (R_DEFAULT + 19) + "}\n" + + "synchronized[KEYWORD]{synchronized, null, null, synchronized, null, " + (R_DEFAULT + 19) + "}\n" + //{ObjectTeams: - "team[KEYWORD]{team, null, null, team, null, 24}\n" + + "team[KEYWORD]{team, null, null, team, null, " + (R_DEFAULT + 19) + "}\n" + // SH} - "transient[KEYWORD]{transient, null, null, transient, null, 24}\n" + - "volatile[KEYWORD]{volatile, null, null, volatile, null, 24}\n" + - "I[TYPE_REF]{I, , LI;, null, null, 27}\n" + - "J[TYPE_REF]{J, , LJ;, null, null, 27}\n" + - "X[TYPE_REF]{X, , LX;, null, null, 27}\n" + - "clone[METHOD_DECLARATION]{protected Object clone() throws CloneNotSupportedException, Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 27}\n" + - "equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 27}\n" + - "finalize[METHOD_DECLARATION]{protected void finalize() throws Throwable, Ljava.lang.Object;, ()V, finalize, null, 27}\n" + - "hashCode[METHOD_DECLARATION]{public int hashCode(), Ljava.lang.Object;, ()I, hashCode, null, 27}\n" + - "toString[METHOD_DECLARATION]{public String toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, 27}", + "transient[KEYWORD]{transient, null, null, transient, null, " + (R_DEFAULT + 19) + "}\n" + + "volatile[KEYWORD]{volatile, null, null, volatile, null, " + (R_DEFAULT + 19) + "}\n" + + "I[TYPE_REF]{I, , LI;, null, null, " + (R_DEFAULT + 22) + "}\n" + + "J[TYPE_REF]{J, , LJ;, null, null, " + (R_DEFAULT + 22) + "}\n" + + "X[TYPE_REF]{X, , LX;, null, null, " + (R_DEFAULT + 22) + "}\n" + + "clone[METHOD_DECLARATION]{protected Object clone() throws CloneNotSupportedException, Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_DEFAULT + 22) + "}\n" + + "equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_DEFAULT + 22) + "}\n" + + "finalize[METHOD_DECLARATION]{protected void finalize() throws Throwable, Ljava.lang.Object;, ()V, finalize, null, " + (R_DEFAULT + 22) + "}\n" + + "hashCode[METHOD_DECLARATION]{public int hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_DEFAULT + 22) + "}\n" + + "toString[METHOD_DECLARATION]{public String toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=422107, [1.8][code assist] Invoking code assist just before and after a variable initialized using lambda gives different result @@ -319,35 +319,35 @@ public void test009() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "[POTENTIAL_METHOD_DECLARATION]{, LX;, ()V, , null, 14}\n" + - "abstract[KEYWORD]{abstract, null, null, abstract, null, 24}\n" + + "[POTENTIAL_METHOD_DECLARATION]{, LX;, ()V, , null, " + (R_DEFAULT + 9) + "}\n" + + "abstract[KEYWORD]{abstract, null, null, abstract, null, " + (R_DEFAULT + 19) + "}\n" + //{ObjectTeams: - "callin[KEYWORD]{callin, null, null, callin, null, 24}\n" + + "callin[KEYWORD]{callin, null, null, callin, null, " + (R_DEFAULT + 9) + "}\n" + // SH} - "class[KEYWORD]{class, null, null, class, null, 24}\n" + - "enum[KEYWORD]{enum, null, null, enum, null, 24}\n" + - "final[KEYWORD]{final, null, null, final, null, 24}\n" + - "interface[KEYWORD]{interface, null, null, interface, null, 24}\n" + - "native[KEYWORD]{native, null, null, native, null, 24}\n" + - "private[KEYWORD]{private, null, null, private, null, 24}\n" + - "protected[KEYWORD]{protected, null, null, protected, null, 24}\n" + - "public[KEYWORD]{public, null, null, public, null, 24}\n" + - "static[KEYWORD]{static, null, null, static, null, 24}\n" + - "strictfp[KEYWORD]{strictfp, null, null, strictfp, null, 24}\n" + - "synchronized[KEYWORD]{synchronized, null, null, synchronized, null, 24}\n" + + "class[KEYWORD]{class, null, null, class, null, " + (R_DEFAULT + 19) + "}\n" + + "enum[KEYWORD]{enum, null, null, enum, null, " + (R_DEFAULT + 19) + "}\n" + + "final[KEYWORD]{final, null, null, final, null, " + (R_DEFAULT + 19) + "}\n" + + "interface[KEYWORD]{interface, null, null, interface, null, " + (R_DEFAULT + 19) + "}\n" + + "native[KEYWORD]{native, null, null, native, null, " + (R_DEFAULT + 19) + "}\n" + + "private[KEYWORD]{private, null, null, private, null, " + (R_DEFAULT + 19) + "}\n" + + "protected[KEYWORD]{protected, null, null, protected, null, " + (R_DEFAULT + 19) + "}\n" + + "public[KEYWORD]{public, null, null, public, null, " + (R_DEFAULT + 19) + "}\n" + + "static[KEYWORD]{static, null, null, static, null, " + (R_DEFAULT + 19) + "}\n" + + "strictfp[KEYWORD]{strictfp, null, null, strictfp, null, " + (R_DEFAULT + 19) + "}\n" + + "synchronized[KEYWORD]{synchronized, null, null, synchronized, null, " + (R_DEFAULT + 19) + "}\n" + //{ObjectTeams: - "team[KEYWORD]{team, null, null, team, null, 24}\n" + + "team[KEYWORD]{team, null, null, team, null, " + (R_DEFAULT + 9) + "}\n" + // SH} - "transient[KEYWORD]{transient, null, null, transient, null, 24}\n" + - "volatile[KEYWORD]{volatile, null, null, volatile, null, 24}\n" + - "I[TYPE_REF]{I, , LI;, null, null, 27}\n" + - "J[TYPE_REF]{J, , LJ;, null, null, 27}\n" + - "X[TYPE_REF]{X, , LX;, null, null, 27}\n" + - "clone[METHOD_DECLARATION]{protected Object clone() throws CloneNotSupportedException, Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 27}\n" + - "equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 27}\n" + - "finalize[METHOD_DECLARATION]{protected void finalize() throws Throwable, Ljava.lang.Object;, ()V, finalize, null, 27}\n" + - "hashCode[METHOD_DECLARATION]{public int hashCode(), Ljava.lang.Object;, ()I, hashCode, null, 27}\n" + - "toString[METHOD_DECLARATION]{public String toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, 27}", + "transient[KEYWORD]{transient, null, null, transient, null, " + (R_DEFAULT + 19) + "}\n" + + "volatile[KEYWORD]{volatile, null, null, volatile, null, " + (R_DEFAULT + 19) + "}\n" + + "I[TYPE_REF]{I, , LI;, null, null, " + (R_DEFAULT + 22) + "}\n" + + "J[TYPE_REF]{J, , LJ;, null, null, " + (R_DEFAULT + 22) + "}\n" + + "X[TYPE_REF]{X, , LX;, null, null, " + (R_DEFAULT + 22) + "}\n" + + "clone[METHOD_DECLARATION]{protected Object clone() throws CloneNotSupportedException, Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_DEFAULT + 22) + "}\n" + + "equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_DEFAULT + 22) + "}\n" + + "finalize[METHOD_DECLARATION]{protected void finalize() throws Throwable, Ljava.lang.Object;, ()V, finalize, null, " + (R_DEFAULT + 22) + "}\n" + + "hashCode[METHOD_DECLARATION]{public int hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_DEFAULT + 22) + "}\n" + + "toString[METHOD_DECLARATION]{public String toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } public void test010() throws JavaModelException { @@ -377,20 +377,20 @@ public void test010() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "goo[METHOD_REF]{goo(), LX;, (LI;)V, goo, (i), 24}\n" + - "goo[METHOD_REF]{goo(), LX;, (Ljava.lang.String;)V, goo, (s), 24}\n" + - "main[METHOD_REF]{main(), LX;, ([Ljava.lang.String;)V, main, (args), 24}\n" + - "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 35}\n" + - "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 35}\n" + - "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, 35}\n" + - "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, getClass, null, 35}\n" + - "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, 35}\n" + - "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, 35}\n" + - "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, 35}\n" + - "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, 35}\n" + - "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, 35}\n" + - "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), 35}\n" + - "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), 35}", + "goo[METHOD_REF]{goo(), LX;, (LI;)V, goo, (i), " + (R_DEFAULT + 19) + "}\n" + + "goo[METHOD_REF]{goo(), LX;, (Ljava.lang.String;)V, goo, (s), " + (R_DEFAULT + 19) + "}\n" + + "main[METHOD_REF]{main(), LX;, ([Ljava.lang.String;)V, main, (args), " + (R_DEFAULT + 19) + "}\n" + + "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_DEFAULT + 30) + "}\n" + + "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_DEFAULT + 30) + "}\n" + + "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, " + (R_DEFAULT + 30) + "}\n" + + "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, getClass, null, " + (R_DEFAULT + 30) + "}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_DEFAULT + 30) + "}\n" + + "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, " + (R_DEFAULT + 30) + "}\n" + + "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, " + (R_DEFAULT + 30) + "}\n" + + "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_DEFAULT + 30) + "}\n" + + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, " + (R_DEFAULT + 30) + "}\n" + + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), " + (R_DEFAULT + 30) + "}\n" + + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=422901, [1.8][code assist] Code assistant sensitive to scope.referenceContext type identity. @@ -509,8 +509,8 @@ public void test014() throws JavaModelException { // ensure higher relevance for String completeBehind = "arrayO"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("arrayOfStrings[LOCAL_VARIABLE_REF]{arrayOfStrings, null, [Ljava.lang.String;, null, null, arrayOfStrings, null, [168, 174], 27}\n" + - "arrayOfInts[LOCAL_VARIABLE_REF]{arrayOfInts, null, [I, null, null, arrayOfInts, null, [168, 174], 57}", requestor.getResults()); + assertResults("arrayOfStrings[LOCAL_VARIABLE_REF]{arrayOfStrings, null, [Ljava.lang.String;, null, null, arrayOfStrings, null, [168, 174], " + (R_DEFAULT + 22) + "}\n" + + "arrayOfInts[LOCAL_VARIABLE_REF]{arrayOfInts, null, [I, null, null, arrayOfInts, null, [168, 174], " + (R_DEFAULT + 52) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=422901, [1.8][code assist] Code assistant sensitive to scope.referenceContext type identity. public void test015() throws JavaModelException { // ensure higher relevance for matching return type. @@ -537,7 +537,7 @@ public void test015() throws JavaModelException { // ensure higher relevance for String completeBehind = "xyz"; int cursorLocation = str.indexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("xyzAfter[LOCAL_VARIABLE_REF]{xyzAfter, null, Ljava.lang.Object;, null, null, xyzAfter, null, [132, 135], 26}", requestor.getResults()); + assertResults("xyzAfter[LOCAL_VARIABLE_REF]{xyzAfter, null, Ljava.lang.Object;, null, null, xyzAfter, null, [132, 135], " + (R_DEFAULT + 21) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=422901, [1.8][code assist] Code assistant sensitive to scope.referenceContext type identity. public void test016() throws JavaModelException { // ensure higher relevance for matching return type. @@ -564,7 +564,7 @@ public void test016() throws JavaModelException { // ensure higher relevance for String completeBehind = "xyz"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("xyzBefore[LOCAL_VARIABLE_REF]{xyzBefore, null, Ljava.lang.Object;, null, null, xyzBefore, null, [163, 166], 26}", requestor.getResults()); + assertResults("xyzBefore[LOCAL_VARIABLE_REF]{xyzBefore, null, Ljava.lang.Object;, null, null, xyzBefore, null, [163, 166], " + (R_DEFAULT + 21) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=422901, [1.8][code assist] Code assistant sensitive to scope.referenceContext type identity. public void test017() throws JavaModelException { // ensure higher relevance for matching return type. @@ -732,20 +732,20 @@ public void testUnspecifiedReference() throws JavaModelException { // ensure com String completeBehind = "Stri"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("StringBufferInputStream[TYPE_REF]{java.io.StringBufferInputStream, java.io, Ljava.io.StringBufferInputStream;, null, null, null, null, [155, 159], 24}\n" + - "StringCharBuffer[TYPE_REF]{java.nio.StringCharBuffer, java.nio, Ljava.nio.StringCharBuffer;, null, null, null, null, [155, 159], 24}\n" + - "StringCharacterIterator[TYPE_REF]{java.text.StringCharacterIterator, java.text, Ljava.text.StringCharacterIterator;, null, null, null, null, [155, 159], 24}\n" + - "StringJoiner[TYPE_REF]{java.util.StringJoiner, java.util, Ljava.util.StringJoiner;, null, null, null, null, [155, 159], 24}\n" + - "StringReader[TYPE_REF]{java.io.StringReader, java.io, Ljava.io.StringReader;, null, null, null, null, [155, 159], 24}\n" + - "StringTokenizer[TYPE_REF]{java.util.StringTokenizer, java.util, Ljava.util.StringTokenizer;, null, null, null, null, [155, 159], 24}\n" + - "StringWriter[TYPE_REF]{java.io.StringWriter, java.io, Ljava.io.StringWriter;, null, null, null, null, [155, 159], 24}\n" + - "StrictMath[TYPE_REF]{StrictMath, java.lang, Ljava.lang.StrictMath;, null, null, null, null, [155, 159], 27}\n" + - "String[TYPE_REF]{String, java.lang, Ljava.lang.String;, null, null, null, null, [155, 159], 27}\n" + - "StringBuffer[TYPE_REF]{StringBuffer, java.lang, Ljava.lang.StringBuffer;, null, null, null, null, [155, 159], 27}\n" + - "StringBuilder[TYPE_REF]{StringBuilder, java.lang, Ljava.lang.StringBuilder;, null, null, null, null, [155, 159], 27}\n" + - "StringCoding[TYPE_REF]{StringCoding, java.lang, Ljava.lang.StringCoding;, null, null, null, null, [155, 159], 27}\n" + - "StringIndexOutOfBoundsException[TYPE_REF]{StringIndexOutOfBoundsException, java.lang, Ljava.lang.StringIndexOutOfBoundsException;, null, null, null, null, [155, 159], 27}\n" + - "StringParameter[LOCAL_VARIABLE_REF]{StringParameter, null, LX;, null, null, StringParameter, null, [155, 159], 27}", requestor.getResults()); + assertResults("StringBufferInputStream[TYPE_REF]{java.io.StringBufferInputStream, java.io, Ljava.io.StringBufferInputStream;, null, null, null, null, [155, 159], " + (R_DEFAULT + 19) + "}\n" + + "StringCharBuffer[TYPE_REF]{java.nio.StringCharBuffer, java.nio, Ljava.nio.StringCharBuffer;, null, null, null, null, [155, 159], " + (R_DEFAULT + 19) + "}\n" + + "StringCharacterIterator[TYPE_REF]{java.text.StringCharacterIterator, java.text, Ljava.text.StringCharacterIterator;, null, null, null, null, [155, 159], " + (R_DEFAULT + 19) + "}\n" + + "StringJoiner[TYPE_REF]{java.util.StringJoiner, java.util, Ljava.util.StringJoiner;, null, null, null, null, [155, 159], " + (R_DEFAULT + 19) + "}\n" + + "StringReader[TYPE_REF]{java.io.StringReader, java.io, Ljava.io.StringReader;, null, null, null, null, [155, 159], " + (R_DEFAULT + 19) + "}\n" + + "StringTokenizer[TYPE_REF]{java.util.StringTokenizer, java.util, Ljava.util.StringTokenizer;, null, null, null, null, [155, 159], " + (R_DEFAULT + 19) + "}\n" + + "StringWriter[TYPE_REF]{java.io.StringWriter, java.io, Ljava.io.StringWriter;, null, null, null, null, [155, 159], " + (R_DEFAULT + 19) + "}\n" + + "StrictMath[TYPE_REF]{StrictMath, java.lang, Ljava.lang.StrictMath;, null, null, null, null, [155, 159], " + (R_DEFAULT + 22) + "}\n" + + "String[TYPE_REF]{String, java.lang, Ljava.lang.String;, null, null, null, null, [155, 159], " + (R_DEFAULT + 22) + "}\n" + + "StringBuffer[TYPE_REF]{StringBuffer, java.lang, Ljava.lang.StringBuffer;, null, null, null, null, [155, 159], " + (R_DEFAULT + 22) + "}\n" + + "StringBuilder[TYPE_REF]{StringBuilder, java.lang, Ljava.lang.StringBuilder;, null, null, null, null, [155, 159], " + (R_DEFAULT + 22) + "}\n" + + "StringCoding[TYPE_REF]{StringCoding, java.lang, Ljava.lang.StringCoding;, null, null, null, null, [155, 159], " + (R_DEFAULT + 22) + "}\n" + + "StringIndexOutOfBoundsException[TYPE_REF]{StringIndexOutOfBoundsException, java.lang, Ljava.lang.StringIndexOutOfBoundsException;, null, null, null, null, [155, 159], " + (R_DEFAULT + 22) + "}\n" + + "StringParameter[LOCAL_VARIABLE_REF]{StringParameter, null, LX;, null, null, StringParameter, null, [155, 159], " + (R_DEFAULT + 22) + "}", requestor.getResults()); } public void testBrokenMethodCall() throws JavaModelException { // ensure completion works when the containing call is not terminated properly. this.workingCopies = new ICompilationUnit[1]; @@ -770,7 +770,7 @@ public void testBrokenMethodCall() throws JavaModelException { // ensure complet String completeBehind = "StringP"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("StringParameter[LOCAL_VARIABLE_REF]{StringParameter, null, LX;, null, null, StringParameter, null, [155, 162], 27}", requestor.getResults()); + assertResults("StringParameter[LOCAL_VARIABLE_REF]{StringParameter, null, LX;, null, null, StringParameter, null, [155, 162], " + (R_DEFAULT + 22) + "}", requestor.getResults()); } public void testExpressionBody() throws JavaModelException { this.workingCopies = new ICompilationUnit[1]; @@ -795,21 +795,21 @@ public void testExpressionBody() throws JavaModelException { String completeBehind = "xyz."; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("goo[METHOD_REF]{goo(), LX;, (LI;)V, null, null, goo, (i), [173, 173], 24}\n" + - "main[METHOD_REF]{main(), LX;, ([Ljava.lang.String;)V, null, null, main, (args), [173, 173], 24}\n" + - "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, null, null, clone, null, [173, 173], 35}\n" + - "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, null, null, equals, (obj), [173, 173], 35}\n" + - "field[FIELD_REF]{field, LX;, I, null, null, field, null, [173, 173], 35}\n" + - "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, null, null, finalize, null, [173, 173], 35}\n" + - "foo[METHOD_REF]{foo(), LX;, ()V, null, null, foo, null, [173, 173], 35}\n" + - "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [173, 173], 35}\n" + - "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, null, null, hashCode, null, [173, 173], 35}\n" + - "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, null, null, notify, null, [173, 173], 35}\n" + - "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, null, null, notifyAll, null, [173, 173], 35}\n" + - "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, null, null, toString, null, [173, 173], 35}\n" + - "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, null, null, wait, null, [173, 173], 35}\n" + - "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, null, null, wait, (millis), [173, 173], 35}\n" + - "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, null, null, wait, (millis, nanos), [173, 173], 35}", requestor.getResults()); + assertResults("goo[METHOD_REF]{goo(), LX;, (LI;)V, null, null, goo, (i), [173, 173], " + (R_DEFAULT + 19) + "}\n" + + "main[METHOD_REF]{main(), LX;, ([Ljava.lang.String;)V, null, null, main, (args), [173, 173], " + (R_DEFAULT + 19) + "}\n" + + "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, null, null, clone, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, null, null, equals, (obj), [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "field[FIELD_REF]{field, LX;, I, null, null, field, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, null, null, finalize, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "foo[METHOD_REF]{foo(), LX;, ()V, null, null, foo, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, null, null, hashCode, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, null, null, notify, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, null, null, notifyAll, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, null, null, toString, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, null, null, wait, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, null, null, wait, (millis), [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, null, null, wait, (millis, nanos), [173, 173], " + (R_DEFAULT + 30) + "}", requestor.getResults()); } public void testExpressionBody2() throws JavaModelException { this.workingCopies = new ICompilationUnit[1]; @@ -834,21 +834,21 @@ public void testExpressionBody2() throws JavaModelException { String completeBehind = "xyz."; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("goo[METHOD_REF]{goo(), LX;, (LI;)V, null, null, goo, (i), [173, 173], 24}\n" + - "main[METHOD_REF]{main(), LX;, ([Ljava.lang.String;)V, null, null, main, (args), [173, 173], 24}\n" + - "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, null, null, clone, null, [173, 173], 35}\n" + - "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, null, null, equals, (obj), [173, 173], 35}\n" + - "field[FIELD_REF]{field, LX;, I, null, null, field, null, [173, 173], 35}\n" + - "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, null, null, finalize, null, [173, 173], 35}\n" + - "foo[METHOD_REF]{foo(), LX;, ()V, null, null, foo, null, [173, 173], 35}\n" + - "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [173, 173], 35}\n" + - "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, null, null, hashCode, null, [173, 173], 35}\n" + - "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, null, null, notify, null, [173, 173], 35}\n" + - "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, null, null, notifyAll, null, [173, 173], 35}\n" + - "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, null, null, toString, null, [173, 173], 35}\n" + - "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, null, null, wait, null, [173, 173], 35}\n" + - "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, null, null, wait, (millis), [173, 173], 35}\n" + - "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, null, null, wait, (millis, nanos), [173, 173], 35}", requestor.getResults()); + assertResults("goo[METHOD_REF]{goo(), LX;, (LI;)V, null, null, goo, (i), [173, 173], " + (R_DEFAULT + 19) + "}\n" + + "main[METHOD_REF]{main(), LX;, ([Ljava.lang.String;)V, null, null, main, (args), [173, 173], " + (R_DEFAULT + 19) + "}\n" + + "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, null, null, clone, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, null, null, equals, (obj), [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "field[FIELD_REF]{field, LX;, I, null, null, field, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, null, null, finalize, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "foo[METHOD_REF]{foo(), LX;, ()V, null, null, foo, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, null, null, hashCode, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, null, null, notify, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, null, null, notifyAll, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, null, null, toString, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, null, null, wait, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, null, null, wait, (millis), [173, 173], " + (R_DEFAULT + 30) + "}\n" + + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, null, null, wait, (millis, nanos), [173, 173], " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // Bug 405125 - [1.8][code assist] static members of an interface appearing after the declaration of a static member lambda expression are not being suggested. // https://bugs.eclipse.org/bugs/show_bug.cgi?id=405125 @@ -877,7 +877,7 @@ public void testBug405125a() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "bars[METHOD_REF]{bars(), LB;, ()I, bars, null, 27}", + "bars[METHOD_REF]{bars(), LB;, ()I, bars, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } public void testBug405125b() throws JavaModelException { @@ -905,7 +905,7 @@ public void testBug405125b() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "another[FIELD_REF]{another, LB;, I, another, null, 27}", + "another[FIELD_REF]{another, LB;, I, another, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=425084, [1.8][completion] Eclipse freeze while autocompleting try block in lambda. @@ -932,8 +932,8 @@ public void test425084() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "tryit[LOCAL_VARIABLE_REF]{tryit, null, I, null, null, tryit, null, [99, 102], 27}\n" + - "try[KEYWORD]{try, null, null, null, null, try, null, [99, 102], 28}", + "tryit[LOCAL_VARIABLE_REF]{tryit, null, I, null, null, tryit, null, [99, 102], " + (R_DEFAULT + 22) + "}\n" + + "try[KEYWORD]{try, null, null, null, null, try, null, [99, 102], " + (R_DEFAULT + 23) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=422901, [1.8][code assist] Code assistant sensitive to scope.referenceContext type identity. @@ -1017,7 +1017,7 @@ public void test426851() throws JavaModelException { String completeBehind = "Ty"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("TypeUse[TYPE_REF]{TypeUse, , LTypeUse;, null, null, null, null, [131, 133], 52}", requestor.getResults()); + assertResults("TypeUse[TYPE_REF]{TypeUse, , LTypeUse;, null, null, null, null, [131, 133], " + (R_DEFAULT + 47) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=427532, [1.8][code assist] Completion engine does not like intersection casts public void test427532() throws JavaModelException { @@ -1136,7 +1136,7 @@ public void test427464() throws JavaModelException { String completeBehind = "@Ann"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("Annotation[TYPE_REF]{Annotation, , LAnnotation;, null, null, null, null, [138, 141], 47}", requestor.getResults()); + assertResults("Annotation[TYPE_REF]{Annotation, , LAnnotation;, null, null, null, null, [138, 141], " + (R_DEFAULT + 42) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=428735, [1.8][assist] Missing completion proposals inside lambda body expression - other than first token public void test428735() throws JavaModelException { @@ -1159,8 +1159,8 @@ public void test428735() throws JavaModelException { String completeBehind = "p.get"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [186, 189], 35}\n" + - "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [186, 189], 35}", requestor.getResults()); + assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [186, 189], " + (R_DEFAULT + 30) + "}\n" + + "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [186, 189], " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=428735, [1.8][assist] Missing completion proposals inside lambda body expression - other than first token public void test428735a() throws JavaModelException { @@ -1186,8 +1186,8 @@ public void test428735a() throws JavaModelException { String completeBehind = "x.get"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [267, 270], 35}\n" + - "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [267, 270], 35}", requestor.getResults()); + assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [267, 270], " + (R_DEFAULT + 30) + "}\n" + + "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [267, 270], " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=428735, [1.8][assist] Missing completion proposals inside lambda body expression - other than first token public void test428735b() throws JavaModelException { @@ -1213,8 +1213,8 @@ public void test428735b() throws JavaModelException { String completeBehind = "y.get"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [293, 296], 35}\n" + - "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [293, 296], 35}", requestor.getResults()); + assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [293, 296], " + (R_DEFAULT + 30) + "}\n" + + "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [293, 296], " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=428735, [1.8][assist] Missing completion proposals inside lambda body expression - other than first token public void test428735c() throws JavaModelException { @@ -1240,8 +1240,8 @@ public void test428735c() throws JavaModelException { String completeBehind = "y.get"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [285, 288], 35}\n" + - "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [285, 288], 65}", requestor.getResults()); + assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [285, 288], " + (R_DEFAULT + 30) + "}\n" + + "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [285, 288], " + (R_DEFAULT + 60) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=428735, [1.8][assist] Missing completion proposals inside lambda body expression - other than first token public void test428735d() throws JavaModelException { @@ -1267,8 +1267,8 @@ public void test428735d() throws JavaModelException { String completeBehind = "x.get"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [272, 275], 35}\n" + - "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [272, 275], 65}", requestor.getResults()); + assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [272, 275], " + (R_DEFAULT + 30) + "}\n" + + "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [272, 275], " + (R_DEFAULT + 60) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=428735, [1.8][assist] Missing completion proposals inside lambda body expression - other than first token public void test428735e() throws JavaModelException { @@ -1293,8 +1293,8 @@ public void test428735e() throws JavaModelException { String completeBehind = "x.get"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [203, 206], 35}\n" + - "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [203, 206], 65}", requestor.getResults()); + assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [203, 206], " + (R_DEFAULT + 30) + "}\n" + + "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [203, 206], " + (R_DEFAULT + 60) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=402081, [1.8][code complete] No proposals while completing at method/constructor references public void test402081() throws JavaModelException { @@ -1321,7 +1321,7 @@ public void test402081() throws JavaModelException { String completeBehind = "long"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("longMethodName[METHOD_NAME_REFERENCE]{longMethodName, LX;, (Ljava.lang.String;)Ljava.lang.String;, null, null, longMethodName, (x), [183, 187], 35}", requestor.getResults()); + assertResults("longMethodName[METHOD_NAME_REFERENCE]{longMethodName, LX;, (Ljava.lang.String;)Ljava.lang.String;, null, null, longMethodName, (x), [183, 187], " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=402081, [1.8][code complete] No proposals while completing at method/constructor references public void test402081a() throws JavaModelException { @@ -1351,7 +1351,7 @@ public void test402081a() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "longMethodName[METHOD_NAME_REFERENCE]{longMethodName, Ltest.X;, (Ljava.lang.String;)Ljava.lang.String;, longMethodName, (x), 35}", + "longMethodName[METHOD_NAME_REFERENCE]{longMethodName, Ltest.X;, (Ljava.lang.String;)Ljava.lang.String;, longMethodName, (x), " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=402081, [1.8][code complete] No proposals while completing at method/constructor references @@ -1377,7 +1377,7 @@ public void test402081b() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "longMethodName[METHOD_NAME_REFERENCE]{longMethodName, Ltest.X<Ljava.lang.String;>;, (Ljava.lang.String;)Ljava.lang.String;, longMethodName, (x), 35}", + "longMethodName[METHOD_NAME_REFERENCE]{longMethodName, Ltest.X<Ljava.lang.String;>;, (Ljava.lang.String;)Ljava.lang.String;, longMethodName, (x), " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=402081, [1.8][code complete] No proposals while completing at method/constructor references @@ -1406,7 +1406,7 @@ public void test402081c() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "longMethodName[METHOD_NAME_REFERENCE]{longMethodName, Ltest.Y;, (Ljava.lang.String;)Ljava.lang.String;, longMethodName, (x), 35}", + "longMethodName[METHOD_NAME_REFERENCE]{longMethodName, Ltest.Y;, (Ljava.lang.String;)Ljava.lang.String;, longMethodName, (x), " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=402081, [1.8][code complete] No proposals while completing at method/constructor references @@ -1435,7 +1435,7 @@ public void test402081d() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "longMethodName[METHOD_NAME_REFERENCE]{longMethodName, Ltest.Y;, (Ljava.lang.String;)Ljava.lang.String;, longMethodName, (x), 35}", + "longMethodName[METHOD_NAME_REFERENCE]{longMethodName, Ltest.Y;, (Ljava.lang.String;)Ljava.lang.String;, longMethodName, (x), " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=431402, [assist] NPE in AssistParser.triggerRecoveryUponLambdaClosure:483 using Content Assist @@ -1462,7 +1462,7 @@ public void test431402() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "asList[LOCAL_VARIABLE_REF]{asList, null, Ljava.lang.Object;, asList, null, 47}", + "asList[LOCAL_VARIABLE_REF]{asList, null, Ljava.lang.Object;, asList, null, " + (R_DEFAULT + 42) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=432527, Content Assist crashes sometimes using JDK8 @@ -1532,7 +1532,7 @@ public void test432527() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "removeNodeFromGraph[METHOD_REF]{removeNodeFromGraph(), Ltest.X;, (Ltest.X$Node;)V, removeNodeFromGraph, (node), 27}", + "removeNodeFromGraph[METHOD_REF]{removeNodeFromGraph(), Ltest.X;, (Ltest.X$Node;)V, removeNodeFromGraph, (node), " + (R_DEFAULT + 22) + "}", requestor.getResults()); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=430441, [compiler] NPE in ImplicitNullAnnotationVerifier.collectOverriddenMethods from Content Assist in a .jpage file @@ -1579,8 +1579,8 @@ public void test430656() throws JavaModelException { int cursorLocation = str.indexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "getClass[METHOD_NAME_REFERENCE]{getClass, Ljava.lang.Object;, ()Ljava.lang.Class<*>;, getClass, null, 35}\n" + - "getLastName[METHOD_NAME_REFERENCE]{getLastName, Ltest.Person;, ()Ljava.lang.String;, getLastName, null, 35}", + "getClass[METHOD_NAME_REFERENCE]{getClass, Ljava.lang.Object;, ()Ljava.lang.Class<*>;, getClass, null, " + (R_DEFAULT + 30) + "}\n" + + "getLastName[METHOD_NAME_REFERENCE]{getLastName, Ltest.Person;, ()Ljava.lang.String;, getLastName, null, " + (R_DEFAULT + 30) + "}", requestor.getResults()); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=433178 @@ -1656,7 +1656,7 @@ public void test435219() throws JavaModelException { String completeBehind = "System.o"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("out[FIELD_REF]{out, Ljava.lang.System;, Ljava.io.PrintStream;, null, null, out, null, [83, 84], 26}", requestor.getResults()); + assertResults("out[FIELD_REF]{out, Ljava.lang.System;, Ljava.io.PrintStream;, null, null, out, null, [83, 84], " + (R_DEFAULT + 21) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases public void test435219a() throws JavaModelException { @@ -1675,27 +1675,27 @@ public void test435219a() throws JavaModelException { String completeBehind = "System.out.p"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("print[METHOD_REF]{print(), Ljava.io.PrintStream;, (C)V, null, null, print, (arg0), [87, 88], 35}\n" + - "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (D)V, null, null, print, (arg0), [87, 88], 35}\n" + - "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (F)V, null, null, print, (arg0), [87, 88], 35}\n" + - "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (I)V, null, null, print, (arg0), [87, 88], 35}\n" + - "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (J)V, null, null, print, (arg0), [87, 88], 35}\n" + - "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, print, (arg0), [87, 88], 35}\n" + - "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, print, (arg0), [87, 88], 35}\n" + - "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (Z)V, null, null, print, (arg0), [87, 88], 35}\n" + - "print[METHOD_REF]{print(), Ljava.io.PrintStream;, ([C)V, null, null, print, (arg0), [87, 88], 35}\n" + - "printf[METHOD_REF]{printf(), Ljava.io.PrintStream;, (Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, (arg0, arg1), [87, 88], 35}\n" + - "printf[METHOD_REF]{printf(), Ljava.io.PrintStream;, (Ljava.util.Locale;Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, (arg0, arg1, arg2), [87, 88], 35}\n" + - "println[METHOD_REF]{println(), Ljava.io.PrintStream;, ()V, null, null, println, null, [87, 88], 35}\n" + - "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (C)V, null, null, println, (arg0), [87, 88], 35}\n" + - "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (D)V, null, null, println, (arg0), [87, 88], 35}\n" + - "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (F)V, null, null, println, (arg0), [87, 88], 35}\n" + - "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (I)V, null, null, println, (arg0), [87, 88], 35}\n" + - "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (J)V, null, null, println, (arg0), [87, 88], 35}\n" + - "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, println, (arg0), [87, 88], 35}\n" + - "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, println, (arg0), [87, 88], 35}\n" + - "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (Z)V, null, null, println, (arg0), [87, 88], 35}\n" + - "println[METHOD_REF]{println(), Ljava.io.PrintStream;, ([C)V, null, null, println, (arg0), [87, 88], 35}", requestor.getResults()); + assertResults("print[METHOD_REF]{print(), Ljava.io.PrintStream;, (C)V, null, null, print, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (D)V, null, null, print, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (F)V, null, null, print, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (I)V, null, null, print, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (J)V, null, null, print, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, print, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, print, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (Z)V, null, null, print, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "print[METHOD_REF]{print(), Ljava.io.PrintStream;, ([C)V, null, null, print, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "printf[METHOD_REF]{printf(), Ljava.io.PrintStream;, (Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, (arg0, arg1), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "printf[METHOD_REF]{printf(), Ljava.io.PrintStream;, (Ljava.util.Locale;Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, (arg0, arg1, arg2), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "println[METHOD_REF]{println(), Ljava.io.PrintStream;, ()V, null, null, println, null, [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (C)V, null, null, println, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (D)V, null, null, println, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (F)V, null, null, println, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (I)V, null, null, println, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (J)V, null, null, println, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, println, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, println, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (Z)V, null, null, println, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" + + "println[METHOD_REF]{println(), Ljava.io.PrintStream;, ([C)V, null, null, println, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases public void test435219b() throws JavaModelException { @@ -1714,9 +1714,9 @@ public void test435219b() throws JavaModelException { String completeBehind = "st"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("start[METHOD_REF]{start(), Ljava.lang.Thread;, ()V, null, null, start, null, [103, 105], 35}\n" + - "stop[METHOD_REF]{stop(), Ljava.lang.Thread;, ()V, null, null, stop, null, [103, 105], 35}\n" + - "stop[METHOD_REF]{stop(), Ljava.lang.Thread;, (Ljava.lang.Throwable;)V, null, null, stop, (arg0), [103, 105], 35}", requestor.getResults()); + assertResults("start[METHOD_REF]{start(), Ljava.lang.Thread;, ()V, null, null, start, null, [103, 105], " + (R_DEFAULT + 30) + "}\n" + + "stop[METHOD_REF]{stop(), Ljava.lang.Thread;, ()V, null, null, stop, null, [103, 105], " + (R_DEFAULT + 30) + "}\n" + + "stop[METHOD_REF]{stop(), Ljava.lang.Thread;, (Ljava.lang.Throwable;)V, null, null, stop, (arg0), [103, 105], " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases public void test435219c() throws JavaModelException { @@ -1738,9 +1738,9 @@ public void test435219c() throws JavaModelException { String completeBehind = "x.h"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("hashCode[METHOD_REF]{hashCode(), Ljava.lang.Integer;, (I)I, null, null, hashCode, (arg0), [187, 188], 54}\n" + - "highestOneBit[METHOD_REF]{highestOneBit(), Ljava.lang.Integer;, (I)I, null, null, highestOneBit, (arg0), [187, 188], 54}\n" + - "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Integer;, ()I, null, null, hashCode, null, [187, 188], 65}", requestor.getResults()); + assertResults("hashCode[METHOD_REF]{hashCode(), Ljava.lang.Integer;, (I)I, null, null, hashCode, (arg0), [187, 188], " + (R_DEFAULT + 49) + "}\n" + + "highestOneBit[METHOD_REF]{highestOneBit(), Ljava.lang.Integer;, (I)I, null, null, highestOneBit, (arg0), [187, 188], " + (R_DEFAULT + 49) + "}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Integer;, ()I, null, null, hashCode, null, [187, 188], " + (R_DEFAULT + 60) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases public void test435219d() throws JavaModelException { @@ -1762,27 +1762,27 @@ public void test435219d() throws JavaModelException { String completeBehind = "pri"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (C)V, null, null, print, null, [219, 222], 30}\n" + - "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (D)V, null, null, print, null, [219, 222], 30}\n" + - "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (F)V, null, null, print, null, [219, 222], 30}\n" + - "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (I)V, null, null, print, null, [219, 222], 30}\n" + - "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (J)V, null, null, print, null, [219, 222], 30}\n" + - "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, print, null, [219, 222], 30}\n" + - "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, print, null, [219, 222], 30}\n" + - "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Z)V, null, null, print, null, [219, 222], 30}\n" + - "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, ([C)V, null, null, print, null, [219, 222], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, ()V, null, null, println, null, [219, 222], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (C)V, null, null, println, null, [219, 222], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (D)V, null, null, println, null, [219, 222], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (F)V, null, null, println, null, [219, 222], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (I)V, null, null, println, null, [219, 222], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (J)V, null, null, println, null, [219, 222], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, println, null, [219, 222], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, println, null, [219, 222], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Z)V, null, null, println, null, [219, 222], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, ([C)V, null, null, println, null, [219, 222], 30}\n" + - "printf[METHOD_NAME_REFERENCE]{printf, Ljava.io.PrintStream;, (Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, null, [219, 222], 35}\n" + - "printf[METHOD_NAME_REFERENCE]{printf, Ljava.io.PrintStream;, (Ljava.util.Locale;Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, null, [219, 222], 35}", requestor.getResults()); + assertResults("print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (C)V, null, null, print, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (D)V, null, null, print, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (F)V, null, null, print, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (I)V, null, null, print, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (J)V, null, null, print, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, print, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, print, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Z)V, null, null, print, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, ([C)V, null, null, print, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, ()V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (C)V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (D)V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (F)V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (I)V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (J)V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Z)V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, ([C)V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" + + "printf[METHOD_NAME_REFERENCE]{printf, Ljava.io.PrintStream;, (Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, null, [219, 222], " + (R_DEFAULT + 30) + "}\n" + + "printf[METHOD_NAME_REFERENCE]{printf, Ljava.io.PrintStream;, (Ljava.util.Locale;Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, null, [219, 222], " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases public void test435219e() throws JavaModelException { @@ -1806,9 +1806,9 @@ public void test435219e() throws JavaModelException { String completeBehind = "dou"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("doubleToLongBits[METHOD_REF]{doubleToLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToLongBits, (arg0), [355, 358], 24}\n" + - "doubleToRawLongBits[METHOD_REF]{doubleToRawLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToRawLongBits, (arg0), [355, 358], 24}\n" + - "doubleValue[METHOD_REF]{doubleValue(), Ljava.lang.Double;, ()D, null, null, doubleValue, null, [355, 358], 35}", requestor.getResults()); + assertResults("doubleToLongBits[METHOD_REF]{doubleToLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToLongBits, (arg0), [355, 358], " + (R_DEFAULT + 19) + "}\n" + + "doubleToRawLongBits[METHOD_REF]{doubleToRawLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToRawLongBits, (arg0), [355, 358], " + (R_DEFAULT + 19) + "}\n" + + "doubleValue[METHOD_REF]{doubleValue(), Ljava.lang.Double;, ()D, null, null, doubleValue, null, [355, 358], " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases public void test435219f() throws JavaModelException { @@ -1832,8 +1832,8 @@ public void test435219f() throws JavaModelException { String completeBehind = "g"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [391, 392], 35}\n" + - "get[METHOD_REF]{get(), Ljava.util.Optional<Ljava.lang.Double;>;, ()Ljava.lang.Double;, null, null, get, null, [391, 392], 55}", requestor.getResults()); + assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [391, 392], " + (R_DEFAULT + 30) + "}\n" + + "get[METHOD_REF]{get(), Ljava.util.Optional<Ljava.lang.Double;>;, ()Ljava.lang.Double;, null, null, get, null, [391, 392], " + (R_DEFAULT + 50) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases public void test435219g() throws JavaModelException { @@ -1857,9 +1857,9 @@ public void test435219g() throws JavaModelException { String completeBehind = "dou"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("doubleToLongBits[METHOD_REF]{doubleToLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToLongBits, (arg0), [376, 379], 54}\n" + - "doubleToRawLongBits[METHOD_REF]{doubleToRawLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToRawLongBits, (arg0), [376, 379], 54}\n" + - "doubleValue[METHOD_REF]{doubleValue(), Ljava.lang.Double;, ()D, null, null, doubleValue, null, [376, 379], 65}", requestor.getResults()); + assertResults("doubleToLongBits[METHOD_REF]{doubleToLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToLongBits, (arg0), [376, 379], " + (R_DEFAULT + 49) + "}\n" + + "doubleToRawLongBits[METHOD_REF]{doubleToRawLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToRawLongBits, (arg0), [376, 379], " + (R_DEFAULT + 49) + "}\n" + + "doubleValue[METHOD_REF]{doubleValue(), Ljava.lang.Double;, ()D, null, null, doubleValue, null, [376, 379], " + (R_DEFAULT + 60) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=435682, [1.8] content assist not working inside lambda expression public void test435682() throws JavaModelException { @@ -1881,7 +1881,7 @@ public void test435682() throws JavaModelException { String completeBehind = "so.tr"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("trim[METHOD_REF]{trim(), Ljava.lang.String;, ()Ljava.lang.String;, null, null, trim, null, [237, 239], 35}", requestor.getResults()); + assertResults("trim[METHOD_REF]{trim(), Ljava.lang.String;, ()Ljava.lang.String;, null, null, trim, null, [237, 239], " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=435682, [1.8] content assist not working inside lambda expression public void test435682a() throws JavaModelException { @@ -1903,7 +1903,7 @@ public void test435682a() throws JavaModelException { String completeBehind = "so.tr"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("trim[METHOD_REF]{trim(), Ljava.lang.String;, ()Ljava.lang.String;, null, null, trim, null, [246, 248], 35}", requestor.getResults()); + assertResults("trim[METHOD_REF]{trim(), Ljava.lang.String;, ()Ljava.lang.String;, null, null, trim, null, [246, 248], " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=430667, [1.8][content assist] no proposals around lambda as a field public void test430667() throws JavaModelException { @@ -1929,8 +1929,8 @@ public void test430667() throws JavaModelException { String completeBehind = "D_F"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("D_F[POTENTIAL_METHOD_DECLARATION]{D_F, LD_DemoRefactorings;, ()V, null, null, D_F, null, [195, 198], 14}\n" + - "D_FI[TYPE_REF]{D_FI, , LD_FI;, null, null, null, null, [195, 198], 27}", requestor.getResults()); + assertResults("D_F[POTENTIAL_METHOD_DECLARATION]{D_F, LD_DemoRefactorings;, ()V, null, null, D_F, null, [195, 198], " + (R_DEFAULT + 9) + "}\n" + + "D_FI[TYPE_REF]{D_FI, , LD_FI;, null, null, null, null, [195, 198], " + (R_DEFAULT + 22) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=430667, [1.8][content assist] no proposals around lambda as a field public void test430667a() throws JavaModelException { @@ -1957,8 +1957,8 @@ public void test430667a() throws JavaModelException { String completeBehind = "/*HERE*/D_F"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("D_F[POTENTIAL_METHOD_DECLARATION]{D_F, LD_DemoRefactorings;, ()V, null, null, D_F, null, [150, 153], 14}\n" + - "D_FI[TYPE_REF]{D_FI, , LD_FI;, null, null, null, null, [150, 153], 27}", requestor.getResults()); + assertResults("D_F[POTENTIAL_METHOD_DECLARATION]{D_F, LD_DemoRefactorings;, ()V, null, null, D_F, null, [150, 153], " + (R_DEFAULT + 9) + "}\n" + + "D_FI[TYPE_REF]{D_FI, , LD_FI;, null, null, null, null, [150, 153], " + (R_DEFAULT + 22) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=430667, [1.8][content assist] no proposals around lambda as a field public void test430667b() throws JavaModelException { @@ -1984,8 +1984,8 @@ public void test430667b() throws JavaModelException { String completeBehind = "/*HERE*/D_F"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("D_F[POTENTIAL_METHOD_DECLARATION]{D_F, LD_DemoRefactorings;, ()V, null, null, D_F, null, [36, 39], 14}\n" + - "D_FI[TYPE_REF]{D_FI, , LD_FI;, null, null, null, null, [36, 39], 27}", requestor.getResults()); + assertResults("D_F[POTENTIAL_METHOD_DECLARATION]{D_F, LD_DemoRefactorings;, ()V, null, null, D_F, null, [36, 39], " + (R_DEFAULT + 9) + "}\n" + + "D_FI[TYPE_REF]{D_FI, , LD_FI;, null, null, null, null, [36, 39], " + (R_DEFAULT + 22) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=443932, [1.8][code complete] method reference proposals not applied when caret inside method name public void test443932() throws JavaModelException { @@ -2003,15 +2003,15 @@ public void test443932() throws JavaModelException { String completeBehind = "to"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("toBinaryString[METHOD_NAME_REFERENCE]{toBinaryString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toBinaryString, null, [90, 98], 24}\n" + - "toHexString[METHOD_NAME_REFERENCE]{toHexString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toHexString, null, [90, 98], 24}\n" + - "toOctalString[METHOD_NAME_REFERENCE]{toOctalString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toOctalString, null, [90, 98], 24}\n" + - "toString[METHOD_NAME_REFERENCE]{toString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toString, null, [90, 98], 24}\n" + - "toString[METHOD_NAME_REFERENCE]{toString, Ljava.lang.Integer;, (II)Ljava.lang.String;, null, null, toString, null, [90, 98], 24}\n" + - "toUnsignedLong[METHOD_NAME_REFERENCE]{toUnsignedLong, Ljava.lang.Integer;, (I)J, null, null, toUnsignedLong, null, [90, 98], 24}\n" + - "toUnsignedString[METHOD_NAME_REFERENCE]{toUnsignedString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toUnsignedString, null, [90, 98], 24}\n" + - "toUnsignedString[METHOD_NAME_REFERENCE]{toUnsignedString, Ljava.lang.Integer;, (II)Ljava.lang.String;, null, null, toUnsignedString, null, [90, 98], 24}\n" + - "toString[METHOD_NAME_REFERENCE]{toString, Ljava.lang.Integer;, ()Ljava.lang.String;, null, null, toString, null, [90, 98], 35}", requestor.getResults()); + assertResults("toBinaryString[METHOD_NAME_REFERENCE]{toBinaryString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toBinaryString, null, [90, 98], " + (R_DEFAULT + 19) + "}\n" + + "toHexString[METHOD_NAME_REFERENCE]{toHexString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toHexString, null, [90, 98], " + (R_DEFAULT + 19) + "}\n" + + "toOctalString[METHOD_NAME_REFERENCE]{toOctalString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toOctalString, null, [90, 98], " + (R_DEFAULT + 19) + "}\n" + + "toString[METHOD_NAME_REFERENCE]{toString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toString, null, [90, 98], " + (R_DEFAULT + 19) + "}\n" + + "toString[METHOD_NAME_REFERENCE]{toString, Ljava.lang.Integer;, (II)Ljava.lang.String;, null, null, toString, null, [90, 98], " + (R_DEFAULT + 19) + "}\n" + + "toUnsignedLong[METHOD_NAME_REFERENCE]{toUnsignedLong, Ljava.lang.Integer;, (I)J, null, null, toUnsignedLong, null, [90, 98], " + (R_DEFAULT + 19) + "}\n" + + "toUnsignedString[METHOD_NAME_REFERENCE]{toUnsignedString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toUnsignedString, null, [90, 98], " + (R_DEFAULT + 19) + "}\n" + + "toUnsignedString[METHOD_NAME_REFERENCE]{toUnsignedString, Ljava.lang.Integer;, (II)Ljava.lang.String;, null, null, toUnsignedString, null, [90, 98], " + (R_DEFAULT + 19) + "}\n" + + "toString[METHOD_NAME_REFERENCE]{toString, Ljava.lang.Integer;, ()Ljava.lang.String;, null, null, toString, null, [90, 98], " + (R_DEFAULT + 30) + "}", requestor.getResults()); assertTrue(str.substring(90, 98).equals("toString")); } @@ -2034,8 +2034,8 @@ public void test444300() throws JavaModelException { String completeBehind = "so.ch"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("charAt[METHOD_REF]{charAt(), Ljava.lang.String;, (I)C, null, null, charAt, (arg0), [232, 234], 35}\n" + - "chars[METHOD_REF]{chars(), Ljava.lang.CharSequence;, ()Ljava.util.stream.IntStream;, null, null, chars, null, [232, 234], 35}", requestor.getResults()); + assertResults("charAt[METHOD_REF]{charAt(), Ljava.lang.String;, (I)C, null, null, charAt, (arg0), [232, 234], " + (R_DEFAULT + 30) + "}\n" + + "chars[METHOD_REF]{chars(), Ljava.lang.CharSequence;, ()Ljava.util.stream.IntStream;, null, null, chars, null, [232, 234], " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases // https://bugs.eclipse.org/bugs/show_bug.cgi?id=444300, [1.8] content assist not working inside lambda expression in case of fields @@ -2056,9 +2056,9 @@ public void test435219h() throws JavaModelException { String completeBehind = "x.h"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("hashCode[METHOD_REF]{hashCode(), Ljava.lang.Integer;, (I)I, null, null, hashCode, (arg0), [164, 165], 54}\n" + - "highestOneBit[METHOD_REF]{highestOneBit(), Ljava.lang.Integer;, (I)I, null, null, highestOneBit, (arg0), [164, 165], 54}\n" + - "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Integer;, ()I, null, null, hashCode, null, [164, 165], 65}", requestor.getResults()); + assertResults("hashCode[METHOD_REF]{hashCode(), Ljava.lang.Integer;, (I)I, null, null, hashCode, (arg0), [164, 165], " + (R_DEFAULT + 49) + "}\n" + + "highestOneBit[METHOD_REF]{highestOneBit(), Ljava.lang.Integer;, (I)I, null, null, highestOneBit, (arg0), [164, 165], " + (R_DEFAULT + 49) + "}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Integer;, ()I, null, null, hashCode, null, [164, 165], " + (R_DEFAULT + 60) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases // https://bugs.eclipse.org/bugs/show_bug.cgi?id=444300, [1.8] content assist not working inside lambda expression in case of fields @@ -2079,27 +2079,27 @@ public void test435219i() throws JavaModelException { String completeBehind = "pri"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (C)V, null, null, print, null, [188, 191], 30}\n" + - "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (D)V, null, null, print, null, [188, 191], 30}\n" + - "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (F)V, null, null, print, null, [188, 191], 30}\n" + - "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (I)V, null, null, print, null, [188, 191], 30}\n" + - "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (J)V, null, null, print, null, [188, 191], 30}\n" + - "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, print, null, [188, 191], 30}\n" + - "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, print, null, [188, 191], 30}\n" + - "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Z)V, null, null, print, null, [188, 191], 30}\n" + - "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, ([C)V, null, null, print, null, [188, 191], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, ()V, null, null, println, null, [188, 191], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (C)V, null, null, println, null, [188, 191], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (D)V, null, null, println, null, [188, 191], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (F)V, null, null, println, null, [188, 191], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (I)V, null, null, println, null, [188, 191], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (J)V, null, null, println, null, [188, 191], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, println, null, [188, 191], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, println, null, [188, 191], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Z)V, null, null, println, null, [188, 191], 30}\n" + - "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, ([C)V, null, null, println, null, [188, 191], 30}\n" + - "printf[METHOD_NAME_REFERENCE]{printf, Ljava.io.PrintStream;, (Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, null, [188, 191], 35}\n" + - "printf[METHOD_NAME_REFERENCE]{printf, Ljava.io.PrintStream;, (Ljava.util.Locale;Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, null, [188, 191], 35}", requestor.getResults()); + assertResults("print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (C)V, null, null, print, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (D)V, null, null, print, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (F)V, null, null, print, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (I)V, null, null, print, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (J)V, null, null, print, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, print, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, print, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Z)V, null, null, print, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, ([C)V, null, null, print, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, ()V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (C)V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (D)V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (F)V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (I)V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (J)V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Z)V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, ([C)V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" + + "printf[METHOD_NAME_REFERENCE]{printf, Ljava.io.PrintStream;, (Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, null, [188, 191], " + (R_DEFAULT + 30) + "}\n" + + "printf[METHOD_NAME_REFERENCE]{printf, Ljava.io.PrintStream;, (Ljava.util.Locale;Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, null, [188, 191], " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases // https://bugs.eclipse.org/bugs/show_bug.cgi?id=444300, [1.8] content assist not working inside lambda expression in case of fields @@ -2121,9 +2121,9 @@ public void test435219j() throws JavaModelException { String completeBehind = "dou"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("doubleToLongBits[METHOD_REF]{doubleToLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToLongBits, (arg0), [235, 238], 24}\n" + - "doubleToRawLongBits[METHOD_REF]{doubleToRawLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToRawLongBits, (arg0), [235, 238], 24}\n" + - "doubleValue[METHOD_REF]{doubleValue(), Ljava.lang.Double;, ()D, null, null, doubleValue, null, [235, 238], 35}", requestor.getResults()); + assertResults("doubleToLongBits[METHOD_REF]{doubleToLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToLongBits, (arg0), [235, 238], " + (R_DEFAULT + 19) + "}\n" + + "doubleToRawLongBits[METHOD_REF]{doubleToRawLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToRawLongBits, (arg0), [235, 238], " + (R_DEFAULT + 19) + "}\n" + + "doubleValue[METHOD_REF]{doubleValue(), Ljava.lang.Double;, ()D, null, null, doubleValue, null, [235, 238], " + (R_DEFAULT + 30) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases // https://bugs.eclipse.org/bugs/show_bug.cgi?id=444300, [1.8] content assist not working inside lambda expression in case of fields @@ -2145,8 +2145,8 @@ public void test435219k() throws JavaModelException { String completeBehind = "g"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [271, 272], 35}\n" + - "get[METHOD_REF]{get(), Ljava.util.Optional<Ljava.lang.Double;>;, ()Ljava.lang.Double;, null, null, get, null, [271, 272], 55}", requestor.getResults()); + assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [271, 272], " + (R_DEFAULT + 30) + "}\n" + + "get[METHOD_REF]{get(), Ljava.util.Optional<Ljava.lang.Double;>;, ()Ljava.lang.Double;, null, null, get, null, [271, 272], " + (R_DEFAULT + 50) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases // https://bugs.eclipse.org/bugs/show_bug.cgi?id=444300, [1.8] content assist not working inside lambda expression in case of fields @@ -2168,22 +2168,22 @@ public void test435219l() throws JavaModelException { String completeBehind = "dou"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("doubleToLongBits[METHOD_REF]{doubleToLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToLongBits, (arg0), [256, 259], 54}\n" + - "doubleToRawLongBits[METHOD_REF]{doubleToRawLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToRawLongBits, (arg0), [256, 259], 54}\n" + - "doubleValue[METHOD_REF]{doubleValue(), Ljava.lang.Double;, ()D, null, null, doubleValue, null, [256, 259], 65}", requestor.getResults()); + assertResults("doubleToLongBits[METHOD_REF]{doubleToLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToLongBits, (arg0), [256, 259], " + (R_DEFAULT + 49) + "}\n" + + "doubleToRawLongBits[METHOD_REF]{doubleToRawLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToRawLongBits, (arg0), [256, 259], " + (R_DEFAULT + 49) + "}\n" + + "doubleValue[METHOD_REF]{doubleValue(), Ljava.lang.Double;, ()D, null, null, doubleValue, null, [256, 259], " + (R_DEFAULT + 60) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=435281, [1.8][code assist] No import or completion proposal for anonymous class inside lambda public void test435281() throws JavaModelException { this.workingCopies = new ICompilationUnit[3]; this.workingCopies[0] = getWorkingCopy( - "/Completion/src/p4a/FI1.java", + "/Completion/src/FI1.java", "package p4a;\n" + "@FunctionalInterface\n" + "public interface FI1<R> {\n" + " public R foo1();\n" + "}\n"); this.workingCopies[1] = getWorkingCopy( - "/Completion/src/p4a/FI2.java", + "/Completion/src/FI2.java", "package p4a;\n" + "@FunctionalInterface\n" + "public interface FI2 {\n" + @@ -2210,7 +2210,7 @@ public void test435281() throws JavaModelException { String completeBehind = "FI2"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[2].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("FI2[TYPE_REF]{p4a.FI2, p4a, Lp4a.FI2;, null, null, null, null, [104, 107], 28}", requestor.getResults()); + assertResults("FI2[TYPE_REF]{p4a.FI2, p4a, Lp4a.FI2;, null, null, null, null, [104, 107], " + (R_DEFAULT + 23) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=431811, content assist should propose keyword 'super' after type name public void test431811() throws JavaModelException { @@ -2238,7 +2238,7 @@ public void test431811() throws JavaModelException { String completeBehind = "su"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("super[KEYWORD]{super, null, null, null, null, super, null, [192, 194], 26}", requestor.getResults()); + assertResults("super[KEYWORD]{super, null, null, null, null, super, null, [192, 194], " + (R_DEFAULT + 21) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=447774, Auto complete does not work when using lambdas with cast public void test447774() throws JavaModelException { @@ -2300,8 +2300,8 @@ public void test449358() throws JavaModelException { String completeBehind = "/*HERE*/localMeth"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("localmethod1[METHOD_REF]{localmethod1(), LLambdaBug;, ()V, null, null, localmethod1, null, [181, 190], 17}\n" + - "localmethod2[METHOD_REF]{localmethod2(), LLambdaBug;, ()V, null, null, localmethod2, null, [181, 190], 17}", requestor.getResults()); + assertResults("localmethod1[METHOD_REF]{localmethod1(), LLambdaBug;, ()V, null, null, localmethod1, null, [181, 190], " + (R_DEFAULT + 12) + "}\n" + + "localmethod2[METHOD_REF]{localmethod2(), LLambdaBug;, ()V, null, null, localmethod2, null, [181, 190], " + (R_DEFAULT + 12) + "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=449358, Content assist inside lambda broken in all methods except last @@ -2333,8 +2333,8 @@ public void test449358a() throws JavaModelException { String completeBehind = "/*HERE*/localMeth"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertResults("localmethod1[METHOD_REF]{localmethod1(), LLambdaBug;, ()V, null, null, localmethod1, null, [282, 291], 17}\n" + - "localmethod2[METHOD_REF]{localmethod2(), LLambdaBug;, ()V, null, null, localmethod2, null, [282, 291], 17}", requestor.getResults()); + assertResults("localmethod1[METHOD_REF]{localmethod1(), LLambdaBug;, ()V, null, null, localmethod1, null, [282, 291], " + (R_DEFAULT + 12) + "}\n" + + "localmethod2[METHOD_REF]{localmethod2(), LLambdaBug;, ()V, null, null, localmethod2, null, [282, 291], " + (R_DEFAULT + 12) + "}", requestor.getResults()); } public void testBug459189_001() throws JavaModelException { @@ -2359,9 +2359,9 @@ public void testBug459189_001() throws JavaModelException { int cursorLocation = str.indexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "Retention[TYPE_REF]{java.lang.annotation.Retention, java.lang.annotation, Ljava.lang.annotation.Retention;, null, null, 14}\n"+ - "RetentionPolicy[TYPE_REF]{java.lang.annotation.RetentionPolicy, java.lang.annotation, Ljava.lang.annotation.RetentionPolicy;, null, null, 14}\n"+ - "return[KEYWORD]{return, null, null, return, null, 24}", + "Retention[TYPE_REF]{java.lang.annotation.Retention, java.lang.annotation, Ljava.lang.annotation.Retention;, null, null, " + (R_DEFAULT + 9) + "}\n"+ + "RetentionPolicy[TYPE_REF]{java.lang.annotation.RetentionPolicy, java.lang.annotation, Ljava.lang.annotation.RetentionPolicy;, null, null, " + (R_DEFAULT + 9) + "}\n"+ + "return[KEYWORD]{return, null, null, return, null, " + (R_DEFAULT + 19) + "}", requestor.getResults()); } public void testBug459189_002() throws JavaModelException { @@ -2386,9 +2386,9 @@ public void testBug459189_002() throws JavaModelException { int cursorLocation = str.indexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "Retention[TYPE_REF]{java.lang.annotation.Retention, java.lang.annotation, Ljava.lang.annotation.Retention;, null, null, 14}\n"+ - "RetentionPolicy[TYPE_REF]{java.lang.annotation.RetentionPolicy, java.lang.annotation, Ljava.lang.annotation.RetentionPolicy;, null, null, 14}\n" + - "return[KEYWORD]{return, null, null, return, null, 24}", + "Retention[TYPE_REF]{java.lang.annotation.Retention, java.lang.annotation, Ljava.lang.annotation.Retention;, null, null, " + (R_DEFAULT + 9) + "}\n"+ + "RetentionPolicy[TYPE_REF]{java.lang.annotation.RetentionPolicy, java.lang.annotation, Ljava.lang.annotation.RetentionPolicy;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "return[KEYWORD]{return, null, null, return, null, " + (R_DEFAULT + 19) + "}", requestor.getResults()); } public void testBug459189_003() throws JavaModelException { @@ -2413,8 +2413,8 @@ public void testBug459189_003() throws JavaModelException { int cursorLocation = str.indexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "catch[KEYWORD]{catch, null, null, catch, null, 24}\n"+ - "finally[KEYWORD]{finally, null, null, finally, null, 24}", + "catch[KEYWORD]{catch, null, null, catch, null, " + (R_DEFAULT + 19) + "}\n"+ + "finally[KEYWORD]{finally, null, null, finally, null, " + (R_DEFAULT + 19) + "}", requestor.getResults()); } public void testBug459189_004() throws JavaModelException { @@ -2439,7 +2439,7 @@ public void testBug459189_004() throws JavaModelException { int cursorLocation = str.indexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "while[KEYWORD]{while, null, null, while, null, 24}", + "while[KEYWORD]{while, null, null, while, null, " + (R_DEFAULT + 19) + "}", requestor.getResults()); } public void testBug460410() throws JavaModelException { @@ -2491,7 +2491,7 @@ public void testBug481564() throws JavaModelException { int cursorLocation = str.indexOf(completeBehind) ; this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "someMethod[METHOD_REF]{someMethod(), LX;, ()V, someMethod, null, 27}", requestor.getResults()); + "someMethod[METHOD_REF]{someMethod(), LX;, ()V, someMethod, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=481215 public void testBug481215a() throws JavaModelException { @@ -2523,11 +2523,11 @@ public void testBug481215a() throws JavaModelException { int cursorLocation = str.indexOf(completeBehind) ; this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "ResourceBundle[TYPE_REF]{java.util.ResourceBundle, java.util, Ljava.util.ResourceBundle;, null, null, 14}\n" + - "ResponseCache[TYPE_REF]{java.net.ResponseCache, java.net, Ljava.net.ResponseCache;, null, null, 14}\n" + - "ResultSet[TYPE_REF]{java.sql.ResultSet, java.sql, Ljava.sql.ResultSet;, null, null, 14}\n" + - "ResultSetMetaData[TYPE_REF]{java.sql.ResultSetMetaData, java.sql, Ljava.sql.ResultSetMetaData;, null, null, 14}\n" + - "result[LOCAL_VARIABLE_REF]{result, null, Ljava.lang.String;, result, null, 27}", requestor.getResults()); + "ResourceBundle[TYPE_REF]{java.util.ResourceBundle, java.util, Ljava.util.ResourceBundle;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "ResponseCache[TYPE_REF]{java.net.ResponseCache, java.net, Ljava.net.ResponseCache;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "ResultSet[TYPE_REF]{java.sql.ResultSet, java.sql, Ljava.sql.ResultSet;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "ResultSetMetaData[TYPE_REF]{java.sql.ResultSetMetaData, java.sql, Ljava.sql.ResultSetMetaData;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "result[LOCAL_VARIABLE_REF]{result, null, Ljava.lang.String;, result, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } public void testBug481215b() throws JavaModelException { this.workingCopies = new ICompilationUnit[1]; @@ -2555,11 +2555,11 @@ public void testBug481215b() throws JavaModelException { int cursorLocation = str.indexOf(completeBehind) ; this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "ResourceBundle[TYPE_REF]{java.util.ResourceBundle, java.util, Ljava.util.ResourceBundle;, null, null, 14}\n" + - "ResponseCache[TYPE_REF]{java.net.ResponseCache, java.net, Ljava.net.ResponseCache;, null, null, 14}\n" + - "ResultSet[TYPE_REF]{java.sql.ResultSet, java.sql, Ljava.sql.ResultSet;, null, null, 14}\n" + - "ResultSetMetaData[TYPE_REF]{java.sql.ResultSetMetaData, java.sql, Ljava.sql.ResultSetMetaData;, null, null, 14}\n" + - "result[LOCAL_VARIABLE_REF]{result, null, Ljava.lang.String;, result, null, 27}", requestor.getResults()); + "ResourceBundle[TYPE_REF]{java.util.ResourceBundle, java.util, Ljava.util.ResourceBundle;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "ResponseCache[TYPE_REF]{java.net.ResponseCache, java.net, Ljava.net.ResponseCache;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "ResultSet[TYPE_REF]{java.sql.ResultSet, java.sql, Ljava.sql.ResultSet;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "ResultSetMetaData[TYPE_REF]{java.sql.ResultSetMetaData, java.sql, Ljava.sql.ResultSetMetaData;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "result[LOCAL_VARIABLE_REF]{result, null, Ljava.lang.String;, result, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } public void testBug481215c() throws JavaModelException { this.workingCopies = new ICompilationUnit[1]; @@ -2587,11 +2587,11 @@ public void testBug481215c() throws JavaModelException { int cursorLocation = str.indexOf(completeBehind) ; this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "ResourceBundle[TYPE_REF]{java.util.ResourceBundle, java.util, Ljava.util.ResourceBundle;, null, null, 14}\n" + - "ResponseCache[TYPE_REF]{java.net.ResponseCache, java.net, Ljava.net.ResponseCache;, null, null, 14}\n" + - "ResultSet[TYPE_REF]{java.sql.ResultSet, java.sql, Ljava.sql.ResultSet;, null, null, 14}\n" + - "ResultSetMetaData[TYPE_REF]{java.sql.ResultSetMetaData, java.sql, Ljava.sql.ResultSetMetaData;, null, null, 14}\n" + - "result[LOCAL_VARIABLE_REF]{result, null, Ljava.lang.String;, result, null, 27}", requestor.getResults()); + "ResourceBundle[TYPE_REF]{java.util.ResourceBundle, java.util, Ljava.util.ResourceBundle;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "ResponseCache[TYPE_REF]{java.net.ResponseCache, java.net, Ljava.net.ResponseCache;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "ResultSet[TYPE_REF]{java.sql.ResultSet, java.sql, Ljava.sql.ResultSet;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "ResultSetMetaData[TYPE_REF]{java.sql.ResultSetMetaData, java.sql, Ljava.sql.ResultSetMetaData;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "result[LOCAL_VARIABLE_REF]{result, null, Ljava.lang.String;, result, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } public void testBug481215d() throws JavaModelException { this.workingCopies = new ICompilationUnit[1]; @@ -2627,12 +2627,12 @@ public void testBug481215d() throws JavaModelException { int cursorLocation = str.indexOf(completeBehind) ; this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "ResourceBundle[TYPE_REF]{java.util.ResourceBundle, java.util, Ljava.util.ResourceBundle;, null, null, 14}\n" + - "ResponseCache[TYPE_REF]{java.net.ResponseCache, java.net, Ljava.net.ResponseCache;, null, null, 14}\n" + - "ResultSet[TYPE_REF]{java.sql.ResultSet, java.sql, Ljava.sql.ResultSet;, null, null, 14}\n" + - "ResultSetMetaData[TYPE_REF]{java.sql.ResultSetMetaData, java.sql, Ljava.sql.ResultSetMetaData;, null, null, 14}\n" + - "result[LOCAL_VARIABLE_REF]{result, null, Ljava.lang.String;, result, null, 27}\n" + - "result2[LOCAL_VARIABLE_REF]{result2, null, Ljava.lang.String;, result2, null, 27}", requestor.getResults()); + "ResourceBundle[TYPE_REF]{java.util.ResourceBundle, java.util, Ljava.util.ResourceBundle;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "ResponseCache[TYPE_REF]{java.net.ResponseCache, java.net, Ljava.net.ResponseCache;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "ResultSet[TYPE_REF]{java.sql.ResultSet, java.sql, Ljava.sql.ResultSet;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "ResultSetMetaData[TYPE_REF]{java.sql.ResultSetMetaData, java.sql, Ljava.sql.ResultSetMetaData;, null, null, " + (R_DEFAULT + 9) + "}\n" + + "result[LOCAL_VARIABLE_REF]{result, null, Ljava.lang.String;, result, null, " + (R_DEFAULT + 22) + "}\n" + + "result2[LOCAL_VARIABLE_REF]{result2, null, Ljava.lang.String;, result2, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=484479 public void test484479() throws JavaModelException { diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java index 827681ce6..ea37cbcd3 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java @@ -5502,7 +5502,7 @@ public void testBug317264a() throws CoreException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); cu.codeComplete(cursorLocation, requestor); assertResults( - "Enum[TYPE_REF]{Enum, java.lang, Ljava.lang.Enum;, null, null, 17}", + "Enum[TYPE_REF]{Enum, java.lang, Ljava.lang.Enum;, null, null, " + (R_DEFAULT + 12) + "}", requestor.getResults()); } finally { @@ -5535,7 +5535,7 @@ public void testBug317264b() throws CoreException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); cu.codeComplete(cursorLocation, requestor); assertResults( - "Enum[TYPE_REF]{org.apache.commons.lang.enum.Enum, org.apache.commons.lang.enum, Lorg.apache.commons.lang.enum.Enum;, null, null, 14}", + "Enum[TYPE_REF]{org.apache.commons.lang.enum.Enum, org.apache.commons.lang.enum, Lorg.apache.commons.lang.enum.Enum;, null, null, " + (R_DEFAULT + 9) + "}", requestor.getResults()); } finally { @@ -5597,7 +5597,7 @@ public void testBug317264d() throws CoreException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); cu.codeComplete(cursorLocation, requestor); assertResults( - "org.apache.commons.lang.enum[PACKAGE_REF]{org.apache.commons.lang.enum.*;, org.apache.commons.lang.enum, null, null, null, 24}", + "org.apache.commons.lang.enum[PACKAGE_REF]{org.apache.commons.lang.enum.*;, org.apache.commons.lang.enum, null, null, null, " + (R_DEFAULT + 19) + "}", requestor.getResults()); } finally { @@ -6148,7 +6148,7 @@ public void testBug410207a() throws Exception { CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true); cu.codeComplete(cursorLocation, requestor); assertResults( - "Main[TYPE_REF]{Main, p, Lp.Main;, null, null, 27}", + "Main[TYPE_REF]{Main, p, Lp.Main;, null, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } finally { deleteProject("P"); @@ -6206,7 +6206,7 @@ public void testBug410207b() throws Exception { CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true); cu.codeComplete(cursorLocation, requestor); assertResults( - "Main[TYPE_REF]{Main, p, Lp.Main;, null, null, 27}", + "Main[TYPE_REF]{Main, p, Lp.Main;, null, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } finally { deleteProject("P"); @@ -6262,7 +6262,7 @@ public void testBug410207c() throws Exception { CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true); cu.codeComplete(cursorLocation, requestor); assertResults( - "Main[TYPE_REF]{Main, p, Lp.Main;, null, null, 27}", + "Main[TYPE_REF]{Main, p, Lp.Main;, null, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } finally { deleteProjects(new String[] { "Lib", "P" }); @@ -6318,7 +6318,7 @@ public void testBug410207d() throws Exception { CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true); cu.codeComplete(cursorLocation, requestor); assertResults( - "Main[TYPE_REF]{Main, p, Lp.Main;, null, null, 27}", + "Main[TYPE_REF]{Main, p, Lp.Main;, null, null, " + (R_DEFAULT + 22) + "}", requestor.getResults()); } finally { deleteProjects(new String[] { "Lib", "P" }); @@ -6409,7 +6409,7 @@ public void testBug376977() throws CoreException { this.workingCopies[2].codeComplete(cursorLocation, requestor, this.wcOwner, monitor); assertResults( - "Nested[TYPE_REF]{Nested, myannotations, Lmyannotations.Nested;, null, null, 47}", + "Nested[TYPE_REF]{Nested, myannotations, Lmyannotations.Nested;, null, null, " + (R_DEFAULT + 42) + "}", requestor.getResults()); } finally { deleteProject("P"); @@ -6483,7 +6483,7 @@ public void test479656() throws Exception { CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true); cu.codeComplete(cursorLocation, requestor); assertResults( - "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, 35}", + "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_DEFAULT + 30) + "}", requestor.getResults()); } finally { deleteProject("P"); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java index 2a685d576..ac305745a 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13503,8 +13503,8 @@ public void testCompletionOnExtends() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "ThisClassIsFinal[TYPE_REF]{ThisClassIsFinal, test, Ltest.ThisClassIsFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_CLASS) + "}\n" + - "ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_CLASS) + "}", + "ThisClassIsFinal[TYPE_REF]{ThisClassIsFinal, test, Ltest.ThisClassIsFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + + "ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", requestor.getResults()); } @@ -13846,9 +13846,9 @@ public void testBug310423a() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "Inn.Inn2[TYPE_REF]{label.Inn.Inn2, label, Llabel.Inn$Inn2;, null, null, 44}\n" + - "In[TYPE_REF]{In, label, Llabel.In;, null, null, 47}\n" + - "Inn[TYPE_REF]{Inn, label, Llabel.Inn;, null, null, 47}", + "Inn.Inn2[TYPE_REF]{label.Inn.Inn2, label, Llabel.Inn$Inn2;, null, null, " + (R_DEFAULT + 39) + "}\n" + + "In[TYPE_REF]{In, label, Llabel.In;, null, null, " + (R_DEFAULT + 42) + "}\n" + + "Inn[TYPE_REF]{Inn, label, Llabel.Inn;, null, null, " + (R_DEFAULT + 42) + "}", requestor.getResults()); } @@ -13874,8 +13874,8 @@ public void testBug310423b() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "Inn.Inn2[TYPE_REF]{Inn2, label, Llabel.Inn$Inn2;, null, null, 44}\n" + - "Inn.Inn3[TYPE_REF]{Inn3, label, Llabel.Inn$Inn3;, null, null, 44}", + "Inn.Inn2[TYPE_REF]{Inn2, label, Llabel.Inn$Inn2;, null, null, " + (R_DEFAULT + 39) + "}\n" + + "Inn.Inn3[TYPE_REF]{Inn3, label, Llabel.Inn$Inn3;, null, null, " + (R_DEFAULT + 39) + "}", requestor.getResults()); } @@ -13891,8 +13891,10 @@ public void testBug343865a() throws JavaModelException { cu.codeComplete(cursorLocation, requestor); assertResults( - "name[ANNOTATION_ATTRIBUTE_REF]{name, Ltestxxx.YAAnnot;, Ljava.lang.String;, name, null, " + (R_NAME_FIRST_PREFIX + R_EXPECTED_TYPE + R_RESOLVED) + "}\n" + - "val[ANNOTATION_ATTRIBUTE_REF]{val, Ltestxxx.YAAnnot;, I, val, null, " + (R_NAME_FIRST_PREFIX + R_EXPECTED_TYPE + R_RESOLVED) + "}", + "name[ANNOTATION_ATTRIBUTE_REF]{name, Ltestxxx.YAAnnot;, Ljava.lang.String;, name, null, " + + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + + "val[ANNOTATION_ATTRIBUTE_REF]{val, Ltestxxx.YAAnnot;, I, val, null, " + + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", requestor.getResults()); } @@ -13913,8 +13915,10 @@ public void testBug343865b() throws JavaModelException { requestor.getContext()); assertResults( - "xxyy[FIELD_REF]{xxyy, Ltestxxx.TestType2;, I, xxyy, null, " + (R_NAME_FIRST_PREFIX + R_EXPECTED_TYPE + R_RESOLVED) + "}\n" + - "xxyy1[FIELD_REF]{xxyy1, Ltestxxx.TestType2;, Ljava.lang.String;, xxyy1, null, " + (R_NAME_FIRST_PREFIX + R_EXPECTED_TYPE + R_RESOLVED + R_EXACT_EXPECTED_TYPE) + "}", + "xxyy[FIELD_REF]{xxyy, Ltestxxx.TestType2;, I, xxyy, null, " + + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + + "xxyy1[FIELD_REF]{xxyy1, Ltestxxx.TestType2;, Ljava.lang.String;, xxyy1, null, " + + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}", requestor.getResults()); } public void testBug351426() throws JavaModelException { @@ -13936,7 +13940,7 @@ public void testBug351426() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE; + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED; assertResults( "expectedTypesSignatures={Ltest.X<Ljava.lang.String;>;}\n" + @@ -13965,7 +13969,7 @@ public void testBug351426b() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE; + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED; assertResults( "expectedTypesSignatures={Ltest.X<Ljava.lang.String;>;}\n" + @@ -13996,7 +14000,7 @@ public void testBug351426c() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE; + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED; assertResults( "expectedTypesSignatures={Ltest.X<Ljava.lang.String;>.X1<Ljava.lang.String;>;}\n" + @@ -14029,7 +14033,7 @@ public void testBug351426d() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE; + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED; assertResults( "expectedTypesSignatures={Ltest.X<Ljava.lang.String;>.X1<Ljava.lang.Object;>.X11<Ljava.lang.String;>;}\n" + @@ -14061,7 +14065,7 @@ public void testBug351426e() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE; + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED; assertResults( "expectedTypesSignatures={Ltest.X$X1<Ljava.lang.String;>;}\n" + @@ -14091,7 +14095,7 @@ public void testBug351426f() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE; + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED; assertResults( "expectedTypesSignatures={Ltest.X<Ljava.lang.String;>;}\n" + @@ -14122,7 +14126,7 @@ public void testBug351426g() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE; + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED; assertResults( "expectedTypesSignatures={Ltest.X<TT;>.X1<Ljava.lang.String;>;}\n" + @@ -14153,7 +14157,7 @@ public void testBug351426h() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE; + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED; assertResults( "expectedTypesSignatures={Ltest.X$X1<Ljava.lang.String;>;}\n" + @@ -14181,7 +14185,7 @@ public void testBug351426i() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE; + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED; assertResults( "expectedTypesSignatures={Ltest.X<Ljava.lang.String;>;}\n" + @@ -14213,7 +14217,7 @@ public void testBug351426j() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE; + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED; assertResults( "expectedTypesSignatures={Ltest.X$X1<Ljava.lang.String;>;}\n" + @@ -14243,7 +14247,7 @@ public void testBug351426k() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE; + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED; assertResults( "expectedTypesSignatures={Ltest.X<Ljava.lang.String;Ljava.lang.String;>;}\n" + @@ -14278,7 +14282,7 @@ public void testBug351426l() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE; + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED; assertResults( "expectedTypesSignatures={Ltest.X1<Ljava.lang.String;>;}\n" + @@ -14305,7 +14309,8 @@ public void test361963() throws JavaModelException { int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "X<T>[TYPE_REF]{, , LX<TT;>;, null, null, replace[116, 116], token[116, 116], 51}", + "X<T>[TYPE_REF]{, , LX<TT;>;, null, null, replace[116, 116], token[116, 116], " + + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+ "}", requestor.getResults()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=326610 diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExclusionPatternsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExclusionPatternsTests.java index 41ec92c7a..bfede2da1 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExclusionPatternsTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExclusionPatternsTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -289,12 +289,16 @@ public void testCreateExcludedPackage() throws CoreException { root.getNonJavaResources()); } /* - * Ensure that crearing an excluded package doesn't make it appear as a child of its package fragment root but it is a non-java resource. + * Ensure that creating an excluded package doesn't make it appear as a child of its package fragment root but it is a non-java resource. * (regression test for bug 65637 [model] Excluded package still in Java model) */ public void testCreateExcludedPackage2() throws CoreException { setClasspath(new String[] {"/P/src", "org/*|org/eclipse/*"}); + // Trigger population of cache to check if it is properly invalidated by the delta processor. + // See http://bugs.eclipse.org/500714 + getPackageFragmentRoot("/P/src").getChildren(); + clearDeltas(); createFolder("/P/src/org/eclipse/mypack"); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalAnnotations18Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalAnnotations18Test.java index 680ae6b30..bc2e74417 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalAnnotations18Test.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalAnnotations18Test.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.jdt.core.tests.model; +import java.io.BufferedInputStream; import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -350,6 +351,19 @@ public class ExternalAnnotations18Test extends ModifyingResourceTests { return ((AbstractCompilerTest.getPossibleComplianceLevels() & AbstractCompilerTest.F_1_8) != 0); } + String readFully(IFile file) throws IOException, CoreException { + try (BufferedInputStream bs = new BufferedInputStream(file.getContents())) { + int available = 0; + StringBuilder buf = new StringBuilder(); + while ((available = bs.available()) > 0) { + byte[] contents = new byte[available]; + bs.read(contents); + buf.append(new String(contents)); + } + return buf.toString(); + } + } + /** Perform full build. */ public void test1FullBuild() throws Exception { setupJavaProject("Test1"); @@ -1012,11 +1026,104 @@ public class ExternalAnnotations18Test extends ModifyingResourceTests { MergeStrategy.OVERWRITE_ANNOTATIONS, null); assertTrue("file should exist", annotationFile.exists()); - // check that the error is even worse now: + // check that the error is resolved now: reconciled = cu.reconcile(AST.JLS8, true, null, new NullProgressMonitor()); assertNoProblems(reconciled.getProblems()); } + + public void testAnnotateConstructorParameter() throws Exception { + myCreateJavaProject("TestLibs"); + String lib1Content = + "package libs;\n" + + "\n" + + "public class Lib1<U> {\n" + + " public Lib1(int ignore, U string) {}\n" + + "}\n"; + addLibraryWithExternalAnnotations(this.project, "lib1.jar", "annots", new String[] { + "/UnannotatedLib/libs/Lib1.java", + lib1Content + }, null); + + // type check sources: + IPackageFragment fragment = this.project.getPackageFragmentRoots()[0].createPackageFragment("tests", true, null); + ICompilationUnit cu = fragment.createCompilationUnit("Test1.java", + "package tests;\n" + + "import org.eclipse.jdt.annotation.*;\n" + + "import libs.Lib1;\n" + + "\n" + + "public class Test1 {\n" + + " Object test0() {\n" + + " Lib1<@NonNull String> lib = new Lib1<>(1, null);\n" + + " return lib;\n" + + " }\n" + + "}\n", + true, new NullProgressMonitor()).getWorkingCopy(new NullProgressMonitor()); + CompilationUnit reconciled = cu.reconcile(AST.JLS8, true, null, new NullProgressMonitor()); + assertProblems(reconciled.getProblems(), new String[] { + "Pb(910) Null type mismatch: required '@NonNull String' but the provided value is null", + }, new int[] { 7 }); + + // acquire library AST: + IType type = this.project.findType("libs.Lib1"); + ICompilationUnit libWorkingCopy = type.getClassFile().getWorkingCopy(this.wcOwner, null); + ASTParser parser = ASTParser.newParser(AST.JLS8); + parser.setSource(libWorkingCopy); + parser.setResolveBindings(true); + parser.setStatementsRecovery(false); + parser.setBindingsRecovery(false); + CompilationUnit unit = (CompilationUnit) parser.createAST(null); + libWorkingCopy.discardWorkingCopy(); + + // find type binding: + int start = lib1Content.indexOf("U string"); + ASTNode name = NodeFinder.perform(unit, start, 0); + assertTrue("should be simple name", name.getNodeType() == ASTNode.SIMPLE_NAME); + ASTNode method = name.getParent().getParent().getParent(); + IMethodBinding methodBinding = ((MethodDeclaration)method).resolveBinding(); + + // find annotation file (not yet existing): + IFile annotationFile = ExternalAnnotationUtil.getAnnotationFile(this.project, methodBinding.getDeclaringClass(), null); + assertFalse("file should not exist", annotationFile.exists()); + assertEquals("file path", "/TestLibs/annots/libs/Lib1.eea", annotationFile.getFullPath().toString()); + + // annotate: + String originalSignature = ExternalAnnotationUtil.extractGenericSignature(methodBinding); + ExternalAnnotationUtil.annotateMember("libs/Lib1", annotationFile, + "<init>", + originalSignature, + "(IT0U;)V", // <- @Nullable U + MergeStrategy.OVERWRITE_ANNOTATIONS, null); + assertTrue("file should exist", annotationFile.exists()); + + // check that the error is resolved now: + reconciled = cu.reconcile(AST.JLS8, true, null, new NullProgressMonitor()); + assertNoProblems(reconciled.getProblems()); + + // invert annotation: + ExternalAnnotationUtil.annotateMethodParameterType("libs/Lib1", annotationFile, + "<init>", + originalSignature, + "T1U;", // <- @NonNull U + 1, // position + MergeStrategy.OVERWRITE_ANNOTATIONS, null); + assertTrue("file should exist", annotationFile.exists()); + + // check that the error is back now: + reconciled = cu.reconcile(AST.JLS8, true, null, new NullProgressMonitor()); + assertProblems(reconciled.getProblems(), new String[] { + "Pb(910) Null type mismatch: required '@NonNull String' but the provided value is null", + }, new int[] { 7 }); + + // check that the previous entry has been overwritten: + assertEquals( + "class libs/Lib1\n" + + "<init>\n" + + " (ITU;)V\n" + + " (IT1U;)V\n", + readFully(annotationFile)); + } + // ===== white box tests for ExternalAnnotationUtil ===== public void testBug470666a() throws CoreException, IOException { diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/FreezeMonitor.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/FreezeMonitor.java new file mode 100644 index 000000000..19fd7a728 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/FreezeMonitor.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2016 Google, Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Stefan Xenos (Google) - Initial implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.model; + +import java.lang.management.ManagementFactory; +import java.lang.management.ThreadInfo; +import java.lang.management.ThreadMXBean; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ICoreRunnable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.jobs.Job; + +public class FreezeMonitor { + + private static /* @Nullable */ Job monitorJob; + + public static void expectCompletionIn(final long millis) { + done(); + monitorJob = Job.create("", new ICoreRunnable() { + @Override + public void run(IProgressMonitor monitor) throws CoreException { + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + StringBuilder result = new StringBuilder(); + result.append("Possible frozen test case\n"); + ThreadMXBean threadStuff = ManagementFactory.getThreadMXBean(); + ThreadInfo[] allThreads = threadStuff.getThreadInfo(threadStuff.getAllThreadIds(), 200); + for (ThreadInfo threadInfo : allThreads) { + result.append("\""); + result.append(threadInfo.getThreadName()); + result.append("\": "); + result.append(threadInfo.getThreadState()); + result.append("\n"); + final StackTraceElement[] elements = threadInfo.getStackTrace(); + for (StackTraceElement element : elements) { + result.append(" "); + result.append(element); + result.append("\n"); + } + result.append("\n"); + } + System.out.println(result.toString()); + } + }); + monitorJob.schedule(millis); + } + + public static void done() { + if (monitorJob != null) { + monitorJob.cancel(); + monitorJob = null; + } + } +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java index ef9d23cd3..9ea4398ee 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java @@ -2809,4 +2809,75 @@ public void testBug491354() throws CoreException { deleteProject(project15); } } + +public void testBug501220() throws CoreException { + IJavaProject jdkPrj = null, swtPrj = null, egitPrj = null; + try { + jdkPrj = createJavaProject("JDK8", new String[]{"src"}, new String[] {"JCL_LIB"}, null, null, "bin", new String[]{"bin"}, null, null, "1.8"); + createFolder("/JDK8/src/jdk8"); + createFile("/JDK8/src/jdk8/MyConsumer.java", + "package jdk8;\n" + + "@FunctionalInterface\n" + + "public interface MyConsumer<T> {\n" + + " void accept(T t);\n" + + "}\n"); + + swtPrj = createJavaProject("SWT", new String[]{"src"}, new String[] {"JCL_LIB"}, new String[]{"/JDK8"}, null, "bin", new String[]{"bin"}, null, null, "1.8"); + createFolder("/SWT/src/swt"); + createFile("/SWT/src/swt/EventObject.java", + "package swt;\n" + + "\n" + + "import jdk8.MyConsumer;\n" + + "\n" + + "public class EventObject {\n" + + "}"); + createFile("/SWT/src/swt/SelectionListener.java", + "package swt;\n" + + "\n" + + "import java.util.EventObject;\n" + + "\n" + + "import jdk8.MyConsumer;\n" + + "\n" + + "public interface SelectionListener {\n" + + " void widgetSelected(EventObject event);\n" + + "\n" + + " static SelectionListener widgetSelected(MyConsumer<EventObject> c) {\n" + + " return new SelectionListener() {\n" + + " public void widgetSelected(EventObject e) {\n" + + " c.accept(e);\n" + + " }\n" + + " };\n" + + " }\n" + + "}"); + egitPrj = createJavaProject("EGit", new String[]{"src"}, new String[] {"JCL_LIB"}, new String[]{"/SWT"}, null, "bin", new String[]{"bin"}, null, null, "1.8"); + egitPrj.setOption(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED); + createFolder("/EGit/src/egit"); + createFile("/EGit/src/egit/UIUtils.java", + "package egit; // Error: The type jdk8.MyConsumer cannot be resolved. It is indirectly referenced from required .class files\n" + + "\n" + + "import swt.EventObject;\n" + + "\n" + + "import swt.SelectionListener;\n" + + "\n" + + "public class UIUtils {\n" + + " void foo() {\n" + + " SelectionListener listener = new SelectionListener() {\n" + + " public void widgetSelected(EventObject event) {\n" + + " }\n" + + " };\n" + + " listener.toString();\n" + + " }\n" + + "}\n"); + egitPrj.getProject().getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null); + IMarker[] markers = egitPrj.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE); + assertMarkers("Unexpected markers", "", markers); + } finally { + if (jdkPrj != null) + deleteProject(jdkPrj); + if (swtPrj != null) + deleteProject(swtPrj); + if (egitPrj != null) + deleteProject(egitPrj); + } +} } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocFieldCompletionModelTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocFieldCompletionModelTest.java index 696669ab6..2587d80d6 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocFieldCompletionModelTest.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocFieldCompletionModelTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -513,7 +513,7 @@ public void test030() throws JavaModelException { "}"; completeInJavadoc("/Completion/src/javadoc/fields/tags/BasicTestFields.java", source, true, "oTT"); assertResults( - "oneTwoThree[FIELD_REF]{oneTwoThree, Ljavadoc.fields.tags.BasicTestFields;, Ljava.lang.Object;, oneTwoThree, null, "+this.positions+"30}" + "oneTwoThree[FIELD_REF]{oneTwoThree, Ljavadoc.fields.tags.BasicTestFields;, Ljava.lang.Object;, oneTwoThree, null, "+this.positions+(R_DEFAULT + 25) + "}" ); } finally { JavaCore.setOptions(this.oldOptions); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocMethodCompletionModelTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocMethodCompletionModelTest.java index af02169ac..eeae0e816 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocMethodCompletionModelTest.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocMethodCompletionModelTest.java @@ -1768,8 +1768,8 @@ public void test114() throws JavaModelException { "}\n"; completeInJavadoc("/Completion/src/javadoc/methods/tags/BasicTestMethods.java", source, true, "@param ", 0); // empty token assertSortedResults( - "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, "+this.positions+"19}\n" + - "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, "+this.positions+"18}\n" + + "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, "+this.positions+(R_DEFAULT + 14)+"}\n" + + "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, "+this.positions+(R_DEFAULT + 13)+"}\n" + "TM[JAVADOC_PARAM_REF]{<TM>, null, null, TM, null, "+this.positions+JAVADOC_RELEVANCE+"}" ); } @@ -1834,8 +1834,8 @@ public void test118() throws JavaModelException { "}\n"; completeInJavadoc("/Completion/src/javadoc/methods/tags/BasicTestMethods.java", source, true, "@param ", 0); // empty token assertSortedResults( - "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, [105, 108], 19}\n" + - "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, [105, 108], 18}\n" + + "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, [105, 108], " + (R_DEFAULT + 14) +"}\n" + + "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, [105, 108], " + (R_DEFAULT + 13) +"}\n" + "TM[JAVADOC_PARAM_REF]{<TM>, null, null, TM, null, [105, 108], "+JAVADOC_RELEVANCE+"}" ); } @@ -1883,8 +1883,8 @@ public void test121() throws JavaModelException { "}\n"; completeInJavadoc("/Completion/src/javadoc/methods/tags/BasicTestMethods.java", source, true, "@param ", 0); // empty token assertSortedResults( - "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, "+this.positions+"19}\n" + - "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, "+this.positions+"18}\n" + + "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, "+this.positions+(R_DEFAULT + 14)+"}\n" + + "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, "+this.positions+(R_DEFAULT + 13)+"}\n" + "TM[JAVADOC_PARAM_REF]{<TM>, null, null, TM, null, "+this.positions+JAVADOC_RELEVANCE+"}" ); } @@ -1902,8 +1902,8 @@ public void test122() throws JavaModelException { "}\n"; completeInJavadoc("/Completion/src/javadoc/methods/tags/BasicTestMethods.java", source, true, "@param ", 0); // empty token assertSortedResults( - "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, "+this.positions+"19}\n" + - "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, "+this.positions+"18}\n" + + "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, "+this.positions+(R_DEFAULT + 14)+"}\n" + + "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, "+this.positions+(R_DEFAULT + 13)+"}\n" + "TM[JAVADOC_PARAM_REF]{<TM>, null, null, TM, null, "+this.positions+JAVADOC_RELEVANCE+"}" ); } @@ -1921,8 +1921,8 @@ public void test123() throws JavaModelException { "}\n"; completeInJavadoc("/Completion/src/javadoc/methods/tags/BasicTestMethods.java", source, true, "@param ", 0); // empty token assertSortedResults( - "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, "+this.positions+"19}\n" + - "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, "+this.positions+"18}\n" + + "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, "+this.positions+(R_DEFAULT + 14)+"}\n" + + "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, "+this.positions+(R_DEFAULT + 13)+"}\n" + "TM[JAVADOC_PARAM_REF]{<TM>, null, null, TM, null, "+this.positions+JAVADOC_RELEVANCE+"}" ); } @@ -2536,7 +2536,7 @@ public void test161() throws JavaModelException { "}\n"; completeInJavadoc("/Completion/src/javadoc/methods/tags/BasicTestMethods.java", source, true, "oTT"); assertResults( - "oneTwoThree[METHOD_REF]{oneTwoThree(int), Ljavadoc.methods.tags.BasicTestMethods;, (I)V, oneTwoThree, (i), "+this.positions+"30}" + "oneTwoThree[METHOD_REF]{oneTwoThree(int), Ljavadoc.methods.tags.BasicTestMethods;, (I)V, oneTwoThree, (i), "+this.positions+(R_DEFAULT + 25)+"}" ); } finally { JavaCore.setOptions(this.oldOptions); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocTypeCompletionModelTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocTypeCompletionModelTest.java index a567e074b..1452f4d48 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocTypeCompletionModelTest.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocTypeCompletionModelTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -1036,7 +1036,7 @@ public void test080() throws JavaModelException { " */\n" + "public class BasicTestTypes {}\n"; completeInJavadoc("/Completion/src/javadoc/types/tags/BasicTestTypes.java", source, true, "BTT"); - assertResults("BasicTestTypes[TYPE_REF]{BasicTestTypes, javadoc.types.tags, Ljavadoc.types.tags.BasicTestTypes;, null, null, "+this.positions+"22}"); + assertResults("BasicTestTypes[TYPE_REF]{BasicTestTypes, javadoc.types.tags, Ljavadoc.types.tags.BasicTestTypes;, null, null, "+this.positions+ (R_DEFAULT + 17) +"}"); } finally { JavaCore.setOptions(this.oldOptions); } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java index 4a5036381..3f44c37b2 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java @@ -19,6 +19,7 @@ import org.eclipse.jdt.core.*; import org.eclipse.jdt.core.compiler.batch.BatchCompiler; import org.eclipse.jdt.core.tests.util.Util; import org.eclipse.jdt.internal.core.JavaElement; +import org.eclipse.jdt.internal.core.nd.indexer.Indexer; public class ModifyingResourceTests extends AbstractJavaModelTests { @@ -102,6 +103,7 @@ protected IFile createFile(String path, InputStream content) throws CoreExceptio } catch (IOException e) { e.printStackTrace(); } + Indexer.getInstance().waitForIndex(null); return file; } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NameLookupTests2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NameLookupTests2.java index a529c7761..1dd935489 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NameLookupTests2.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NameLookupTests2.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,9 +14,6 @@ package org.eclipse.jdt.core.tests.model; import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Files; -import java.nio.file.StandardCopyOption; -import java.nio.file.attribute.FileTime; -import java.util.Arrays; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.runtime.CoreException; @@ -361,15 +358,7 @@ public void testFindTypeWithUnrelatedWorkingCopy() throws Exception { * JavaProjectElementInfo cache without restarting Eclipse or closing and reopening the project. */ public void testTransitionFromInvalidToValidJar() throws CoreException, IOException { - /* - * Since it is difficult to test intermittent IO errors, simulate it - * by creating two jars of equal size, one of which has an invalid format. - * Set up the classpath with the invalid jar, and then swap in the valid jar - * and reset its timestamp to be the same as the original file. - */ - String goodJar = getExternalPath() + "goodJar.jar"; String transitioningJar = getExternalPath() + "transitioningJar.jar"; - java.nio.file.Path goodJarPath = FileSystems.getDefault().getPath(goodJar); java.nio.file.Path transitioningJarPath = FileSystems.getDefault().getPath(transitioningJar); IPath transitioningIPath = Path.fromOSString(transitioningJar); @@ -385,33 +374,29 @@ public void testTransitionFromInvalidToValidJar() throws CoreException, IOExcept "META-INF/MANIFEST.MF", "Manifest-Version: 1.0\n" }, - goodJar, + transitioningJar, JavaCore.VERSION_1_4); - char[] invalidContents = new char[(int) goodJarPath.toFile().length()]; - Arrays.fill(invalidContents, ' '); - Util.createFile(transitioningJar, String.copyValueOf(invalidContents)); // Set up the project with the invalid jar and allow all of the classpath validation // and delta processing to complete. + JavaModelManager.throwIoExceptionsInGetZipFile = true; JavaProject proj = (JavaProject) createJavaProject("P", new String[] {}, new String[] {transitioningJar}, "bin"); JavaModelManager.getJavaModelManager().getJavaModel().refreshExternalArchives(null, null); waitForAutoBuild(); assertTrue("The invalid archive cache should report that the jar is invalid", - JavaModelManager.getJavaModelManager().isInvalidArchive(transitioningIPath)); + !JavaModelManager.getJavaModelManager().getArchiveValidity(transitioningIPath).isValid()); IType type = getNameLookup(proj).findType("test1.IResource", false, NameLookup.ACCEPT_CLASSES); assertEquals("Name lookup should fail when the jar is invalid", null, type); - // Substitute the good jar, maintaining the timestamp. - FileTime fileTime = Files.getLastModifiedTime(transitioningJarPath); - Files.move(goodJarPath, transitioningJarPath, StandardCopyOption.REPLACE_EXISTING); - Files.setLastModifiedTime(transitioningJarPath, fileTime); + // Cause IO exceptions to be thrown on all file operations + JavaModelManager.throwIoExceptionsInGetZipFile = false; // Since the timestamp hasn't changed, an external archive refresh isn't going // to update the caches or cause name lookups to work. JavaModelManager.getJavaModelManager().getJavaModel().refreshExternalArchives(null, null); assertTrue("External archive refresh sees no changes, so the invalid archive cache should be unchanged", - JavaModelManager.getJavaModelManager().isInvalidArchive(transitioningIPath)); + !JavaModelManager.getJavaModelManager().getArchiveValidity(transitioningIPath).isValid()); type = getNameLookup(proj).findType("test1.IResource", false, NameLookup.ACCEPT_CLASSES); assertEquals("External archive refresh sees no changes, so the project cache should be unchanged", null, type); @@ -423,11 +408,10 @@ public void testTransitionFromInvalidToValidJar() throws CoreException, IOExcept ClasspathEntry.validateClasspathEntry(proj, transitioningEntry, false, false); assertFalse("The invalid archive cache should no longer report the jar as invalid", - JavaModelManager.getJavaModelManager().isInvalidArchive(transitioningIPath)); + !JavaModelManager.getJavaModelManager().getArchiveValidity(transitioningIPath).isValid()); type = getNameLookup(proj).findType("test1.IResource", false, NameLookup.ACCEPT_CLASSES); assertFalse("Name lookup should be able to find types in the valid jar", type == null); } finally { - Files.deleteIfExists(goodJarPath); Files.deleteIfExists(transitioningJarPath); deleteProject("P"); } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SubstringCompletionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SubstringCompletionTests.java index 81e976d43..4fea3b391 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SubstringCompletionTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SubstringCompletionTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 Gábor Kövesdán and others. + * Copyright (c) 2015, 2016 Gábor Kövesdán and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,59 +17,20 @@ import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import junit.framework.Test; -import junit.framework.TestSuite; public class SubstringCompletionTests extends AbstractJavaModelCompletionTests { public static Test suite() { - if (TESTS_PREFIX != null || TESTS_NAMES != null || TESTS_NUMBERS != null || TESTS_RANGE != null) { - return buildModelTestSuite(SubstringCompletionTests.class); - } - TestSuite suite = new Suite(SubstringCompletionTests.class.getName()); - suite.addTest(new SubstringCompletionTests("testQualifiedNonStaticMethod")); - suite.addTest(new SubstringCompletionTests("testQualifiedStaticMethod")); - suite.addTest(new SubstringCompletionTests("testUnqualifiedNonStaticMethod")); - suite.addTest(new SubstringCompletionTests("testUnqualifiedStaticMethod")); - suite.addTest(new SubstringCompletionTests("testQualifiedNonStaticField")); - suite.addTest(new SubstringCompletionTests("testQualifiedStaticField")); - suite.addTest(new SubstringCompletionTests("testUnqualifiedNonStaticField")); - suite.addTest(new SubstringCompletionTests("testUnqualifiedStaticField")); - suite.addTest(new SubstringCompletionTests("testLocalVariable")); - suite.addTest(new SubstringCompletionTests("testMethodParamVariable")); - suite.addTest(new SubstringCompletionTests("testClassTypeInstantiation")); - suite.addTest(new SubstringCompletionTests("testClassTypeFieldDeclaration")); - suite.addTest(new SubstringCompletionTests("testClassTypeParamDeclaration")); - suite.addTest(new SubstringCompletionTests("testClassTypeLocalVarDeclaration")); - suite.addTest(new SubstringCompletionTests("testClassTypeThrowsDeclaration")); - suite.addTest(new SubstringCompletionTests("testClassTypeExtends")); - suite.addTest(new SubstringCompletionTests("testClassTypeImplements")); - suite.addTest(new SubstringCompletionTests("testInnerClassTypeInstantiation")); - suite.addTest(new SubstringCompletionTests("testInnerClassTypeFieldDeclaration")); - suite.addTest(new SubstringCompletionTests("testInnerClassTypeParamDeclaration")); - suite.addTest(new SubstringCompletionTests("testInnerClassTypeLocalVarDeclaration")); - suite.addTest(new SubstringCompletionTests("testInnerClassTypeThrowsDeclaration")); - suite.addTest(new SubstringCompletionTests("testInnerClassTypeExtends")); - suite.addTest(new SubstringCompletionTests("testInnerClassTypeImplements")); - suite.addTest(new SubstringCompletionTests("testStaticNestedClassTypeInstantiation")); - suite.addTest(new SubstringCompletionTests("testStaticNestedClassTypeFieldDeclaration")); - suite.addTest(new SubstringCompletionTests("testStaticNestedClassTypeParamDeclaration")); - suite.addTest(new SubstringCompletionTests("testStaticNestedClassTypeLocalVarDeclaration")); - suite.addTest(new SubstringCompletionTests("testStaticNestedClassTypeThrowsDeclaration")); - suite.addTest(new SubstringCompletionTests("testStaticNestedClassTypeExtends")); - suite.addTest(new SubstringCompletionTests("testStaticNestedClassTypeImplements")); - suite.addTest(new SubstringCompletionTests("testLocalClassTypeInstantiation")); - suite.addTest(new SubstringCompletionTests("testLocalClassTypeLocalVarDeclaration")); - suite.addTest(new SubstringCompletionTests("testLocalClassTypeExtends")); - return suite; + return buildModelTestSuite(SubstringCompletionTests.class, BYTECODE_DECLARATION_ORDER); } public SubstringCompletionTests(String name) { super(name); } public void setUpSuite() throws Exception { if (COMPLETION_PROJECT == null) { - COMPLETION_PROJECT = setUpJavaProject("Completion"); + COMPLETION_PROJECT = setUpJavaProject("Completion", "1.8", true); } else { - setUpProjectCompliance(COMPLETION_PROJECT, "1.8"); + setUpProjectCompliance(COMPLETION_PROJECT, "1.8", true); } super.setUpSuite(); Hashtable<String, String> options = new Hashtable<>(this.oldOptions); @@ -202,24 +163,24 @@ public void testQualifiedNonStaticField() throws JavaModelException { "/Completion/src/test/Test.java", "package test;"+ "public class Test {\n" + - " int element;\n" + - " int otherElement;\n" + - " long elementCount;\n" + + " int items;\n" + + " int otherItems;\n" + + " long itemsCount;\n" + " void foo() {\n" + - " this.elem\n" + + " this.item\n" + " }\n" + "}\n"); CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); String str = this.workingCopies[0].getSource(); - String completeBehind = "this.elem"; + String completeBehind = "this.item"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "otherElement[FIELD_REF]{otherElement, Ltest.Test;, I, otherElement, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_STATIC + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" + - "element[FIELD_REF]{element, Ltest.Test;, I, element, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}\n" + - "elementCount[FIELD_REF]{elementCount, Ltest.Test;, J, elementCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}", + "otherItems[FIELD_REF]{otherItems, Ltest.Test;, I, otherItems, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_STATIC + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" + + "items[FIELD_REF]{items, Ltest.Test;, I, items, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}\n" + + "itemsCount[FIELD_REF]{itemsCount, Ltest.Test;, J, itemsCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}", requestor.getResults()); } @@ -229,25 +190,24 @@ public void testUnqualifiedNonStaticField() throws JavaModelException { "/Completion/src/test/Test.java", "package test;"+ "public class Test {\n" + - " int element;\n" + - " int otherElement;\n" + - " long elementCount;\n" + + " int items;\n" + + " int otherItems;\n" + + " long itemsCount;\n" + " void foo() {\n" + - " elem\n" + + " item\n" + " }\n" + "}\n"); CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); String str = this.workingCopies[0].getSource(); - String completeBehind = "elem"; + String completeBehind = "item"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "ElementType[TYPE_REF]{java.lang.annotation.ElementType, java.lang.annotation, Ljava.lang.annotation.ElementType;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" + - "otherElement[FIELD_REF]{otherElement, Ltest.Test;, I, otherElement, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" + - "element[FIELD_REF]{element, Ltest.Test;, I, element, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + - "elementCount[FIELD_REF]{elementCount, Ltest.Test;, J, elementCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", + "otherItems[FIELD_REF]{otherItems, Ltest.Test;, I, otherItems, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" + + "items[FIELD_REF]{items, Ltest.Test;, I, items, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + + "itemsCount[FIELD_REF]{itemsCount, Ltest.Test;, J, itemsCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", requestor.getResults()); } public void testQualifiedStaticField() throws JavaModelException { @@ -256,23 +216,23 @@ public void testQualifiedStaticField() throws JavaModelException { "/Completion/src/test/Test.java", "package test;"+ "public class Test {\n" + - " static int element;\n" + - " int otherElement;\n" + - " static long elementCount;\n" + + " static int items;\n" + + " int otherItems;\n" + + " static long itemsCount;\n" + " void foo() {\n" + - " Test.elem\n" + + " Test.item\n" + " }\n" + "}\n"); CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); String str = this.workingCopies[0].getSource(); - String completeBehind = "Test.elem"; + String completeBehind = "Test.item"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "element[FIELD_REF]{element, Ltest.Test;, I, element, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_NON_INHERITED) + "}\n" + - "elementCount[FIELD_REF]{elementCount, Ltest.Test;, J, elementCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_NON_INHERITED) + "}", + "items[FIELD_REF]{items, Ltest.Test;, I, items, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_NON_INHERITED) + "}\n" + + "itemsCount[FIELD_REF]{itemsCount, Ltest.Test;, J, itemsCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_NON_INHERITED) + "}", requestor.getResults()); } public void testUnqualifiedStaticField() throws JavaModelException { @@ -281,25 +241,24 @@ public void testUnqualifiedStaticField() throws JavaModelException { "/Completion/src/test/Test.java", "package test;"+ "public class Test {\n" + - " static int element;\n" + - " int otherElement;\n" + - " static long elementCount;\n" + + " static int items;\n" + + " int otherItems;\n" + + " static long itemsCount;\n" + " void foo() {\n" + - " elem\n" + + " item\n" + " }\n" + "}\n"); CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); String str = this.workingCopies[0].getSource(); - String completeBehind = "elem"; + String completeBehind = "item"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "ElementType[TYPE_REF]{java.lang.annotation.ElementType, java.lang.annotation, Ljava.lang.annotation.ElementType;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" + - "otherElement[FIELD_REF]{otherElement, Ltest.Test;, I, otherElement, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" + - "element[FIELD_REF]{element, Ltest.Test;, I, element, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + - "elementCount[FIELD_REF]{elementCount, Ltest.Test;, J, elementCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", + "otherItems[FIELD_REF]{otherItems, Ltest.Test;, I, otherItems, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" + + "items[FIELD_REF]{items, Ltest.Test;, I, items, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + + "itemsCount[FIELD_REF]{itemsCount, Ltest.Test;, J, itemsCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", requestor.getResults()); } public void testLocalVariable() throws JavaModelException { @@ -308,27 +267,26 @@ public void testLocalVariable() throws JavaModelException { "/Completion/src/test/Test.java", "package test;"+ "public class Test {\n" + - " static int element;\n" + - " int otherElement;\n" + - " static long elementCount;\n" + + " static int items;\n" + + " int otherItems;\n" + + " static long itemsCount;\n" + " void foo() {\n" + - " int temporaryElement = 0;\n" + - " elem\n" + + " int temporaryItem = 0;\n" + + " item\n" + " }\n" + "}\n"); CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); String str = this.workingCopies[0].getSource(); - String completeBehind = "elem"; + String completeBehind = "item"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "ElementType[TYPE_REF]{java.lang.annotation.ElementType, java.lang.annotation, Ljava.lang.annotation.ElementType;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" + - "otherElement[FIELD_REF]{otherElement, Ltest.Test;, I, otherElement, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" + - "temporaryElement[LOCAL_VARIABLE_REF]{temporaryElement, null, I, temporaryElement, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" + - "element[FIELD_REF]{element, Ltest.Test;, I, element, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + - "elementCount[FIELD_REF]{elementCount, Ltest.Test;, J, elementCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", + "otherItems[FIELD_REF]{otherItems, Ltest.Test;, I, otherItems, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" + + "temporaryItem[LOCAL_VARIABLE_REF]{temporaryItem, null, I, temporaryItem, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" + + "items[FIELD_REF]{items, Ltest.Test;, I, items, null, " + (R_DEFAULT + R_RESOLVED + R_CASE + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + + "itemsCount[FIELD_REF]{itemsCount, Ltest.Test;, J, itemsCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", requestor.getResults()); } public void testMethodParamVariable() throws JavaModelException { @@ -337,26 +295,25 @@ public void testMethodParamVariable() throws JavaModelException { "/Completion/src/test/Test.java", "package test;"+ "public class Test {\n" + - " static int element;\n" + - " int otherElement;\n" + - " static long elementCount;\n" + - " void foo(int initElement) {\n" + - " elem\n" + + " static int items;\n" + + " int otherItems;\n" + + " static long itemsCount;\n" + + " void foo(int initItems) {\n" + + " item\n" + " }\n" + "}\n"); CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); String str = this.workingCopies[0].getSource(); - String completeBehind = "elem"; + String completeBehind = "item"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "ElementType[TYPE_REF]{java.lang.annotation.ElementType, java.lang.annotation, Ljava.lang.annotation.ElementType;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" + - "initElement[LOCAL_VARIABLE_REF]{initElement, null, I, initElement, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" + - "otherElement[FIELD_REF]{otherElement, Ltest.Test;, I, otherElement, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" + - "element[FIELD_REF]{element, Ltest.Test;, I, element, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + - "elementCount[FIELD_REF]{elementCount, Ltest.Test;, J, elementCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", + "initItems[LOCAL_VARIABLE_REF]{initItems, null, I, initItems, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" + + "otherItems[FIELD_REF]{otherItems, Ltest.Test;, I, otherItems, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" + + "items[FIELD_REF]{items, Ltest.Test;, I, items, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + + "itemsCount[FIELD_REF]{itemsCount, Ltest.Test;, J, itemsCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", requestor.getResults()); } public void testClassTypeInstantiation() throws JavaModelException { @@ -899,4 +856,257 @@ public void testLocalClassTypeExtends() throws JavaModelException { "FooBar[TYPE_REF]{FooBar, test, LFooBar;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE + R_NON_RESTRICTED + R_UNQUALIFIED + R_SUBSTRING) + "}", requestor.getResults()); } -}
\ No newline at end of file +public void testBug488441_1() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + String content = "public class Try18 {\n" + + " public void main(String[] args) {\n" + + " \"s\".st\n" + + " }\n" + + "}\n" + + "}\n"; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + content); + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = ".st"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_STATIC + R_NON_RESTRICTED; + assertResults( + "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (I)I, lastIndexOf, (arg0), "+ (relevance + R_SUBSTRING) +"}\n" + + "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (II)I, lastIndexOf, (arg0, arg1), "+ (relevance + R_SUBSTRING) +"}\n" + + "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (Ljava.lang.String;)I, lastIndexOf, (arg0), "+ (relevance + R_SUBSTRING) +"}\n" + + "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (Ljava.lang.String;I)I, lastIndexOf, (arg0, arg1), "+ (relevance + R_SUBSTRING) +"}\n" + + "replaceFirst[METHOD_REF]{replaceFirst(), Ljava.lang.String;, (Ljava.lang.String;Ljava.lang.String;)Ljava.lang.String;, replaceFirst, (arg0, arg1), "+ (relevance + R_SUBSTRING) +"}\n" + + "substring[METHOD_REF]{substring(), Ljava.lang.String;, (I)Ljava.lang.String;, substring, (arg0), "+ (relevance + R_SUBSTRING) +"}\n" + + "substring[METHOD_REF]{substring(), Ljava.lang.String;, (II)Ljava.lang.String;, substring, (arg0, arg1), "+ (relevance + R_SUBSTRING) +"}\n" + + "toString[METHOD_REF]{toString(), Ljava.lang.String;, ()Ljava.lang.String;, toString, null, "+ (relevance + R_SUBSTRING) +"}\n" + + "startsWith[METHOD_REF]{startsWith(), Ljava.lang.String;, (Ljava.lang.String;)Z, startsWith, (arg0), "+ (relevance + R_CASE) +"}\n" + + "startsWith[METHOD_REF]{startsWith(), Ljava.lang.String;, (Ljava.lang.String;I)Z, startsWith, (arg0, arg1), "+ (relevance + R_CASE) +"}", + requestor.getResults()); +} +public void testBug488441_2() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + String content = "public class Try18 {\n" + + " public void main(String[] args) {\n" + + " int i = \"s\".st\n" + + " }\n" + + "}\n"; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + content); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = ".st"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_STATIC + R_NON_RESTRICTED; + assertResults( + "replaceFirst[METHOD_REF]{replaceFirst(), Ljava.lang.String;, (Ljava.lang.String;Ljava.lang.String;)Ljava.lang.String;, replaceFirst, (arg0, arg1), "+ (relevance + R_SUBSTRING) +"}\n" + + "substring[METHOD_REF]{substring(), Ljava.lang.String;, (I)Ljava.lang.String;, substring, (arg0), "+ (relevance + R_SUBSTRING) +"}\n" + + "substring[METHOD_REF]{substring(), Ljava.lang.String;, (II)Ljava.lang.String;, substring, (arg0, arg1), "+ (relevance + R_SUBSTRING) +"}\n" + + "toString[METHOD_REF]{toString(), Ljava.lang.String;, ()Ljava.lang.String;, toString, null, "+ (relevance + R_SUBSTRING) +"}\n" + + "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (I)I, lastIndexOf, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (II)I, lastIndexOf, (arg0, arg1), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (Ljava.lang.String;)I, lastIndexOf, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (Ljava.lang.String;I)I, lastIndexOf, (arg0, arg1), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "startsWith[METHOD_REF]{startsWith(), Ljava.lang.String;, (Ljava.lang.String;)Z, startsWith, (arg0), "+ (relevance + R_CASE) +"}\n" + + "startsWith[METHOD_REF]{startsWith(), Ljava.lang.String;, (Ljava.lang.String;I)Z, startsWith, (arg0, arg1), "+ (relevance + R_CASE) +"}", + requestor.getResults()); +} +public void testBug488441_3() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + String content = "public class Try18 {\n" + + " public void main(String[] args) {\n" + + " String s = \"s\".st\n" + + " }\n" + + "}\n"; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + content); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = ".st"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_STATIC + R_NON_RESTRICTED; + assertResults( + "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (I)I, lastIndexOf, (arg0), "+ (relevance + R_SUBSTRING) +"}\n" + + "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (II)I, lastIndexOf, (arg0, arg1), "+ (relevance + R_SUBSTRING) +"}\n" + + "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (Ljava.lang.String;)I, lastIndexOf, (arg0), "+ (relevance + R_SUBSTRING) +"}\n" + + "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (Ljava.lang.String;I)I, lastIndexOf, (arg0, arg1), "+ (relevance + R_SUBSTRING) +"}\n" + + "replaceFirst[METHOD_REF]{replaceFirst(), Ljava.lang.String;, (Ljava.lang.String;Ljava.lang.String;)Ljava.lang.String;, replaceFirst, (arg0, arg1), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "startsWith[METHOD_REF]{startsWith(), Ljava.lang.String;, (Ljava.lang.String;)Z, startsWith, (arg0), "+ (relevance + R_CASE) +"}\n" + + "startsWith[METHOD_REF]{startsWith(), Ljava.lang.String;, (Ljava.lang.String;I)Z, startsWith, (arg0, arg1), "+ (relevance + R_CASE) +"}\n" + + "substring[METHOD_REF]{substring(), Ljava.lang.String;, (I)Ljava.lang.String;, substring, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "substring[METHOD_REF]{substring(), Ljava.lang.String;, (II)Ljava.lang.String;, substring, (arg0, arg1), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "toString[METHOD_REF]{toString(), Ljava.lang.String;, ()Ljava.lang.String;, toString, null, "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}", + requestor.getResults()); +} +public void testBug488441_4() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + String content = "public class Try18 {\n" + + " public void main(String[] args) {\n" + + " boolean s = \"s\".st\n" + + " }\n" + + "}\n"; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + content); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = ".st"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_STATIC + R_NON_RESTRICTED; + assertResults( + "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (I)I, lastIndexOf, (arg0), " + (relevance + R_SUBSTRING) + "}\n" + + "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (II)I, lastIndexOf, (arg0, arg1), " + (relevance + R_SUBSTRING) + "}\n" + + "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (Ljava.lang.String;)I, lastIndexOf, (arg0), " + (relevance + R_SUBSTRING) + "}\n" + + "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (Ljava.lang.String;I)I, lastIndexOf, (arg0, arg1), " + (relevance + R_SUBSTRING) + "}\n" + + "replaceFirst[METHOD_REF]{replaceFirst(), Ljava.lang.String;, (Ljava.lang.String;Ljava.lang.String;)Ljava.lang.String;, replaceFirst, (arg0, arg1), " + (relevance + R_SUBSTRING) + "}\n" + + "substring[METHOD_REF]{substring(), Ljava.lang.String;, (I)Ljava.lang.String;, substring, (arg0), " + (relevance + R_SUBSTRING) + "}\n" + + "substring[METHOD_REF]{substring(), Ljava.lang.String;, (II)Ljava.lang.String;, substring, (arg0, arg1), " + (relevance + R_SUBSTRING) + "}\n" + + "toString[METHOD_REF]{toString(), Ljava.lang.String;, ()Ljava.lang.String;, toString, null, " + (relevance + R_SUBSTRING) + "}\n" + + "startsWith[METHOD_REF]{startsWith(), Ljava.lang.String;, (Ljava.lang.String;)Z, startsWith, (arg0), " + (relevance + R_EXACT_EXPECTED_TYPE + R_CASE) + "}\n" + + "startsWith[METHOD_REF]{startsWith(), Ljava.lang.String;, (Ljava.lang.String;I)Z, startsWith, (arg0, arg1), " + (relevance + R_EXACT_EXPECTED_TYPE + R_CASE) + "}", + requestor.getResults()); +} +public void testBug488441_5() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "import java.util.Arrays;\n" + + "public class Try18 {\n" + + " public void main(String[] args) {\n" + + " String msg=\"\";\n" + + " String[] parameters = {\"a\"};\n" + + " System.out.println(msg + Arrays.as);\n" + + " }\n" + + "}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = ".as"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED + R_NON_INHERITED; + assertResults( + "asList[METHOD_REF]{asList(), Ljava.util.Arrays;, <T:Ljava.lang.Object;>([TT;)Ljava.util.List<TT;>;, asList, (arg0), "+ (relevance + R_CASE) +"}\n" + + "deepHashCode[METHOD_REF]{deepHashCode(), Ljava.util.Arrays;, ([Ljava.lang.Object;)I, deepHashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([B)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([C)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([D)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([F)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([I)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([J)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([Ljava.lang.Object;)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([S)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([Z)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}", + requestor.getResults()); +} +public void testBug488441_6() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "import java.util.Arrays;\n" + + "public class Try18 {\n" + + " public void main(String[] args) {\n" + + " String msg=\"\";\n" + + " String[] parameters = {\"a\"};\n" + + " System.out.println(msg + Arrays.aS);\n" + + " }\n" + + "}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = ".aS"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED + R_NON_INHERITED; + assertResults( + "asList[METHOD_REF]{asList(), Ljava.util.Arrays;, <T:Ljava.lang.Object;>([TT;)Ljava.util.List<TT;>;, asList, (arg0), "+ (relevance) +"}\n" + + "deepHashCode[METHOD_REF]{deepHashCode(), Ljava.util.Arrays;, ([Ljava.lang.Object;)I, deepHashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([B)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([C)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([D)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([F)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([I)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([J)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([Ljava.lang.Object;)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([S)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([Z)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}", + requestor.getResults()); +} +public void testBug488441_7() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "import java.util.Arrays;\n" + + "public class Try18 {\n" + + " public void main(String[] args) {\n" + + " String msg=\"\";\n" + + " String[] parameters = {\"a\"};\n" + + " System.out.println(Arrays.as);\n" + + " }\n" + + "}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = ".as"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED + R_NON_INHERITED; + assertResults( + "deepHashCode[METHOD_REF]{deepHashCode(), Ljava.util.Arrays;, ([Ljava.lang.Object;)I, deepHashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([B)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([C)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([D)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([F)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([I)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([J)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([Ljava.lang.Object;)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([S)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([Z)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "asList[METHOD_REF]{asList(), Ljava.util.Arrays;, <T:Ljava.lang.Object;>([TT;)Ljava.util.List<TT;>;, asList, (arg0), "+ (relevance + R_EXPECTED_TYPE + R_CASE) +"}", + requestor.getResults()); +} +public void testBug488441_8() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "import java.util.Arrays;\n" + + "public class Try18 {\n" + + " public void main(String[] args) {\n" + + " String msg=\"\";\n" + + " String[] parameters = {\"a\"};\n" + + " int i = Arrays.as;\n" + + " }\n" + + "}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = ".as"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED + R_NON_INHERITED; + assertResults( + "asList[METHOD_REF]{asList(), Ljava.util.Arrays;, <T:Ljava.lang.Object;>([TT;)Ljava.util.List<TT;>;, asList, (arg0), "+ (relevance + R_CASE) +"}\n" + + "deepHashCode[METHOD_REF]{deepHashCode(), Ljava.util.Arrays;, ([Ljava.lang.Object;)I, deepHashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([B)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([C)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([D)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([F)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([I)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([J)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([Ljava.lang.Object;)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([S)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" + + "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([Z)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}", + requestor.getResults()); +} +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SuiteOfTestCases.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SuiteOfTestCases.java index 3917b757f..94385decf 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SuiteOfTestCases.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SuiteOfTestCases.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,7 @@ import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.Set; +import org.eclipse.jdt.internal.core.nd.indexer.Indexer; import org.eclipse.test.internal.performance.PerformanceMeterFactory; import junit.extensions.TestSetup; @@ -29,6 +30,12 @@ import junit.framework.TestSuite; @SuppressWarnings("rawtypes") public class SuiteOfTestCases extends org.eclipse.jdt.core.tests.junit.extension.TestCase { + /** + * Number of milliseconds that a test case can run for before we consider it to be potentially + * deadlocked and dump out a stack trace. Currently set to 5 minutes. + */ + private static final long FROZEN_TEST_TIMEOUT_MS = 1000 * 60 * 5; + /* * A test suite that initialize the test case's fields once, then that copies the values * of these fields into each subsequent test case. @@ -118,12 +125,27 @@ public class SuiteOfTestCases extends org.eclipse.jdt.core.tests.junit.extension * Setup the test suite once before all test cases run. */ public void setUpSuite() throws Exception { + Indexer.getInstance().enableAutomaticIndexing(false); + //Indexer.getInstance().waitForIndex(null); } /** * Tear down the test suite once after all test cases have run. */ public void tearDownSuite() throws Exception { + Indexer.getInstance().enableAutomaticIndexing(true); + } + + @Override + protected void setUp() throws Exception { + FreezeMonitor.expectCompletionIn(FROZEN_TEST_TIMEOUT_MS); + super.setUp(); + } + + @Override + protected void tearDown() throws Exception { + FreezeMonitor.done(); + super.tearDown(); } /** diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/BTreeExpensiveTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/BTreeExpensiveTests.java new file mode 100644 index 000000000..155726008 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/BTreeExpensiveTests.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2007, 2016 Symbian Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Symbian - Initial implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.nd; + +import junit.framework.Test; + +/** + * Tests which are too expensive to run as part of normal testing, but + * should be run after B-tree related development. + * <p> + * The 'Full Checking' tests perform a full validation of the B-tree + * invariants after each B-tree operation, and so are especially + * expensive and cpu hungry. + */ +public class BTreeExpensiveTests extends BTreeTests { + + public static Test suite() { + return suite(BTreeExpensiveTests.class); + } + + public void testBySortedSetMirror() throws Exception { + sortedMirrorTest(100); + } + + // @Override + @Override + public void testInsertion() throws Exception { + super.testInsertion(); + } + + /* + * N.B. Each of the following tests are quite expensive (i.e. > 10mins each on a 2Ghz machine) + */ + + public void testBySortedSetMirror1682762087() throws Exception { + System.out.println("1682762087 Full Checking"); + trial(1682762087, true); // exposed bugs in 2a,b + } + + public void testBySortedSetMirror322922974() throws Exception { + System.out.println("322922974 Full Checking"); + trial(322922974, true); // exposed bugs in 3b(ii) + } + + public void testBySortedSetMirror_588448152() throws Exception { + System.out.println("-588448152 Full Checking"); + trial(-588448152, true); // exposed root-delete-on-merge problems + } +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/BTreeTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/BTreeTests.java new file mode 100644 index 000000000..42711e2cc --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/BTreeTests.java @@ -0,0 +1,264 @@ +/******************************************************************************* + * Copyright (c) 2006, 2016 Symbian Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Symbian - Initial implementation + * Markus Schorn (Wind River Systems) + *******************************************************************************/ +package org.eclipse.jdt.core.tests.nd; + +import junit.framework.Test; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jdt.core.tests.nd.util.BaseTestCase; +import org.eclipse.jdt.internal.core.nd.Nd; +import org.eclipse.jdt.internal.core.nd.db.BTree; +import org.eclipse.jdt.internal.core.nd.db.Database; +import org.eclipse.jdt.internal.core.nd.db.IBTreeComparator; +import org.eclipse.jdt.internal.core.nd.db.IBTreeVisitor; + +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.SortedSet; +import java.util.TreeSet; + +/** + * Test insertion/deletion of records of a mock record type in a B-tree. + * + * @author aferguso + */ +public class BTreeTests extends BaseTestCase { + private static int DEBUG= 0; + protected File dbFile; + protected Nd nd; + protected Database db; + protected BTree btree; + protected int rootRecord; + protected IBTreeComparator comparator; + + public static Test suite() { + return suite(BTreeTests.class); + } + + // setUp is not used since we need to parameterize this method, + // and invoke it multiple times per Junit test + protected void init(int degree) throws Exception { + this.dbFile = File.createTempFile("ndtest", "db"); + this.nd = DatabaseTestUtil.createEmptyNd(getName()); + this.db = this.nd.getDB(); + this.db.setExclusiveLock(); + this.rootRecord = Database.DATA_AREA_OFFSET; + this.comparator = new BTMockRecordComparator(); + this.btree = new BTree(this.nd, this.rootRecord, degree, this.comparator); + } + + // tearDown is not used for the same reason as above + protected void finish() throws Exception { + this.db.close(); + this.dbFile.deleteOnExit(); + } + + + public void testBySortedSetMirrorLite() throws Exception { + sortedMirrorTest(8); + } + + /** + * Test random (but reproducible via known seed) sequences of insertions/deletions + * and use TreeSet as a reference implementation to check behaviour against. + * @throws Exception + */ + protected void sortedMirrorTest(int noTrials) throws Exception { + Random seeder = new Random(90210); + + for (int i = 0; i < noTrials; i++) { + int seed = seeder.nextInt(); + if (DEBUG > 0) + System.out.println("Iteration #" + i); + trial(seed, false); + } + } + + /** + * Test random (but reproducible via known seed) sequence of insertions + * and use TreeSet as a reference implementation to check behaviour against. + * @throws Exception + */ + public void testInsertion() throws Exception { + Random seeder = new Random(); + + for (int i = 0; i < 6; i++) { + int seed = seeder.nextInt(); + if (DEBUG > 0) + System.out.println("Iteration #" + i); + trialImp(seed, false, new Random(seed * 2), 1); + } + } + + /** + * Bug 402177: BTree.insert should return the matching record if the new record was not inserted. + */ + public void testEquivalentRecordInsert_Bug402177() throws Exception { + init(8); + try { + BTMockRecord value1 = new BTMockRecord(this.db, 42); + BTMockRecord value2 = new BTMockRecord(this.db, 42); + + long insert1 = this.btree.insert(value1.getRecord()); + long insert2 = this.btree.insert(value2.getRecord()); + assertEquals(insert1, insert2); + } finally { + finish(); + } + } + + /** + * Insert/Delete a random number of records into/from the B-tree + * @param seed the seed for obtaining the deterministic random testing + * @param checkCorrectnessEachIteration if true, then on every single insertion/deletion check that the B-tree invariants + * still hold + * @throws Exception + */ + protected void trial(int seed, final boolean checkCorrectnessEachIteration) throws Exception { + Random random = new Random(seed); + + // the probabilty that a particular iterations action will be an insertion + double pInsert = Math.min(0.5 + random.nextDouble(), 1); + + trialImp(seed, checkCorrectnessEachIteration, random, pInsert); + } + + private void trialImp(int seed, final boolean checkCorrectnessEachIteration, Random random, + double pInsert) throws Exception { + final int degree = 2 + random.nextInt(11); + final int nIterations = random.nextInt(100000); + final SortedSet<Integer> expected = new TreeSet<>(); + final List<BTMockRecord> history = new ArrayList<>(); + + init(degree); + + if (DEBUG > 0) + System.out.print("\t " + seed + " " + (nIterations/1000) + "K: "); + for (int i = 0; i < nIterations; i++) { + if (random.nextDouble() < pInsert) { + Integer value = new Integer(random.nextInt(Integer.MAX_VALUE)); + boolean newEntry = expected.add(value); + if (newEntry) { + BTMockRecord btValue = new BTMockRecord(this.db, value.intValue()); + history.add(btValue); + if (DEBUG > 1) + System.out.println("Add: " + value + " @ " + btValue.record); + this.btree.insert(btValue.getRecord()); + } + } else { + if (!history.isEmpty()) { + int index = random.nextInt(history.size()); + BTMockRecord btValue = history.get(index); + history.remove(index); + expected.remove(new Integer(btValue.intValue())); + if (DEBUG > 1) + System.out.println("Remove: " + btValue.intValue() + " @ " + btValue.record); + this.btree.delete(btValue.getRecord()); + } + } + if (i % 1000 == 0 && DEBUG > 0) { + System.out.print("."); + } + if (checkCorrectnessEachIteration) { + assertBTreeMatchesSortedSet("[iteration " + i + "] ", this.btree, expected); + assertBTreeInvariantsHold("[iteration " + i + "] "); + } + } + if (DEBUG > 0) + System.out.println(); + + assertBTreeMatchesSortedSet("[Trial end] ", this.btree, expected); + assertBTreeInvariantsHold("[Trial end]"); + + finish(); + } + + public void assertBTreeInvariantsHold(String msg) throws CoreException { + String errorReport = this.btree.getInvariantsErrorReport(); + if (!errorReport.equals("")) { + fail("Invariants do not hold: " + errorReport); + } + } + + public void assertBTreeMatchesSortedSet(final String msg, BTree actual, SortedSet<Integer> expected) throws CoreException { + final Iterator<Integer> i = expected.iterator(); + this.btree.accept(new IBTreeVisitor() { + int k; + @Override + public int compare(long record) { + return 0; + } + + @Override + public boolean visit(long record) { + if (record != 0) { + BTMockRecord btValue = new BTMockRecord(record, BTreeTests.this.db); + if (i.hasNext()) { + Integer exp = i.next(); + assertEquals(msg + " Differ at index: " + this.k, btValue.intValue(), exp.intValue()); + this.k++; + } else { + fail("Sizes different"); + return false; + } + } + return true; + } + }); + } + + private static class BTMockRecord { + public static final int VALUE_PTR = 0; + public static final int RECORD_SIZE = Database.INT_SIZE; + long record; + Database db; + + /** + * Make a new record + */ + public BTMockRecord(Database db, int value) throws CoreException { + this.db = db; + this.record = db.malloc(BTMockRecord.RECORD_SIZE, Database.POOL_MISC); + db.putInt(this.record + VALUE_PTR, value); + } + + /** + * Get an existing record + */ + public BTMockRecord(long record, Database db) { + this.db = db; + this.record = record; + } + + public int intValue() { + return this.db.getInt(this.record); + } + + public long getRecord() { + return this.record; + } + } + + private class BTMockRecordComparator implements IBTreeComparator { + public BTMockRecordComparator() { + } + + @Override + public int compare(Nd ndToCompare, long record1, long record2) { + Database dbToCompare = ndToCompare.getDB(); + return dbToCompare.getInt(record1) - dbToCompare.getInt(record2); + } + } +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/DatabaseTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/DatabaseTest.java new file mode 100644 index 000000000..9dd4557c4 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/DatabaseTest.java @@ -0,0 +1,333 @@ +/******************************************************************************* + * Copyright (c) 2005, 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * QNX Software Systems - initial API and implementation + * Andrew Ferguson (Symbian) + * Markus Schorn (Wind River Systems) + *******************************************************************************/ +package org.eclipse.jdt.core.tests.nd; + +import java.io.File; +import java.util.Random; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jdt.core.tests.nd.util.BaseTestCase; +import org.eclipse.jdt.internal.core.nd.Nd; +import org.eclipse.jdt.internal.core.nd.NdNode; +import org.eclipse.jdt.internal.core.nd.NdNodeTypeRegistry; +import org.eclipse.jdt.internal.core.nd.db.BTree; +import org.eclipse.jdt.internal.core.nd.db.ChunkCache; +import org.eclipse.jdt.internal.core.nd.db.Database; +import org.eclipse.jdt.internal.core.nd.db.IBTreeComparator; +import org.eclipse.jdt.internal.core.nd.db.IBTreeVisitor; +import org.eclipse.jdt.internal.core.nd.db.IString; +import org.eclipse.jdt.internal.core.nd.db.IndexException; +import org.eclipse.jdt.internal.core.nd.db.ShortString; + +import junit.framework.Test; + +/** + * Tests for the {@link Database} class. + */ +public class DatabaseTest extends BaseTestCase { + // This constant can be used to run the test with very large databases. + // Try, for example, setting it to Integer.MAX_VALUE * 7L; + private static final long TEST_OFFSET = 0; + private Nd nd; + protected Database db; + private static final int CURRENT_VERSION = 10; + + @Override + protected void setUp() throws Exception { + super.setUp(); + String testName = getName(); + NdNodeTypeRegistry<NdNode> registry = new NdNodeTypeRegistry<>(); + this.nd = new Nd(DatabaseTestUtil.getTempDbName(testName), new ChunkCache(), registry, + 0, 100, CURRENT_VERSION); + this.db = this.nd.getDB(); + this.db.setExclusiveLock(); + + // Allocate all database chunks up to TEST_OFFSET. + int count = 0; + for (long offset = 0; offset < TEST_OFFSET;) { + offset = this.db.malloc(Database.MAX_MALLOC_SIZE, Database.POOL_MISC); + if (++count >= 1000) { + this.db.flush(); + count = 0; + } + } + this.db.flush(); + } + + public static Test suite() { + return BaseTestCase.suite(DatabaseTest.class); + } + + @Override + protected void tearDown() throws Exception { + this.db.close(); + if (!this.db.getLocation().delete()) { + this.db.getLocation().deleteOnExit(); + } + this.db= null; + } + + public void testBlockSizeAndFirstBlock() throws Exception { + assertEquals(CURRENT_VERSION, this.db.getVersion()); + + final int realsize = 42; + final int deltas = (realsize + Database.BLOCK_HEADER_SIZE + Database.BLOCK_SIZE_DELTA - 1) / Database.BLOCK_SIZE_DELTA; + final int blocksize = deltas * Database.BLOCK_SIZE_DELTA; + final int freeDeltas= Database.CHUNK_SIZE / Database.BLOCK_SIZE_DELTA - deltas; + + long mem = this.db.malloc(realsize, Database.POOL_MISC); + assertEquals(-blocksize, this.db.getShort(mem - Database.BLOCK_HEADER_SIZE)); + this.db.free(mem, Database.POOL_MISC); + assertEquals(blocksize, this.db.getShort(mem - Database.BLOCK_HEADER_SIZE)); + assertEquals(mem, this.db.getRecPtr((deltas - Database.MIN_BLOCK_DELTAS +1 ) * Database.INT_SIZE)); + assertEquals(mem + blocksize, this.db.getRecPtr((freeDeltas - Database.MIN_BLOCK_DELTAS + 1) * Database.INT_SIZE)); + } + + public void testBug192437() throws Exception { + File tmp= File.createTempFile("readOnlyEmpty", ".db"); + try { + tmp.setReadOnly(); + + /* check opening a readonly file for rw access fails */ + try { + new Database(tmp, ChunkCache.getSharedInstance(), 0, false); + fail("A readonly file should not be openable with write-access"); + } catch (IndexException e) { + // we expect to get a failure here + } + + /* check opening a readonly file for read access does not fail */ + try { + new Database(tmp, ChunkCache.getSharedInstance(), 0, true); + } catch (IndexException e) { + fail("A readonly file should be readable by a permanently readonly database " + e); + } + } finally { + tmp.delete(); // this may be pointless on some platforms + } + } + + public void testFreeBlockLinking() throws Exception { + final int realsize = 42; + final int deltas = (realsize + Database.BLOCK_HEADER_SIZE + Database.BLOCK_SIZE_DELTA - 1) / Database.BLOCK_SIZE_DELTA; + + long mem1 = this.db.malloc(realsize, Database.POOL_MISC); + long mem2 = this.db.malloc(realsize, Database.POOL_MISC); + this.db.free(mem1, Database.POOL_MISC); + this.db.free(mem2, Database.POOL_MISC); + assertEquals(mem2, this.db.getRecPtr((deltas - Database.MIN_BLOCK_DELTAS + 1) * Database.INT_SIZE)); + assertEquals(0, this.db.getRecPtr(mem2)); + assertEquals(mem1, this.db.getRecPtr(mem2 + Database.INT_SIZE)); + assertEquals(mem2, this.db.getRecPtr(mem1)); + assertEquals(0, this.db.getRecPtr(mem1 + Database.INT_SIZE)); + } + + public void testSimpleAllocationLifecycle() throws Exception { + long mem1 = this.db.malloc(42, Database.POOL_MISC); + this.db.free(mem1, Database.POOL_MISC); + long mem2 = this.db.malloc(42, Database.POOL_MISC); + assertEquals(mem2, mem1); + } + + private static class FindVisitor implements IBTreeVisitor { + private Database db; + private String key; + private long address; + + public FindVisitor(Database db, String key) { + this.db = db; + this.key = key; + } + + @Override + public int compare(long toCompare) { + return this.db.getString(this.db.getRecPtr(toCompare + 4)).compare(this.key, true); + } + + @Override + public boolean visit(long toCompare) { + this.address = toCompare; + return false; + } + + public long getRecord() { + return this.address; + } + } + + public void testStringsInBTree() throws Exception { + String[] names = { + "ARLENE", + "BRET", + "CINDY", + "DENNIS", + "EMILY", + "FRANKLIN", + "GERT", + "HARVEY", + "IRENE", + "JOSE", + "KATRINA", + "LEE", + "MARIA", + "NATE", + "OPHELIA", + "PHILIPPE", + "RITA", + "STAN", + "TAMMY", + "VINCE", + "WILMA", + "ALPHA", + "BETA" + }; + + IBTreeComparator comparator = new IBTreeComparator() { + @Override + public int compare(Nd ndToCompare, long record1, long record2) { + IString string1 = DatabaseTest.this.db.getString(DatabaseTest.this.db.getRecPtr(record1 + 4)); + IString string2 = DatabaseTest.this.db.getString(DatabaseTest.this.db.getRecPtr(record2 + 4)); + return string1.compare(string2, true); + } + }; + + BTree btree = new BTree(this.nd, Database.DATA_AREA_OFFSET, comparator); + for (int i = 0; i < names.length; ++i) { + String name = names[i]; + long record = this.db.malloc(8, Database.POOL_MISC); + this.db.putInt(record + 0, i); + IString string = this.db.newString(name); + this.db.putRecPtr(record + 4, string.getRecord()); + btree.insert(record); + } + + for (int i = 0; i < names.length; ++i) { + String name = names[i]; + FindVisitor finder = new FindVisitor(this.db, name); + btree.accept(finder); + long record = finder.getRecord(); + assertTrue(record != 0); + assertEquals(i, this.db.getInt(record)); + IString rname = this.db.getString(this.db.getRecPtr(record + 4)); + assertTrue(rname.equals(name)); + } + } + + private final int GT = 1, LT = -1, EQ = 0; + + public void testShortStringComparison() throws CoreException { + Random r= new Random(90210); + + assertCMP("", this.EQ, "", true); + assertCMP("", this.EQ, "", false); + + doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH / 2, r, true); + doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH / 2, r, false); + doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH, r, true); + doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH, r, false); + + assertCMP("a", this.LT, "b", true); + assertCMP("aa", this.LT, "ab", true); + assertCMP("a", this.EQ, "a", true); + + assertCMP("a", this.GT, "A", true); + assertCMP("aa", this.GT, "aA", true); + assertCMP("a", this.GT, "B", true); + + assertCMP("a", this.EQ, "a", false); + assertCMP("a", this.EQ, "A", false); + } + + public void testLongStringComparison() throws CoreException { + Random r= new Random(314159265); + doTrials(100, ShortString.MAX_BYTE_LENGTH + 1, ShortString.MAX_BYTE_LENGTH * 2, r, true); + doTrials(100, ShortString.MAX_BYTE_LENGTH + 1, ShortString.MAX_BYTE_LENGTH * 2, r, false); + } + + private void doTrials(int n, int min, int max, Random r, boolean caseSensitive) throws CoreException { +// long start = System.currentTimeMillis(); + for (int i= 0; i < n; i++) { + String a = randomString(min, max, r); + String b = randomString(min, max, r); + int expected = caseSensitive ? a.compareTo(b) : a.compareToIgnoreCase(b); + assertCMP(a, expected, b, caseSensitive); + } +// System.out.print("Trials: " + n + " Max length: " + max + " ignoreCase: " + !caseSensitive); +// System.out.println(" Time: " + (System.currentTimeMillis() - start)); + } + + private String randomString(int min, int max, Random r) { + int len = min + r.nextInt(max - min); + return randomString(len, r); + } + + private String randomString(int len, Random r) { + StringBuilder result = new StringBuilder(len); + for (int i= 0; i < len; i++) { + result.append(randomChar(r)); + } + return result.toString(); + } + + private char randomChar(Random r) { + // We only match String.compareToIgnoreCase behavior within this limited range. + return (char) (32 + r.nextInt(40)); + } + + private void assertCMP(String a, int expected, String b, boolean caseSensitive) throws CoreException { + char[] acs = a.toCharArray(); + char[] bcs = b.toCharArray(); + IString aiss = this.db.newString(a); + IString biss = this.db.newString(b); + IString aisc = this.db.newString(acs); + IString bisc = this.db.newString(bcs); + + assertEquals(a.hashCode(), aiss.hashCode()); + assertEquals(a.hashCode(), aisc.hashCode()); + assertEquals(b.hashCode(), biss.hashCode()); + assertEquals(b.hashCode(), bisc.hashCode()); + + assertEquals(aiss, a); + assertEquals(aisc, a); + assertEquals(biss, b); + assertEquals(bisc, b); + + assertSignEquals(expected, aiss.compare(bcs, caseSensitive)); + assertSignEquals(expected, aiss.compare(biss, caseSensitive)); + assertSignEquals(expected, aiss.compare(bisc, caseSensitive)); + assertSignEquals(expected, aiss.compare(b, caseSensitive)); + assertSignEquals(expected, aiss.comparePrefix(bcs, caseSensitive)); + + assertSignEquals(expected, -biss.compare(acs, caseSensitive)); + assertSignEquals(expected, -biss.compare(aiss, caseSensitive)); + assertSignEquals(expected, -biss.compare(aisc, caseSensitive)); + assertSignEquals(expected, -biss.compare(a, caseSensitive)); + assertSignEquals(expected, -biss.comparePrefix(acs, caseSensitive)); + + if (!caseSensitive && expected != 0) { + assertSignEquals(expected, aiss.compareCompatibleWithIgnoreCase(bcs)); + assertSignEquals(expected, aiss.compareCompatibleWithIgnoreCase(biss)); + assertSignEquals(expected, aiss.compareCompatibleWithIgnoreCase(bisc)); + + assertSignEquals(expected, -biss.compareCompatibleWithIgnoreCase(acs)); + assertSignEquals(expected, -biss.compareCompatibleWithIgnoreCase(aiss)); + assertSignEquals(expected, -biss.compareCompatibleWithIgnoreCase(aisc)); + } + } + + private void assertSignEquals(int a, int b) { + a= a < 0 ? -1 : (a > 0 ? 1 : 0); + b= b < 0 ? -1 : (b > 0 ? 1 : 0); + assertEquals(a, b); + } +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/DatabaseTestUtil.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/DatabaseTestUtil.java new file mode 100644 index 000000000..30040db2b --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/DatabaseTestUtil.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2016 Google, Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Stefan Xenos (Google) - Initial implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.nd; + +import java.io.File; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Plugin; +import org.eclipse.jdt.core.tests.Activator; +import org.eclipse.jdt.internal.core.nd.Nd; +import org.eclipse.jdt.internal.core.nd.NdNode; +import org.eclipse.jdt.internal.core.nd.NdNodeTypeRegistry; +import org.eclipse.jdt.internal.core.nd.db.ChunkCache; + +/** + * + */ +public class DatabaseTestUtil { + + public static IPath getTestDir() { + Plugin plugin = Activator.getInstance(); + + IPath path = plugin.getStateLocation().append("tests/"); + File file = path.toFile(); + if (!file.exists()) + file.mkdir(); + return path; + } + + public static File getTempDbName(String testName) { + return DatabaseTestUtil.getTestDir().append(testName + System.currentTimeMillis() + ".dat").toFile(); + } + + /** + * Creates an empty {@link Nd} with an empty type registry and randomly-named + * database for the given test name + * + * @param testName + * @return the new {@link Nd} + */ + public static Nd createEmptyNd(String testName) { + NdNodeTypeRegistry<NdNode> registry = new NdNodeTypeRegistry<>(); + return new Nd(DatabaseTestUtil.getTempDbName(testName), new ChunkCache(), registry, 0, 0, 0); + } + + public static Nd createEmptyNd(String testName, NdNodeTypeRegistry<NdNode> registry) { + return new Nd(DatabaseTestUtil.getTempDbName(testName), new ChunkCache(), registry, 0, 0, 0); + } +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/FieldBackPointerTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/FieldBackPointerTest.java new file mode 100644 index 000000000..b2ccfad6b --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/FieldBackPointerTest.java @@ -0,0 +1,379 @@ +/******************************************************************************* + * Copyright (c) 2015, 2016 Google, Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Stefan Xenos (Google) - Initial implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.nd; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; + +import org.eclipse.jdt.core.tests.nd.util.BaseTestCase; +import org.eclipse.jdt.internal.core.nd.Nd; +import org.eclipse.jdt.internal.core.nd.NdNode; +import org.eclipse.jdt.internal.core.nd.NdNodeTypeRegistry; +import org.eclipse.jdt.internal.core.nd.RawGrowableArray; +import org.eclipse.jdt.internal.core.nd.field.FieldInt; +import org.eclipse.jdt.internal.core.nd.field.FieldManyToOne; +import org.eclipse.jdt.internal.core.nd.field.FieldOneToMany; +import org.eclipse.jdt.internal.core.nd.field.StructDef; + +import junit.framework.Test; + +public class FieldBackPointerTest extends BaseTestCase { + public static class ForwardPointerStruct extends NdNode { + public static final FieldManyToOne<BackPointerStruct> FORWARD; + public static final FieldManyToOne<BackPointerStruct> OWNER; + + @SuppressWarnings("hiding") + public static final StructDef<ForwardPointerStruct> type; + + static { + type = StructDef.create(ForwardPointerStruct.class, NdNode.type); + + FORWARD = FieldManyToOne.create(type, BackPointerStruct.BACK); + OWNER = FieldManyToOne.createOwner(type, BackPointerStruct.OWNED); + type.done(); + } + + public ForwardPointerStruct(Nd nd) { + super(nd); + } + + public ForwardPointerStruct(Nd nd, long record) { + super(nd, record); + } + + public void setBp(BackPointerStruct toSet) { + FORWARD.put(getNd(), this.address, toSet); + } + + public BackPointerStruct getBp() { + return FORWARD.get(getNd(), this.address); + } + + public void setOwner(BackPointerStruct owner) { + OWNER.put(getNd(), this.address, owner); + } + + public BackPointerStruct getOwner() { + return OWNER.get(getNd(), this.address); + } + } + + public static class BackPointerStruct extends NdNode { + public static final FieldOneToMany<ForwardPointerStruct> BACK; + public static final FieldOneToMany<ForwardPointerStruct> OWNED; + public static final FieldInt SOMEINT; + + @SuppressWarnings("hiding") + public static final StructDef<BackPointerStruct> type; + + static { + type = StructDef.create(BackPointerStruct.class, NdNode.type); + + BACK = FieldOneToMany.create(type, ForwardPointerStruct.FORWARD, 2); + OWNED = FieldOneToMany.create(type, ForwardPointerStruct.OWNER, 0); + SOMEINT = type.addInt(); + type.done(); + } + + public BackPointerStruct(Nd nd) { + super(nd); + + // Fill with nonzero values to ensure that "OWNED" doesn't read beyond its boundary + SOMEINT.put(nd, this.address, 0xf0f0f0f0); + } + + public BackPointerStruct(Nd nd, long record) { + super(nd, record); + } + + public void ensureBackPointerCapacity(int capacity) { + BACK.ensureCapacity(getNd(), this.address, capacity); + } + + public int getBackPointerCapacity() { + return BACK.getCapacity(getNd(), this.address); + } + + public List<ForwardPointerStruct> getBackPointers() { + return BACK.asList(getNd(), this.address); + } + + public List<ForwardPointerStruct> getOwned() { + return OWNED.asList(getNd(), this.address); + } + + public int backPointerSize() { + return BACK.size(getNd(), this.address); + } + + public boolean backPointersAreEmpty() { + return BACK.isEmpty(getNd(), this.address); + } + + public boolean ownedPointersAreEmpty() { + return OWNED.isEmpty(getNd(), this.address); + } + + public ForwardPointerStruct getBackPointer(int i) { + return BACK.get(getNd(), this.address, i); + } + } + + ForwardPointerStruct fa; + ForwardPointerStruct fb; + ForwardPointerStruct fc; + ForwardPointerStruct fd; + BackPointerStruct ba; + BackPointerStruct bb; + private Nd nd; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + NdNodeTypeRegistry<NdNode> registry = new NdNodeTypeRegistry<>(); + registry.register(0, BackPointerStruct.type.getFactory()); + registry.register(1, ForwardPointerStruct.type.getFactory()); + this.nd = DatabaseTestUtil.createEmptyNd(getName(), registry); + this.nd.getDB().setExclusiveLock(); + this.ba = new BackPointerStruct(this.nd); + this.bb = new BackPointerStruct(this.nd); + this.fa = new ForwardPointerStruct(this.nd); + this.fb = new ForwardPointerStruct(this.nd); + this.fc = new ForwardPointerStruct(this.nd); + this.fd = new ForwardPointerStruct(this.nd); + } + + public static Test suite() { + return BaseTestCase.suite(FieldBackPointerTest.class); + } + + void assertBackPointers(BackPointerStruct bp, ForwardPointerStruct... fp) { + HashSet<ForwardPointerStruct> backPointers = new HashSet<>(bp.getBackPointers()); + HashSet<ForwardPointerStruct> desired = new HashSet<>(); + + desired.addAll(Arrays.asList(fp)); + assertEquals(desired, backPointers); + } + + public void testWriteFollowedByReadReturnsSameThing() throws Exception { + this.fa.setBp(this.ba); + BackPointerStruct backpointer = this.fa.getBp(); + + assertEquals(this.ba, backpointer); + } + + public void testListWithoutInlineElementsCanBeEmpty() throws Exception { + assertTrue(this.ba.ownedPointersAreEmpty()); + } + + public void testReadNull() throws Exception { + assertEquals(null, this.fa.getBp()); + } + + public void testAssigningTheSamePointerTwiceIsANoop() throws Exception { + this.fa.setBp(this.ba); + + assertBackPointers(this.ba, this.fa); + + // Now do the same thing again + this.fa.setBp(this.ba); + + assertBackPointers(this.ba, this.fa); + } + + public void testAssigningForwardPointerInsertsBackPointer() throws Exception { + this.fa.setBp(this.ba); + + assertEquals(Arrays.asList(this.fa), this.ba.getBackPointers()); + assertEquals(1, this.ba.backPointerSize()); + } + + public void testRemovesInlineElement() throws Exception { + this.fa.setBp(this.ba); + this.fb.setBp(this.ba); + this.fc.setBp(this.ba); + this.fd.setBp(this.ba); + + assertEquals(4, this.ba.backPointerSize()); + this.fb.setBp(null); + assertEquals(3, this.ba.backPointerSize()); + + assertBackPointers(this.ba, this.fa, this.fc, this.fd); + } + + public void testRemovesElementFromGrowableBlock() throws Exception { + this.fa.setBp(this.ba); + this.fb.setBp(this.ba); + this.fc.setBp(this.ba); + this.fd.setBp(this.ba); + + assertEquals(4, this.ba.backPointerSize()); + this.fc.setBp(null); + assertEquals(3, this.ba.backPointerSize()); + + assertBackPointers(this.ba, this.fa, this.fb, this.fd); + } + + public void testDestructingForwardPointerRemovesBackPointer() throws Exception { + this.fa.setBp(this.ba); + this.fb.setBp(this.ba); + this.fc.setBp(this.ba); + + this.fb.delete(); + this.nd.processDeletions(); + + assertBackPointers(this.ba, this.fa, this.fc); + } + + public void testDestructingBackPointerClearsForwardPointers() throws Exception { + this.fa.setBp(this.ba); + this.fb.setBp(this.ba); + this.fc.setBp(this.ba); + + this.ba.delete(); + this.nd.processDeletions(); + + assertEquals(null, this.fa.getBp()); + assertEquals(null, this.fb.getBp()); + assertEquals(null, this.fc.getBp()); + } + + public void testElementsRemainInInsertionOrderIfNoRemovals() throws Exception { + this.fa.setBp(this.ba); + this.fb.setBp(this.ba); + this.fc.setBp(this.ba); + this.fd.setBp(this.ba); + + assertEquals(Arrays.asList(this.fa, this.fb, this.fc, this.fd), this.ba.getBackPointers()); + } + + public void testDeletingOwnerDeletesOwned() throws Exception { + this.fa.setBp(this.ba); + this.fa.setOwner(this.bb); + + this.fb.setBp(this.ba); + this.fb.setOwner(this.bb); + + this.fc.setBp(this.ba); + + this.bb.delete(); + this.nd.processDeletions(); + + assertBackPointers(this.ba, this.fc); + } + + public void testEnsureCapacityDoesNothingIfLessThanInlineElements() throws Exception { + this.ba.ensureBackPointerCapacity(1); + assertEquals(2, this.ba.getBackPointerCapacity()); + } + + public void testEnsureCapacityAllocatesPowersOfTwoPlusInlineSize() throws Exception { + this.ba.ensureBackPointerCapacity(60); + assertEquals(66, this.ba.getBackPointerCapacity()); + } + + public void testEnsureCapacityAllocatesMinimumSize() throws Exception { + this.ba.ensureBackPointerCapacity(3); + assertEquals(4, this.ba.getBackPointerCapacity()); + } + + public void testEnsureCapacityClampsToChunkSize() throws Exception { + this.ba.ensureBackPointerCapacity(RawGrowableArray.getMaxGrowableBlockSize() - 40); + assertEquals(RawGrowableArray.getMaxGrowableBlockSize() + 2, this.ba.getBackPointerCapacity()); + } + + public void testEnsureCapacityGrowsByMultiplesOfMaxBlockSizeOnceMetablockInUse() throws Exception { + int maxBlockSize = RawGrowableArray.getMaxGrowableBlockSize(); + this.ba.ensureBackPointerCapacity(maxBlockSize * 3 - 100); + assertEquals(maxBlockSize * 3 + 2, this.ba.getBackPointerCapacity()); + } + + public void testAdditionsWontReduceCapacity() throws Exception { + int maxBlockSize = RawGrowableArray.getMaxGrowableBlockSize(); + this.ba.ensureBackPointerCapacity(maxBlockSize); + + this.fa.setBp(this.ba); + this.fb.setBp(this.ba); + this.fc.setBp(this.ba); + this.fd.setBp(this.ba); + + assertEquals(maxBlockSize + 2, this.ba.getBackPointerCapacity()); + } + + public void testIsEmpty() throws Exception { + assertTrue(this.ba.backPointersAreEmpty()); + this.fa.setBp(this.ba); + assertFalse(this.ba.backPointersAreEmpty()); + this.fb.setBp(this.ba); + this.fc.setBp(this.ba); + this.fd.setBp(this.ba); + assertFalse(this.ba.backPointersAreEmpty()); + } + + public void testRemovalsReduceCapacity() throws Exception { + int maxBlockSize = RawGrowableArray.getMaxGrowableBlockSize(); + this.ba.ensureBackPointerCapacity(maxBlockSize); + + this.fa.setBp(this.ba); + this.fb.setBp(this.ba); + this.fc.setBp(this.ba); + assertEquals(maxBlockSize + 2, this.ba.getBackPointerCapacity()); + + this.fb.setBp(null); + this.fc.setBp(null); + + assertEquals(2, this.ba.getBackPointerCapacity()); + } + + public void testInsertEnoughToUseMetablock() throws Exception { + // We need enough instances to fill several full blocks since we don't reclaim + // memory until there are two unused blocks. + int numToAllocate = RawGrowableArray.getMaxGrowableBlockSize() * 4 + 1; + + List<ForwardPointerStruct> allocated = new ArrayList<>(); + + for (int count = 0; count < numToAllocate; count++) { + ForwardPointerStruct next = new ForwardPointerStruct(this.nd); + + next.setBp(this.ba); + assertEquals(next, this.ba.getBackPointer(count)); + allocated.add(next); + assertEquals(count + 1, this.ba.backPointerSize()); + } + + assertEquals(allocated.get(numToAllocate - 1), this.ba.getBackPointer(numToAllocate - 1)); + assertEquals(numToAllocate, this.ba.backPointerSize()); + + int correctSize = numToAllocate; + for (ForwardPointerStruct next : allocated) { + next.setBp(null); + assertEquals(--correctSize, this.ba.backPointerSize()); + } + + assertEquals(0, this.ba.backPointerSize()); + assertEquals(2, this.ba.getBackPointerCapacity()); + } + + public void testGrowExistingMetablock() throws Exception { + int blockSize = RawGrowableArray.getMaxGrowableBlockSize(); + + this.ba.ensureBackPointerCapacity(2 * blockSize); + + assertEquals(2 * blockSize + 2, this.ba.getBackPointerCapacity()); + + this.ba.ensureBackPointerCapacity(6 * blockSize); + + assertEquals(6 * blockSize + 2, this.ba.getBackPointerCapacity()); + } +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/InheritenceTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/InheritenceTests.java new file mode 100644 index 000000000..bb0db5301 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/InheritenceTests.java @@ -0,0 +1,244 @@ +/******************************************************************************* + * Copyright (c) 2015, 2016 Google, Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Stefan Xenos (Google) - Initial implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.nd; + +import org.eclipse.jdt.core.tests.nd.util.BaseTestCase; +import org.eclipse.jdt.internal.core.nd.Nd; +import org.eclipse.jdt.internal.core.nd.NdNode; +import org.eclipse.jdt.internal.core.nd.NdNodeTypeRegistry; +import org.eclipse.jdt.internal.core.nd.field.FieldManyToOne; +import org.eclipse.jdt.internal.core.nd.field.FieldOneToMany; +import org.eclipse.jdt.internal.core.nd.field.StructDef; + +import junit.framework.Test; + +public class InheritenceTests extends BaseTestCase { + /** + * Every other object in this test has a pointer to the deletion detector, so we can detect + * which objects have been deleted by looking for the object in the backpointer list. + */ + public static class AllObjects extends NdNode { + public static final FieldOneToMany<BaseClass> BASE_CLASS_INSTANCES; + public static final FieldOneToMany<Reference> REFERENCE_INSTANCES; + + @SuppressWarnings("hiding") + public static final StructDef<AllObjects> type; + + static { + type = StructDef.create(AllObjects.class, NdNode.type); + + BASE_CLASS_INSTANCES = FieldOneToMany.create(type, BaseClass.DELETION_DETECTOR, 0); + REFERENCE_INSTANCES = FieldOneToMany.create(type, Reference.DELETION_DETECTOR, 0); + type.done(); + } + + public AllObjects(Nd nd, long record) { + super(nd, record); + } + + public AllObjects(Nd nd) { + super(nd); + } + + boolean contains(BaseClass toTest) { + return BASE_CLASS_INSTANCES.asList(getNd(), this.address).contains(toTest); + } + + boolean contains(Reference toTest) { + return REFERENCE_INSTANCES.asList(getNd(), this.address).contains(toTest); + } + } + + public static class BaseClass extends NdNode { + public static final FieldOneToMany<Reference> INCOMING_REFERENCES; + public static final FieldOneToMany<Reference> OWNED_REFERENCES; + public static final FieldManyToOne<AllObjects> DELETION_DETECTOR; + + @SuppressWarnings("hiding") + public static final StructDef<BaseClass> type; + + static { + type = StructDef.create(BaseClass.class, NdNode.type); + + INCOMING_REFERENCES = FieldOneToMany.create(type, Reference.BASE_CLASS_REFERENCE, 0); + OWNED_REFERENCES = FieldOneToMany.create(type, Reference.OWNER, 0); + DELETION_DETECTOR = FieldManyToOne.create(type, AllObjects.BASE_CLASS_INSTANCES); + type.useStandardRefCounting().done(); + } + + public BaseClass(Nd nd, AllObjects deletionDetector) { + super(nd); + + DELETION_DETECTOR.put(nd, this.address, deletionDetector); + } + + public BaseClass(Nd nd, long record) { + super(nd, record); + } + } + + public static class SubClass extends BaseClass { + public static final FieldOneToMany<Reference> MORE_REFERENCES; + + @SuppressWarnings("hiding") + public static final StructDef<SubClass> type; + + static { + type = StructDef.create(SubClass.class, BaseClass.type); + + MORE_REFERENCES = FieldOneToMany.create(type, Reference.SUB_CLASS_REFERENCE, 0); + type.useStandardRefCounting().done(); + } + + public SubClass(Nd nd, long record) { + super(nd, record); + } + + public SubClass(Nd nd, AllObjects deletionDetector) { + super(nd, deletionDetector); + } + } + + public static class Reference extends NdNode { + public static final FieldManyToOne<BaseClass> BASE_CLASS_REFERENCE; + public static final FieldManyToOne<BaseClass> OWNER; + public static final FieldManyToOne<SubClass> SUB_CLASS_REFERENCE; + public static final FieldManyToOne<AllObjects> DELETION_DETECTOR; + + @SuppressWarnings("hiding") + public static StructDef<Reference> type; + + static { + type = StructDef.create(Reference.class, NdNode.type); + + BASE_CLASS_REFERENCE = FieldManyToOne.create(type, BaseClass.INCOMING_REFERENCES); + OWNER = FieldManyToOne.createOwner(type, BaseClass.OWNED_REFERENCES); + SUB_CLASS_REFERENCE = FieldManyToOne.create(type, SubClass.MORE_REFERENCES); + DELETION_DETECTOR = FieldManyToOne.create(type, AllObjects.REFERENCE_INSTANCES); + type.done(); + } + + public Reference(Nd nd, long record) { + super(nd, record); + } + + public Reference(Nd nd, AllObjects deletionDetector) { + super(nd); + + DELETION_DETECTOR.put(nd, this.address, deletionDetector); + } + + public void setBaseClassReference(BaseClass target) { + BASE_CLASS_REFERENCE.put(getNd(), this.address, target); + } + + public void setOwner(BaseClass target) { + OWNER.put(getNd(), this.address, target); + } + + public void setSubClassReference(SubClass target) { + SUB_CLASS_REFERENCE.put(getNd(), this.address, target); + } + } + + AllObjects allObjects; + BaseClass baseClass; + SubClass subClass; + Reference refA; + Reference refB; + Reference refC; + private Nd nd; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + NdNodeTypeRegistry<NdNode> registry = new NdNodeTypeRegistry<>(); + registry.register(0, BaseClass.type.getFactory()); + registry.register(1, SubClass.type.getFactory()); + registry.register(2, Reference.type.getFactory()); + registry.register(3, AllObjects.type.getFactory()); + this.nd = DatabaseTestUtil.createEmptyNd(getName(), registry); + this.nd.getDB().setExclusiveLock(); + + this.allObjects = new AllObjects(this.nd); + this.baseClass = new BaseClass(this.nd, this.allObjects); + this.subClass = new SubClass(this.nd, this.allObjects); + + this.refA = new Reference(this.nd, this.allObjects); + this.refB = new Reference(this.nd, this.allObjects); + this.refC = new Reference(this.nd, this.allObjects); + } + + public static Test suite() { + return BaseTestCase.suite(InheritenceTests.class); + } + + public void testRemovingOnlyRefcountDeletesObject() { + assertTrue(this.allObjects.contains(this.subClass)); + this.refA.setSubClassReference(this.subClass); + this.refA.setSubClassReference(null); + this.nd.processDeletions(); + assertFalse(this.allObjects.contains(this.subClass)); + } + + public void testReferencesToBaseClassIncludedInRefCountA() { + // Test what happens when the subclass reference is removed first. + this.refA.setSubClassReference(this.subClass); + this.refB.setBaseClassReference(this.subClass); + assertTrue(this.allObjects.contains(this.subClass)); + this.refA.setSubClassReference(null); + this.nd.processDeletions(); + assertTrue(this.allObjects.contains(this.subClass)); + this.refB.setBaseClassReference(null); + this.nd.processDeletions(); + assertFalse(this.allObjects.contains(this.subClass)); + } + + public void testReferencesToBaseClassIncludedInRefCountB() { + // Test what happens when the base class reference is removed first. + this.refA.setSubClassReference(this.subClass); + this.refB.setBaseClassReference(this.subClass); + this.nd.processDeletions(); + assertTrue(this.allObjects.contains(this.subClass)); + this.refB.setBaseClassReference(null); + this.nd.processDeletions(); + assertTrue(this.allObjects.contains(this.subClass)); + this.refA.setSubClassReference(null); + this.nd.processDeletions(); + assertFalse(this.allObjects.contains(this.subClass)); + } + + public void testOwnedPointersDontCountTowardsRefCount() { + this.refA.setOwner(this.subClass); + this.nd.processDeletions(); + assertTrue(this.allObjects.contains(this.subClass)); + this.refB.setBaseClassReference(this.subClass); + this.nd.processDeletions(); + assertTrue(this.allObjects.contains(this.subClass)); + assertTrue(this.allObjects.contains(this.refA)); + this.refB.setBaseClassReference(null); + this.nd.processDeletions(); + assertFalse(this.allObjects.contains(this.subClass)); + assertFalse(this.allObjects.contains(this.refA)); + } + + public void testMultipleReferences() { + this.refA.setBaseClassReference(this.subClass); + this.refB.setBaseClassReference(this.subClass); + this.refA.setBaseClassReference(null); + this.nd.processDeletions(); + assertTrue(this.allObjects.contains(this.subClass)); + this.refB.setBaseClassReference(null); + this.nd.processDeletions(); + assertFalse(this.allObjects.contains(this.subClass)); + } +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/Package.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/Package.java new file mode 100644 index 000000000..7485b5431 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/Package.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2015, 2016 Google, Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Stefan Xenos (Google) - Initial implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.nd; + +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.Status; +import org.eclipse.jdt.core.JavaCore; + +/** + * @noreference This class is not intended to be referenced by clients + */ +/* package */ class Package { + public static String PLUGIN_ID = JavaCore.PLUGIN_ID; + + /** + * @noreference This method is not intended to be referenced by clients. + */ + public static void log(Throwable e) { + String msg= e.getMessage(); + if (msg == null) { + log("Error", e); //$NON-NLS-1$ + } else { + log("Error: " + msg, e); //$NON-NLS-1$ + } + } + + /** + * @noreference This method is not intended to be referenced by clients. + */ + public static void log(String message, Throwable e) { + log(createStatus(message, e)); + } + + /** + * @noreference This method is not intended to be referenced by clients. + */ + public static IStatus createStatus(String msg, Throwable e) { + return new Status(IStatus.ERROR, PLUGIN_ID, msg, e); + } + + /** + * @noreference This method is not intended to be referenced by clients. + */ + public static IStatus createStatus(String msg) { + return new Status(IStatus.ERROR, PLUGIN_ID, msg); + } + + /** + * @noreference This method is not intended to be referenced by clients. + * + * Returns the appropriate ILog for this package + */ + public static ILog getLog() { + Plugin plugin = JavaCore.getPlugin(); + if (plugin == null) { + return null; + } + return plugin.getLog(); + } + + /** + * @noreference This method is not intended to be referenced by clients. + */ + public static void log(IStatus status) { + getLog().log(status); + } +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/RunIndexTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/RunIndexTests.java new file mode 100644 index 000000000..a6c2bbc16 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/RunIndexTests.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2015, 2016 Google, Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Stefan Xenos (Google) - Initial implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.nd; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.eclipse.jdt.core.tests.junit.extension.TestCase; +import org.eclipse.jdt.core.tests.nd.indexer.IndexerTest; + +import junit.framework.Test; +import junit.framework.TestSuite; + +@SuppressWarnings({"rawtypes", "unchecked"}) +public class RunIndexTests extends junit.framework.TestCase { +public RunIndexTests(String name) { + super(name); +} +public static Class[] getAllTestClasses() { + return new Class[] { + BTreeTests.class, + DatabaseTest.class, + FieldBackPointerTest.class, + IndexerTest.class, + InheritenceTests.class, + SearchKeyTests.class + }; +} +public static Test suite() { + TestSuite ts = new TestSuite(RunIndexTests.class.getName()); + + Class[] testClasses = getAllTestClasses(); + // Reset forgotten subsets of tests + TestCase.TESTS_PREFIX = null; + TestCase.TESTS_NAMES = null; + TestCase.TESTS_NUMBERS = null; + TestCase.TESTS_RANGE = null; + TestCase.RUN_ONLY_ID = null; + + for (int i = 0; i < testClasses.length; i++) { + Class testClass = testClasses[i]; + + // call the suite() method and add the resulting suite to the suite + try { + Method suiteMethod = testClass.getDeclaredMethod("suite", new Class[0]); //$NON-NLS-1$ + Test suite = (Test)suiteMethod.invoke(null, new Object[0]); + ts.addTest(suite); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.getTargetException().printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + } + return ts; +} +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/SearchKeyTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/SearchKeyTests.java new file mode 100644 index 000000000..e48ae79c9 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/SearchKeyTests.java @@ -0,0 +1,164 @@ +/******************************************************************************* + * Copyright (c) 2015, 2016 Google, Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Stefan Xenos (Google) - Initial implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.nd; + +import org.eclipse.jdt.core.tests.nd.util.BaseTestCase; +import org.eclipse.jdt.internal.core.nd.Nd; +import org.eclipse.jdt.internal.core.nd.NdNode; +import org.eclipse.jdt.internal.core.nd.NdNodeTypeRegistry; +import org.eclipse.jdt.internal.core.nd.db.Database; +import org.eclipse.jdt.internal.core.nd.field.FieldSearchIndex; +import org.eclipse.jdt.internal.core.nd.field.FieldSearchKey; +import org.eclipse.jdt.internal.core.nd.field.StructDef; + +import junit.framework.Test; + +public class SearchKeyTests extends BaseTestCase { + private static final String SEARCH_STRING_B = "Yo"; + private static final String SEARCH_STRING_A = "Heyguyswhatshappening"; + private static final String SEARCH_STRING_C = "Shnoogins"; + + public static class TestSearchIndex { + public static final FieldSearchIndex<Element> NICKNAME_INDEX; + public static final FieldSearchIndex<Element> NAME_INDEX; + + public static final StructDef<TestSearchIndex> type; + + static { + type = StructDef.create(TestSearchIndex.class); + NICKNAME_INDEX = FieldSearchIndex.create(type, Element.NICKNAME); + NAME_INDEX = FieldSearchIndex.create(type, Element.NAME); + type.done(); + } + + private final long address; + private Nd nd; + + public TestSearchIndex(Nd dom, long address) { + this.address = address; + this.nd = dom; + } + + public static TestSearchIndex getIndex(Nd nd) { + return new TestSearchIndex(nd, Database.DATA_AREA_OFFSET); + } + + public Element findName(String searchString) { + return NAME_INDEX.findFirst(this.nd, this.address, + FieldSearchIndex.SearchCriteria.create(searchString.toCharArray())); + } + + public Element findNickName(String searchString) { + return NICKNAME_INDEX.findFirst(this.nd, this.address, + FieldSearchIndex.SearchCriteria.create(searchString.toCharArray())); + } + } + + public static class Element extends NdNode { + public static final FieldSearchKey<TestSearchIndex> NAME; + public static final FieldSearchKey<TestSearchIndex> NICKNAME; + + @SuppressWarnings("hiding") + public static StructDef<Element> type; + + static { + type = StructDef.create(Element.class, NdNode.type); + + NAME = FieldSearchKey.create(type, TestSearchIndex.NAME_INDEX); + NICKNAME = FieldSearchKey.create(type, TestSearchIndex.NICKNAME_INDEX); + type.done(); + } + + public Element(Nd nd, long record) { + super(nd, record); + } + + public Element(Nd nd) { + super(nd); + } + + public void setName(String searchStringA) { + NAME.put(getNd(), this.address, searchStringA); + } + + public void setNickName(String searchStringA) { + NICKNAME.put(getNd(), this.address, searchStringA); + } + } + + private Nd nd; + private Element elementA; + private Element elementB; + private TestSearchIndex index; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + NdNodeTypeRegistry<NdNode> registry = new NdNodeTypeRegistry<>(); + registry.register(0, Element.type.getFactory()); + this.nd = DatabaseTestUtil.createEmptyNd(getName(), registry); + this.nd.getDB().setExclusiveLock(); + + this.elementA = new Element(this.nd); + this.elementB = new Element(this.nd); + + this.index = TestSearchIndex.getIndex(this.nd); + } + + public static Test suite() { + return BaseTestCase.suite(SearchKeyTests.class); + } + + public void testSettingKeyCausesInsertionInSearchIndex() { + this.elementA.setName(SEARCH_STRING_A); + this.elementB.setName(SEARCH_STRING_B); + + Element foundElementA = this.index.findName(SEARCH_STRING_A); + Element foundElementB = this.index.findName(SEARCH_STRING_B); + Element foundElementC = this.index.findName(SEARCH_STRING_C); + + assertEquals(this.elementA, foundElementA); + assertEquals(this.elementB, foundElementB); + assertEquals(null, foundElementC); + } + + public void testChangingSearchKeyAffectsIndex() { + this.elementA.setName(SEARCH_STRING_A); + + Element foundElementA = this.index.findName(SEARCH_STRING_A); + Element foundElementB = this.index.findName(SEARCH_STRING_B); + + assertEquals(null, foundElementB); + assertEquals(this.elementA, foundElementA); + + this.elementA.setName(SEARCH_STRING_B); + + foundElementA = this.index.findName(SEARCH_STRING_A); + foundElementB = this.index.findName(SEARCH_STRING_B); + + assertEquals(this.elementA, foundElementB); + assertEquals(null, foundElementA); + } + + public void testDeletingElementRemovesFromIndex() { + this.elementA.setName(SEARCH_STRING_A); + this.elementA.setNickName(SEARCH_STRING_B); + + assertEquals(this.elementA, this.index.findName(SEARCH_STRING_A)); + assertEquals(this.elementA, this.index.findNickName(SEARCH_STRING_B)); + + this.elementA.delete(); + this.nd.processDeletions(); + assertEquals(null, this.index.findName(SEARCH_STRING_A)); + assertEquals(null, this.index.findNickName(SEARCH_STRING_B)); + } +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/indexer/IndexerTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/indexer/IndexerTest.java new file mode 100644 index 000000000..f378a33bc --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/indexer/IndexerTest.java @@ -0,0 +1,214 @@ +/******************************************************************************* + * Copyright (c) 2015, 2016 Google, Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Stefan Xenos (Google) - Initial implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.nd.indexer; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.Semaphore; + +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.SubMonitor; +import org.eclipse.jdt.core.IClassFile; +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.IPackageFragmentRoot; +import org.eclipse.jdt.core.IParent; +import org.eclipse.jdt.core.tests.model.AbstractJavaModelTests; +import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; +import org.eclipse.jdt.internal.core.nd.IReader; +import org.eclipse.jdt.internal.core.nd.db.ChunkCache; +import org.eclipse.jdt.internal.core.nd.db.Database; +import org.eclipse.jdt.internal.core.nd.indexer.IndexTester; +import org.eclipse.jdt.internal.core.nd.indexer.Indexer; +import org.eclipse.jdt.internal.core.nd.java.JavaIndex; +import org.eclipse.jdt.internal.core.nd.java.NdType; +import org.eclipse.jdt.internal.core.nd.java.NdTypeId; +import org.eclipse.jdt.internal.core.nd.java.model.BinaryTypeDescriptor; +import org.eclipse.jdt.internal.core.nd.java.model.BinaryTypeFactory; +import org.eclipse.jdt.internal.core.nd.java.model.IndexBinaryType; + +import junit.framework.Test; + +/** + * Tests for the {@link Database} class. + */ +public class IndexerTest extends AbstractJavaModelTests { + + public IndexerTest(String name) { + super(name); + } + + private static final String PROJECT_NAME = "IndexerTest"; + private static JavaIndex index; + + @Override + protected void setUp() throws Exception { + String testName = getName(); + index = JavaIndexTestUtil.createTempIndex(testName); + super.setUp(); + } + + @Override + protected void tearDown() throws Exception { + deleteProject(PROJECT_NAME); + index.getNd().getPath().delete(); + index = null; + super.tearDown(); + } + + public static Test suite() { + return buildModelTestSuite(IndexerTest.class); + } + + /** + * Verifies that if the index fails a read due to call to {@link Thread#interrupt()}, subsequent reads will + * still succeed. + */ + public void testInterruptedException() throws Exception { + createJavaProject(PROJECT_NAME, new String[] {"src"}, new String[] {"JCL18_FULL"}, "bin", "1.8", true); + // Create an index + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + Indexer indexer = new Indexer(index.getNd(), root); + indexer.rescan(SubMonitor.convert(null)); + // Ensure we're starting with an empty page cache by creating a new + // Index accessor object on the same database + JavaIndex testIndex = JavaIndex + .getIndex(JavaIndex.createNd(index.getNd().getDB().getLocation(), new ChunkCache())); + + Semaphore semaphore = new Semaphore(0); + + boolean[] wasInterrupted = new boolean[1]; + Thread newThread = new Thread(() -> { + try (IReader reader = testIndex.getNd().acquireReadLock()) { + Thread.currentThread().interrupt(); + testIndex.findType("Ljava/util/List;".toCharArray()); + } catch (OperationCanceledException e) { + wasInterrupted[0] = true; + } finally { + semaphore.release(); + } + }); + + newThread.start(); + + semaphore.acquire(); + + assertTrue(wasInterrupted[0]); + try (IReader reader = testIndex.getNd().acquireReadLock()) { + NdTypeId type = testIndex.findType("Ljava/util/List;".toCharArray()); + assertNotNull(type); + } + } + + public void testSubclassesOfGenericTypeCanBeFound() throws Exception { + createJavaProject(PROJECT_NAME, new String[] {"src"}, new String[] {"JCL18_FULL"}, "bin", "1.8", true); + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + Indexer indexer = new Indexer(index.getNd(), root); + + indexer.rescan(SubMonitor.convert(null)); + + try (IReader reader = IndexerTest.index.getNd().acquireReadLock()) { + NdTypeId javaUtilList = IndexerTest.index.findType("Ljava/util/List;".toCharArray()); + NdTypeId javaUtilArrayList = IndexerTest.index.findType("Ljava/util/ArrayList;".toCharArray()); + + boolean found = false; + List<NdType> subtypes = javaUtilList.getSubTypes(); + for (NdType next : subtypes) { + if (Objects.equals(next.getTypeId(), javaUtilArrayList)) { + found = true; + } + } + + assertTrue("ArrayList was found as a subtype of List", found); + } + } + + private void collectAllClassFiles(List<? super IClassFile> result, IParent nextRoot) throws CoreException { + for (IJavaElement child : nextRoot.getChildren()) { + int type = child.getElementType(); + + if (type == IJavaElement.CLASS_FILE) { + result.add((IClassFile)child); + } else if (child instanceof IParent) { + IParent parent = (IParent) child; + + collectAllClassFiles(result, parent); + } + } + } + + public void testReadingAllClassesInIndexAreEquivalentToOriginalJarFiles() throws Exception { + IJavaProject javaProject = createJavaProject(PROJECT_NAME, new String[] {"src"}, new String[] {"JCL18_FULL"}, "bin", "1.8", true); + addClassFolder(javaProject, "lib", new String[] { + "p/Outer.java", + "import java.lang.annotation.*;\n" + + "\n" + + "@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE_USE) @interface A {}\n" + + "@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @interface M {}\n" + + "@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PARAMETER) @interface P {}\n" + + "\n" + + "class Outer {\n" + + " class Middle1 {\n" + + " class Inner {}\n" + + " }\n" + + " static class Middle2 {\n" + + " class Inner {}\n" + + " static class Middle3 {\n" + + " class Inner2{};\n" + + " }\n" + + " }\n" + + " Middle1.@A Inner e1;\n" + + " Middle2.@A Inner e2;\n" + + " Middle2.Middle3.@A Inner2 e3;\n" + + " @M void foo(@P Middle2.Middle3.@A Inner2 e3) {};\n" + + " class Middle4 extends @A Middle1 {}\n" + + "}\n", + }, "1.8"); + + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + Indexer indexer = new Indexer(index.getNd(), root); + + indexer.rescan(SubMonitor.convert(null)); + + boolean foundAtLeastOneClass = false; + SubMonitor subMonitor = SubMonitor.convert(null); + JavaIndex localIndex = IndexerTest.index; + try (IReader reader = localIndex.getNd().acquireReadLock()) { + IPackageFragmentRoot[] roots = javaProject.getAllPackageFragmentRoots(); + subMonitor.setWorkRemaining(roots.length); + for (IPackageFragmentRoot next : roots) { + SubMonitor iterationMon = subMonitor.split(1); + if (next.getKind() == IPackageFragmentRoot.K_BINARY) { + List<IClassFile> result = new ArrayList<>(); + collectAllClassFiles(result, next); + iterationMon.setWorkRemaining(result.size()); + for (IClassFile nextClass : result) { + SubMonitor classMon = iterationMon.split(1); + BinaryTypeDescriptor descriptor = BinaryTypeFactory.createDescriptor(nextClass); + IndexBinaryType indexedBinaryType = (IndexBinaryType)BinaryTypeFactory.readFromIndex(localIndex, descriptor, classMon); + ClassFileReader originalBinaryType = BinaryTypeFactory.rawReadType(descriptor, true); + + if (!indexedBinaryType.exists()) { + throw new IllegalStateException("Unable to find class in index " + new String(descriptor.indexPath)); + } + IndexTester.testType(originalBinaryType, indexedBinaryType); + foundAtLeastOneClass = true; + } + } + } + } + assertTrue("No classes found in the index", foundAtLeastOneClass); + } +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/indexer/JavaIndexTestUtil.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/indexer/JavaIndexTestUtil.java new file mode 100644 index 000000000..84a1cd7c0 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/indexer/JavaIndexTestUtil.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2015, 2016 Google, Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Stefan Xenos (Google) - Initial implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.nd.indexer; + +import java.io.File; + +import org.eclipse.jdt.core.tests.nd.DatabaseTestUtil; +import org.eclipse.jdt.internal.core.nd.db.ChunkCache; +import org.eclipse.jdt.internal.core.nd.java.JavaIndex; + +public class JavaIndexTestUtil { + public static JavaIndex createTempIndex(String id) { + File dbName = DatabaseTestUtil.getTempDbName(id); + return JavaIndex.getIndex(JavaIndex.createNd(dbName, new ChunkCache())); + } +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/util/BaseTestCase.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/util/BaseTestCase.java new file mode 100644 index 000000000..cb99bf2a8 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/util/BaseTestCase.java @@ -0,0 +1,269 @@ +/******************************************************************************* + * Copyright (c) 2006, 2016 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Markus Schorn - initial API and implementation + * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) + *******************************************************************************/ +package org.eclipse.jdt.core.tests.nd.util; + +import junit.framework.AssertionFailedError; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestFailure; +import junit.framework.TestResult; +import junit.framework.TestSuite; + +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.ILogListener; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.NullProgressMonitor; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Deque; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class BaseTestCase extends TestCase { + private static final String DEFAULT_INDEXER_TIMEOUT_SEC = "10"; + private static final String INDEXER_TIMEOUT_PROPERTY = "indexer.timeout"; + /** + * Indexer timeout used by tests. To avoid this timeout expiring during debugging add + * -Dindexer.timeout=some_large_number to VM arguments of the test launch configuration. + */ + protected static final int INDEXER_TIMEOUT_SEC = + Integer.parseInt(System.getProperty(INDEXER_TIMEOUT_PROPERTY, DEFAULT_INDEXER_TIMEOUT_SEC)); + protected static final int INDEXER_TIMEOUT_MILLISEC= INDEXER_TIMEOUT_SEC * 1000; + + private boolean fExpectFailure; + private int fBugNumber; + private int fExpectedLoggedNonOK; + private Deque<File> filesToDeleteOnTearDown= new ArrayDeque<>(); + + public BaseTestCase() { + super(); + } + + public BaseTestCase(String name) { + super(name); + } + + public static NullProgressMonitor npm() { + return new NullProgressMonitor(); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + //CModelListener.sSuppressUpdateOfLastRecentlyUsed= true; + } + + @Override + protected void tearDown() throws Exception { + for (File file; (file = this.filesToDeleteOnTearDown.pollLast()) != null;) { + file.delete(); + } + ResourceHelper.cleanUp(); + //TestScannerProvider.clear(); + super.tearDown(); + } + + protected void deleteOnTearDown(File file) { + this.filesToDeleteOnTearDown.add(file); + } + + protected File createTempFile(String prefix, String suffix) throws IOException { + File file = File.createTempFile(prefix, suffix); + this.filesToDeleteOnTearDown.add(file); + return file; + } + + protected File nonExistentTempFile(String prefix, String suffix) { + File file= new File(System.getProperty("java.io.tmpdir"), + prefix + System.currentTimeMillis() + suffix); + this.filesToDeleteOnTearDown.add(file); + return file; + } + + public static TestSuite suite(Class<? extends BaseTestCase> clazz) { + return suite(clazz, null); + } + + protected static TestSuite suite(Class<? extends BaseTestCase> clazz, String failingTestPrefix) { + TestSuite suite= new TestSuite(clazz); + Test failing= getFailingTests(clazz, failingTestPrefix); + if (failing != null) { + suite.addTest(failing); + } + return suite; + } + + private static Test getFailingTests(Class<? extends BaseTestCase> clazz, String prefix) { + TestSuite suite= new TestSuite("Failing Tests"); + HashSet<String> names= new HashSet<>(); + Class<?> superClass= clazz; + while (Test.class.isAssignableFrom(superClass) && !TestCase.class.equals(superClass)) { + Method[] methods= superClass.getDeclaredMethods(); + for (Method method : methods) { + addFailingMethod(suite, method, names, clazz, prefix); + } + superClass= superClass.getSuperclass(); + } + if (suite.countTestCases() == 0) { + return null; + } + return suite; + } + + private static void addFailingMethod(TestSuite suite, Method m, Set<String> names, + Class<? extends BaseTestCase> clazz, String prefix) { + String name = m.getName(); + if (!names.add(name)) { + return; + } + if (name.startsWith("test") || (prefix != null && !name.startsWith(prefix))) { + return; + } + if (name.equals("tearDown") || name.equals("setUp") || name.equals("runBare")) { + return; + } + if (Modifier.isPublic(m.getModifiers())) { + Class<?>[] parameters = m.getParameterTypes(); + Class<?> returnType = m.getReturnType(); + if (parameters.length == 0 && returnType.equals(Void.TYPE)) { + Test test = TestSuite.createTest(clazz, name); + ((BaseTestCase) test).setExpectFailure(0); + suite.addTest(test); + } + } + } + + @Override + public void runBare() throws Throwable { + final List<IStatus> statusLog= Collections.synchronizedList(new ArrayList<>()); + ILogListener logListener= new ILogListener() { + @Override + public void logging(IStatus status, String plugin) { + if (!status.isOK() && status.getSeverity() != IStatus.INFO) { + switch (status.getCode()) { + case IResourceStatus.NOT_FOUND_LOCAL: + case IResourceStatus.NO_LOCATION_LOCAL: + case IResourceStatus.FAILED_READ_LOCAL: + case IResourceStatus.RESOURCE_NOT_LOCAL: + // Logged by the resources plugin. + return; + } + statusLog.add(status); + } + } + }; + final ILog log = Package.getLog(); + if (log != null) { // Iff we don't run as a JUnit Plugin Test. + log.addLogListener(logListener); + } + + Throwable testThrowable= null; + try { + try { + super.runBare(); + } catch (Throwable e) { + testThrowable= e; + } + + if (statusLog.size() != this.fExpectedLoggedNonOK) { + StringBuilder msg= new StringBuilder("Expected number (" + this.fExpectedLoggedNonOK + ") of "); + msg.append("Non-OK status objects in log differs from actual (" + statusLog.size() + ").\n"); + Throwable cause= null; + if (!statusLog.isEmpty()) { + synchronized (statusLog) { + for (IStatus status : statusLog) { + IStatus[] ss= {status}; + ss= status instanceof MultiStatus ? ((MultiStatus) status).getChildren() : ss; + for (IStatus s : ss) { + msg.append("\t" + s.getMessage() + " "); + + Throwable t= s.getException(); + cause= cause != null ? cause : t; + if (t != null) { + msg.append(t.getMessage() != null ? t.getMessage() : t.getClass().getCanonicalName()); + } + + msg.append("\n"); + } + } + } + } + cause= cause != null ? cause : testThrowable; + AssertionFailedError afe= new AssertionFailedError(msg.toString()); + afe.initCause(cause); + throw afe; + } + } finally { + if (log != null) { + log.removeLogListener(logListener); + } + } + + if (testThrowable != null) + throw testThrowable; + } + + @Override + public void run(TestResult result) { + if (!this.fExpectFailure || Boolean.parseBoolean(System.getProperty("SHOW_EXPECTED_FAILURES"))) { + super.run(result); + return; + } + + result.startTest(this); + + TestResult r = new TestResult(); + super.run(r); + if (r.failureCount() == 1) { + TestFailure failure= r.failures().nextElement(); + String msg= failure.exceptionMessage(); + if (msg != null && msg.startsWith("Method \"" + getName() + "\"")) { + result.addFailure(this, new AssertionFailedError(msg)); + } + } else if (r.errorCount() == 0 && r.failureCount() == 0) { + String err = "Unexpected success of " + getName(); + if (this.fBugNumber > 0) { + err += ", bug #" + this.fBugNumber; + } + result.addFailure(this, new AssertionFailedError(err)); + } + + result.endTest(this); + } + + public void setExpectFailure(int bugNumber) { + this.fExpectFailure= true; + this.fBugNumber= bugNumber; + } + + /** + * The last value passed to this method in the body of a testXXX method + * will be used to determine whether or not the presence of non-OK status objects + * in the log should fail the test. If the logged number of non-OK status objects + * differs from the last value passed, the test is failed. If this method is not called + * at all, the expected number defaults to zero. + * @param count the expected number of logged error and warning messages + */ + public void setExpectedNumberOfLoggedNonOKStatusObjects(int count) { + this.fExpectedLoggedNonOK= count; + } +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/util/Package.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/util/Package.java new file mode 100644 index 000000000..4e2dbbdd3 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/util/Package.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2015, 2016 Google, Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Stefan Xenos (Google) - Initial implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.nd.util; + +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.Status; +import org.eclipse.jdt.core.JavaCore; + +/** + * @noreference This class is not intended to be referenced by clients + */ +/* package */ class Package { + public static String PLUGIN_ID = JavaCore.PLUGIN_ID; + + /** + * @noreference This method is not intended to be referenced by clients. + */ + public static void log(Throwable e) { + String msg= e.getMessage(); + if (msg == null) { + log("Error", e); //$NON-NLS-1$ + } else { + log("Error: " + msg, e); //$NON-NLS-1$ + } + } + + /** + * @noreference This method is not intended to be referenced by clients. + */ + public static void log(String message, Throwable e) { + log(createStatus(message, e)); + } + + /** + * @noreference This method is not intended to be referenced by clients. + */ + public static IStatus createStatus(String msg, Throwable e) { + return new Status(IStatus.ERROR, PLUGIN_ID, msg, e); + } + + /** + * @noreference This method is not intended to be referenced by clients. + */ + public static IStatus createStatus(String msg) { + return new Status(IStatus.ERROR, PLUGIN_ID, msg); + } + + /** + * @noreference This method is not intended to be referenced by clients. + * + * Returns the appropriate ILog for this package + */ + public static ILog getLog() { + Plugin plugin = JavaCore.getPlugin(); + if (plugin == null) { + return null; + } + return plugin.getLog(); + } + + /** + * @noreference This method is not intended to be referenced by clients. + */ + public static void log(IStatus status) { + getLog().log(status); + } +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/util/ResourceHelper.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/util/ResourceHelper.java new file mode 100644 index 000000000..5b2cd89eb --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/util/ResourceHelper.java @@ -0,0 +1,576 @@ +/******************************************************************************* + * Copyright (c) 2009, 2016 Andrew Gvozdev and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andrew Gvozdev - Initial API and implementation + * James Blackburn (Broadcom Corp.) + * Liviu Ionescu - bug 392416 + *******************************************************************************/ +package org.eclipse.jdt.core.tests.nd.util; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.charset.Charset; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.junit.Assert; + +/** + * This class contains utility methods for creating resources + * such as projects, files, folders etc. which are being used + * in test fixture of unit tests. + * + * Some classes with similar idea worth to look at: + * org.eclipse.core.filebuffers.tests.ResourceHelper, + * org.eclipse.cdt.ui.tests.text.ResourceHelper. + */ +public class ResourceHelper { + private final static IProgressMonitor NULL_MONITOR = new NullProgressMonitor(); + private static final int MAX_RETRY= 5; + + private final static Set<String> externalFilesCreated = new HashSet<String>(); + private final static Set<IResource> resourcesCreated = new HashSet<IResource>(); + + /** + * Creates a plain Eclipse project. + * + * @param projectName + * @return the project handle + * @throws CoreException if project could not be created + */ + public static IProject createProject(String projectName) throws CoreException { + IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); + IProject project= root.getProject(projectName); + if (!project.exists()) { + project.create(NULL_MONITOR); + } else { + project.refreshLocal(IResource.DEPTH_INFINITE, null); + } + + if (!project.isOpen()) + project.open(NULL_MONITOR); + + resourcesCreated.add(project); + return project; + } + + /** + * Deletes project by name. + * + * @param projectName + * @throws CoreException + */ + public static void deleteProject(String projectName) throws CoreException { + IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); + IProject project= root.getProject(projectName); + if (project.exists()) + delete(project); + } + + /** + * Deletes given project with content. + * + * @param project + * @throws CoreException + */ + public static void delete(final IProject project) throws CoreException { + delete(project, true); + } + + /** + * Deletes project. + * + * @param project + * @param deleteContent whether to delete project content + * @throws CoreException + */ + public static void delete(final IProject project, boolean deleteContent) throws CoreException { + for (int i= 0; i < MAX_RETRY; i++) { + try { + project.delete(deleteContent, true, NULL_MONITOR); + i= MAX_RETRY; + } catch (CoreException x) { + if (i == MAX_RETRY - 1) { + Package.log(x.getStatus()); + } + try { + Thread.sleep(1000); // sleep a second + } catch (InterruptedException e) { + } + } + } + } + + /** + * Creates a file with specified content. + * + * @param file - file name. + * @param contents - contents of the file. + * @return file handle. + * @throws CoreException - if the file can't be created. + */ + public static IFile createFile(IFile file, String contents) throws CoreException { + if (contents == null) { + contents= ""; + } + + InputStream inputStream = new ByteArrayInputStream(contents.getBytes()); + file.create(inputStream, true, NULL_MONITOR); + resourcesCreated.add(file); + return file; + } + + /** + * Creates new file from project root with empty content. The filename + * can include relative path as a part of the name but the the path + * has to be present on disk. + * + * @param project - project where to create the file. + * @param name - filename. + * @return file handle. + * @throws CoreException if something goes wrong. + */ + public static IFile createFile(IProject project, String name) throws CoreException { + if (new Path(name).segmentCount() > 1) + createFolder(project, new Path(name).removeLastSegments(1).toString()); + return createFile(project.getFile(name), null); + } + + /** + * Creates new file from workspace root with empty content. The filename + * can include relative path as a part of the name but the the path + * has to be present on disk. + * The intention of the method is to create files which do not belong to any project. + * + * @param name - filename. + * @return full path of the created file. + * + * @throws CoreException... + * @throws IOException... + */ + public static IPath createWorkspaceFile(String name) throws CoreException, IOException { + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + IPath fullPath = workspaceRoot.getLocation().append(name); + java.io.File file = new java.io.File(fullPath.toOSString()); + if (!file.exists()) { + boolean result = file.createNewFile(); + Assert.assertTrue(result); + } + Assert.assertTrue(file.exists()); + + externalFilesCreated.add(fullPath.toOSString()); + workspaceRoot.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); + return fullPath; + } + + /** + * Creates new folder from project root. The folder name + * can include relative path as a part of the name. + * Nonexistent parent directories are being created. + * + * @param project - project where to create the folder. + * @param name - folder name. + * @return folder handle. + * @throws CoreException if something goes wrong. + */ + public static IFolder createFolder(IProject project, String name) throws CoreException { + final IPath p = new Path(name); + IContainer folder = project; + for (String seg : p.segments()) { + folder = folder.getFolder(new Path(seg)); + if (!folder.exists()) + ((IFolder)folder).create(true, true, NULL_MONITOR); + } + resourcesCreated.add(folder); + return (IFolder)folder; + } + + /** + * Creates new folder from workspace root. The folder name + * can include relative path as a part of the name. + * Nonexistent parent directories are being created as per {@link File#mkdirs()}. + * The intention of the method is to create folders which do not belong to any project. + * + * @param name - folder name. + * @return absolute location of the folder on the file system. + * @throws IOException if something goes wrong. + */ + public static IPath createWorkspaceFolder(String name) throws CoreException, IOException { + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + IPath fullPath = workspaceRoot.getLocation().append(name); + java.io.File folder = new java.io.File(fullPath.toOSString()); + if (!folder.exists()) { + boolean result = folder.mkdirs(); + Assert.assertTrue(result); + } + Assert.assertTrue(folder.exists()); + + externalFilesCreated.add(fullPath.toOSString()); + workspaceRoot.refreshLocal(IResource.DEPTH_INFINITE, NULL_MONITOR); + return fullPath; + } + + /** + * Creates new temporary folder with generated name from workspace root. + * + * @return absolute location of the folder on the file system. + * @throws IOException if something goes wrong. + */ + public static IPath createTemporaryFolder() throws CoreException, IOException { + return ResourceHelper.createWorkspaceFolder("tmp/" + System.currentTimeMillis() + '.' + UUID.randomUUID()); + } + + /** + * Creates new eclipse file-link from project root to file system file. The filename + * can include relative path as a part of the name but the the path + * has to be present on disk. + * + * @param project - project where to create the file. + * @param fileLink - filename of the link being created. + * @param realFile - file on the file system, the target of the link. + * @return file handle. + * @throws CoreException if something goes wrong. + */ + public static IFile createLinkedFile(IProject project, String fileLink, IPath realFile) throws CoreException { + IFile file = project.getFile(fileLink); + file.createLink(realFile, IResource.REPLACE, null); + Assert.assertTrue(file.exists()); + resourcesCreated.add(file); + return file; + } + + /** + * Creates new eclipse file-link from project root to file system file. The filename + * can include relative path as a part of the name but the the path + * has to be present on disk. + * + * @param project - project where to create the file. + * @param fileLink - filename of the link being created. + * @param realFile - file on the file system, the target of the link. + * @return file handle. + * @throws CoreException if something goes wrong. + */ + public static IFile createLinkedFile(IProject project, String fileLink, String realFile) throws CoreException { + return createLinkedFile(project, fileLink, new Path(realFile)); + } + + /** + * Creates new eclipse file-link from project root to EFS file. + * + * @param project - project where to create the file. + * @param fileLink - filename of the link being created. + * @param realFile - file on the EFS file system, the target of the link. + * @return file handle. + * @throws CoreException if something goes wrong. + */ + public static IFile createEfsFile(IProject project, String fileLink, URI realFile) throws CoreException { + IFile file= project.getFile(fileLink); + file.createLink(realFile, IResource.ALLOW_MISSING_LOCAL, NULL_MONITOR); + resourcesCreated.add(file); + return file; + } + + /** + * Creates new eclipse file-link from project root to EFS file. + * + * @param project - project where to create the file. + * @param fileLink - filename of the link being created. + * @param realFile - file on the EFS file system, the target of the link. + * @return file handle. + * @throws CoreException if something goes wrong. + * @throws URISyntaxException if wrong URI syntax + */ + public static IFile createEfsFile(IProject project, String fileLink, String realFile) throws CoreException, URISyntaxException { + return createEfsFile(project,fileLink,new URI(realFile)); + } + + /** + * Creates new eclipse folder-link from project root to file system folder. The folder name + * can include relative path as a part of the name but the the path + * has to be present on disk. + * + * @param project - project where to create the file. + * @param folderLink - name of the link being created. + * @param realFolder - folder on the file system, the target of the link. + * @return file handle. + * @throws CoreException if something goes wrong. + */ + public static IFolder createLinkedFolder(IProject project, String folderLink, IPath realFolder) throws CoreException { + IFolder folder = project.getFolder(folderLink); + folder.createLink(realFolder, IResource.REPLACE | IResource.ALLOW_MISSING_LOCAL, null); + Assert.assertTrue(folder.exists()); + resourcesCreated.add(folder); + return folder; + } + + /** + * Creates new eclipse folder-link from project root to file system folder. The folder name + * can include relative path as a part of the name but the the path + * has to be present on disk. + * + * @param project - project where to create the file. + * @param folderLink - name of the link being created. + * @param realFolder - folder on the file system, the target of the link. + * @return file handle. + * @throws CoreException if something goes wrong. + */ + public static IFolder createLinkedFolder(IProject project, String folderLink, String realFolder) throws CoreException { + return createLinkedFolder(project, folderLink, new Path(realFolder)); + } + + /** + * Creates new eclipse folder-link from project root to EFS folder. + * + * @param project - project where to create the folder. + * @param folderLink - folder name of the link being created. + * @param realFolder - folder on the EFS file system, the target of the link. + * @return folder handle. + * @throws CoreException if something goes wrong. + */ + public static IFolder createEfsFolder(IProject project, String folderLink, URI realFolder) throws CoreException { + IFolder folder= project.getFolder(folderLink); + if (folder.exists()) { + Assert.assertEquals("Folder with the same name but different location already exists", + realFolder, folder.getLocationURI()); + return folder; + } + + folder.createLink(realFolder, IResource.ALLOW_MISSING_LOCAL, new NullProgressMonitor()); + resourcesCreated.add(folder); + return folder; + } + + /** + * Creates new eclipse folder-link from project root to EFS folder. + * + * @param project - project where to create the folder. + * @param folderLink - folder name of the link being created. + * @param realFolder - folder on the EFS file system, the target of the link. + * @return folder handle. + * @throws CoreException if something goes wrong. + * @throws URISyntaxException if wrong URI syntax + */ + public static IFolder createEfsFolder(IProject project, String folderLink, String realFolder) throws CoreException, URISyntaxException { + return createEfsFolder(project,folderLink,new URI(realFolder)); + } + + /** + * Checks if symbolic links are supported on the system. + * Used in particular by method {@link #createSymbolicLink(IPath, IPath)} + * and other flavors to create symbolic links. + * + * Note that Windows links .lnk are not supported here. + * @return {@code true} if symbolic links are suppoted, {@code false} otherwise. + */ + public static boolean isSymbolicLinkSupported() { + return ! Platform.getOS().equals(Platform.OS_WIN32); + } + + /** + * Creates new symbolic file system link from file or folder on project root + * to another file system file. The filename can include relative path + * as a part of the name but the the path has to be present on disk. + * + * @param project - project where to create the file. + * @param linkName - name of the link being created. + * @param realPath - file or folder on the file system, the target of the link. + * @return file handle. + * + * @throws UnsupportedOperationException on Windows where links are not supported. + * @throws IOException... + * @throws CoreException... + */ + public static IResource createSymbolicLink(IProject project, String linkName, IPath realPath) + throws IOException, CoreException, UnsupportedOperationException { + if (!isSymbolicLinkSupported()) { + throw new UnsupportedOperationException("Windows links .lnk are not supported."); + } + + Assert.assertTrue("Path for symbolic link does not exist: [" + realPath.toOSString() + "]", + new File(realPath.toOSString()).exists()); + + IPath linkedPath = project.getLocation().append(linkName); + createSymbolicLink(linkedPath, realPath); + + IResource resource = project.getFile(linkName); + resource.refreshLocal(IResource.DEPTH_ZERO, null); + + if (!resource.exists()) { + resource = project.getFolder(linkName); + resource.refreshLocal(IResource.DEPTH_ZERO, null); + } + Assert.assertTrue("Failed to create resource form symbolic link", resource.exists()); + + externalFilesCreated.add(linkedPath.toOSString()); + ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, NULL_MONITOR); + return resource; + } + + /** + * Creates new symbolic file system link from file or folder to another filesystem file. + * The target path has to be present on disk. + * + * @param linkPath - filesystem path of the link being created. + * @param realPath - file or folder on the file system, the target of the link. + * + * @throws UnsupportedOperationException on Windows where links are not supported. + * @throws IOException if execution of the command fails. + */ + public static void createSymbolicLink(IPath linkPath, IPath realPath) throws IOException { + if (!isSymbolicLinkSupported()) { + throw new UnsupportedOperationException("Windows links .lnk are not supported."); + } + + String command[] = { "ln", "-s", realPath.toOSString(), linkPath.toOSString()}; + Process process = Runtime.getRuntime().exec(command); + + // Wait for up to 2.5s... + for (int i = 0; i < 5; i++) { + try { + Assert.assertTrue("ln process exited with non-zero status", process.waitFor() == 0); + // If exitValue succeeded, then the process has exited successfully. + break; + } catch (InterruptedException e) { + // Clear interrupted state, see Java bug http://bugs.sun.com/view_bug.do?bug_id=6420270 + Thread.interrupted(); + } + // Wait for a 500ms before checking again. + try { Thread.sleep(500); } catch (InterruptedException e) {/*don't care*/} + } + Assert.assertTrue("Symbolic link not created, command=[" + command + "]", linkPath.toFile().exists()); + } + + /** + * Creates new symbolic file system link from file or folder on project root + * to another file system file. The filename can include relative path + * as a part of the name but the the path has to be present on disk. + * + * @param project - project where to create the file. + * @param linkName - name of the link being created. + * @param realPath - file or folder on the file system, the target of the link. + * @return file handle. + * + * @throws UnsupportedOperationException on Windows where links are not supported. + * @throws IOException... + * @throws CoreException... + */ + public static IResource createSymbolicLink(IProject project, String linkName, String realPath) + throws IOException, CoreException, UnsupportedOperationException { + return createSymbolicLink(project, linkName, new Path(realPath)); + } + + /** + * Get contents of file on file-system. + * + * @param fullPath - full path to the file on the file-system. + * @return contents of the file. + * @throws IOException on IO problem. + */ + public static String getContents(IPath fullPath) throws IOException { + FileInputStream stream = new FileInputStream(fullPath.toFile()); + try { + // Avoid using java.nio.channels.FileChannel, + // see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4715154 + Reader reader = new BufferedReader(new InputStreamReader(stream, Charset.defaultCharset())); + StringBuilder builder = new StringBuilder(); + char[] buffer = new char[8192]; + int read; + while ((read = reader.read(buffer, 0, buffer.length)) > 0) { + builder.append(buffer, 0, read); + } + return builder.toString(); + } finally { + stream.close(); + } + } + + /** + * Get contents of file on file-system. + * + * @param fullPath - full path to the file on the file-system. + * @return contents of the file. + * @throws IOException on IO problem. + */ + public static String getContents(String fullPath) throws IOException { + return getContents(new Path(fullPath)); + } + + /** + * Clean-up any files created as part of a unit test. + * This method removes *all* Workspace IResources and any external + * files / folders created with the #createWorkspaceFile #createWorkspaceFolder + * methods in this class + */ + public static void cleanUp() throws CoreException, IOException { + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + root.refreshLocal(IResource.DEPTH_INFINITE, NULL_MONITOR); + + // Delete all external files & folders created using ResourceHelper + for (String loc : externalFilesCreated) { + File f = new File(loc); + if (f.exists()) + deleteRecursive(f); + } + externalFilesCreated.clear(); + + // Remove IResources created by this helper + for (IResource r : resourcesCreated) { + if (r.exists()) { + try { + r.delete(true, NULL_MONITOR); + } catch (CoreException e) { + // Ignore + } + } + } + resourcesCreated.clear(); + } + + /** + * Recursively delete a directory / file + * + * For safety this method only deletes files created under the workspace + */ + private static final void deleteRecursive(File f) throws IllegalArgumentException { + // Ensure that the file being deleted is a child of the workspace + // root to prevent anything nasty happening + if (!f.getAbsolutePath().startsWith( + ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getAbsolutePath())) { + throw new IllegalArgumentException("File must exist within the workspace!"); + } + + if (f.isDirectory()) { + for (File f1 : f.listFiles()) { + deleteRecursive(f1); + } + } + f.delete(); + } +} |