From f040c09eb77b61b62871d12824721e3d8c38bade Mon Sep 17 00:00:00 2001 From: Stephan Herrmann Date: Tue, 5 Feb 2019 16:12:46 +0100 Subject: Bug 544017 - [9] bogus error in editor: "The type com.example.sub.b.B is not accessable." Change-Id: Idb1a5f043aa8a555454e16b3cfb60283e0b68e74 Signed-off-by: Stephan Herrmann --- .../org/eclipse/jdt/internal/compiler/lookup/BinaryModuleBinding.java | 2 +- .../org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryModuleBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryModuleBinding.java index 6c4cb11224..89cbe361a1 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryModuleBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryModuleBinding.java @@ -108,7 +108,7 @@ public class BinaryModuleBinding extends ModuleBinding { } // TODO(SHMOD): handle null case } - if (count < this.requiresTransitive.length) + if (count < this.requires.length) System.arraycopy(this.requires, 0, this.requires = new ModuleBinding[count], 0, count); if (transitiveCount < this.requiresTransitive.length) System.arraycopy(this.requiresTransitive, 0, this.requiresTransitive = new ModuleBinding[transitiveCount], 0, transitiveCount); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java index 0199eae16c..8993942d9b 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java @@ -213,7 +213,6 @@ void checkAndSetImports() { if (this.referenceContext.moduleDeclaration != null) { this.referenceContext.moduleDeclaration.resolveModuleDirectives(this); - this.referenceContext.moduleDeclaration.resolvePackageDirectives(this); } if (this.referenceContext.imports == null) { @@ -512,6 +511,7 @@ void faultInImports() { public void faultInTypes() { faultInImports(); if (this.referenceContext.moduleDeclaration != null) { + this.referenceContext.moduleDeclaration.resolvePackageDirectives(this); this.referenceContext.moduleDeclaration.resolveTypeDirectives(this); } else if (this.referenceContext.currentPackage != null) { this.referenceContext.currentPackage.checkPackageConflict(this); -- cgit v1.2.3 From f4c214a7a3a283cd92dfa31f14ee2ca73595fb7b Mon Sep 17 00:00:00 2001 From: Stephan Herrmann Date: Tue, 5 Feb 2019 18:17:01 +0100 Subject: Bug 544126 - Unable to build Apache Wicket project (The package org.apache.wicket is accessible from more than one module: wicket.core, wicket.request) Change-Id: I57f93471af8db75cf3628b10a3543092c59c7c11 Signed-off-by: Stephan Herrmann --- .../jdt/core/tests/model/ModuleBuilderTests.java | 55 ++++++++++++++++++++++ .../compiler/lookup/BinaryModuleBinding.java | 5 ++ .../internal/compiler/lookup/ModuleBinding.java | 7 +++ .../internal/compiler/lookup/PackageBinding.java | 4 +- .../jdt/internal/core/builder/ClasspathJar.java | 6 ++- 5 files changed, 73 insertions(+), 4 deletions(-) diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java index 9d0f5c80b1..1bd84d02b3 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java @@ -7939,6 +7939,61 @@ public class ModuleBuilderTests extends ModifyingResourceTests { } } + public void testBug544126() throws CoreException, IOException { + String outputDirectory = Util.getOutputDirectory(); + IJavaProject p = createJava9Project("p"); + try { + String jar1Path = outputDirectory + File.separator + "auto1Lib.jar"; + createJar( + new String[] { + "org/test/Root.java", + "package org.test;\n" + + "public class Root {}\n" + }, + jar1Path); + String jar2Path = outputDirectory + File.separator + "auto2Lib.jar"; + createJar( + new String[] { + "org/test/ext/Ext.java", + "package org.test.ext;\n" + + "public class Ext {}\n" + }, + jar2Path); + addModularLibraryEntry(p, new Path(jar1Path), null); + addModularLibraryEntry(p, new Path(jar2Path), null); + createFolder("p/src/test"); + String testPath = "p/src/test/Test.java"; + String testSource = + "package test;\n" + + "import org.test.Root;\n" + + "public class Test {\n" + + " public static void main(String[] args) { \n" + + " System.out.println(new Root());\n" + + " }\n" + + "}\n"; + createFile(testPath, testSource); + createFile("p/src/module-info.java", + "module test {\n" + + " requires auto1Lib;\n" + + " requires auto2Lib;\n" + + "}\n"); + getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null); + assertNoErrors(); + + this.problemRequestor.initialize(testSource.toCharArray()); + getCompilationUnit(testPath).getWorkingCopy(this.wcOwner, null); + assertProblems("unexpected problems", + "----------\n" + + "----------\n", + this.problemRequestor); + } finally { + deleteProject(p); + File outputDir = new File(outputDirectory); + if (outputDir.exists()) + Util.flushDirectoryContent(outputDir); + } + } + protected void assertNoErrors() throws CoreException { for (IProject p : getWorkspace().getRoot().getProjects()) { int maxSeverity = p.findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryModuleBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryModuleBinding.java index 89cbe361a1..080b8f8a89 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryModuleBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryModuleBinding.java @@ -61,6 +61,11 @@ public class BinaryModuleBinding extends ModuleBinding { public char[] nameForLookup() { return ANY_NAMED; } + + @Override + public char[] nameForCUCheck() { + return this.moduleName; + } } private IPackageExport[] unresolvedExports; diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java index 66e02b7a3c..44235199f0 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java @@ -442,6 +442,13 @@ public class ModuleBinding extends Binding implements IUpdatableModule { return this.moduleName; } + /** + * Answer the name of this module as it should be used for hasCompilationUnit() checks. + */ + public char[] nameForCUCheck() { + return nameForLookup(); + } + /** * Check if the specified package is owned by the current module and exported to the client module. * True if the package appears in the list of exported packages and when the export is targeted, diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java index 4054281c71..33a2218c93 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java @@ -442,13 +442,13 @@ public PackageBinding getVisibleFor(ModuleBinding module, boolean preferLocal) { public boolean hasCompilationUnit(boolean checkCUs) { if (this.knownTypes != null) { for (ReferenceBinding knownType : this.knownTypes.valueTable) { - if (knownType != null && knownType != LookupEnvironment.TheNotFoundType) + if (knownType != null && knownType != LookupEnvironment.TheNotFoundType && !knownType.isUnresolvedType()) return true; } } if (this.environment.useModuleSystem) { IModuleAwareNameEnvironment moduleEnv = (IModuleAwareNameEnvironment) this.environment.nameEnvironment; - return moduleEnv.hasCompilationUnit(this.compoundName, this.enclosingModule.nameForLookup(), checkCUs); + return moduleEnv.hasCompilationUnit(this.compoundName, this.enclosingModule.nameForCUCheck(), checkCUs); } return false; } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java index 592f193cfa..27c8f298b1 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -325,7 +325,9 @@ public boolean isPackage(String qualifiedPackageName, String moduleName) { public boolean hasCompilationUnit(String pkgName, String moduleName) { for (Enumeration e = this.zipFile.entries(); e.hasMoreElements(); ) { String fileName = e.nextElement().getName(); - if (fileName.startsWith(pkgName) && fileName.toLowerCase().endsWith(SuffixConstants.SUFFIX_STRING_class)) + if (fileName.startsWith(pkgName) + && fileName.toLowerCase().endsWith(SuffixConstants.SUFFIX_STRING_class) + && fileName.indexOf('/', pkgName.length()+1) == -1) return true; } return false; -- cgit v1.2.3 From bcec7451e941decddf86ddcdbe87a1f9b59eec30 Mon Sep 17 00:00:00 2001 From: Stephan Herrmann Date: Tue, 5 Feb 2019 22:31:28 +0100 Subject: Bug 540846 - [regression] Cannot infer type argument(s) for map(Function Change-Id: I340a5e402d319615f21623cd6492ba4037078bd4 Signed-off-by: Stephan Herrmann --- .../regression/GenericsRegressionTest_1_8.java | 27 ++++++++++++++++++++++ .../jdt/core/tests/model/ModuleBuilderTests.java | 10 ++++++-- .../internal/compiler/ast/ModuleDeclaration.java | 1 + .../compiler/lookup/IntersectionTypeBinding18.java | 23 +++++++++++++++++- 4 files changed, 58 insertions(+), 3 deletions(-) diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java index 1979b4bbdd..4bf0b94b6e 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java @@ -9485,4 +9485,31 @@ public void testBug508834_comment0() { }; runner.runConformTest(); } + public void testBug540846() { + Runner runner = new Runner(); + runner.testFiles = new String[] { + "Test.java", + "import java.util.*;\n" + + "import java.util.stream.*;\n" + + "import java.math.*;\n" + + "\n" + + "public class Test {\n" + + " private List getRowValues(Map record, Stream factors) {\n" + + " return Stream.concat(\n" + + " factors.map(f -> {\n" + + " if (f.equals(\"x\")) {\n" + + " return record.get(f);\n" + + " } else {\n" + + " return \"NM\";\n" + + " }\n" + + " }),\n" + + " Stream.of(BigDecimal.ONE)\n" + + " )\n" + + " .map(v -> (v instanceof BigDecimal) ? ((BigDecimal) v).setScale(10, BigDecimal.ROUND_HALF_UP) : v)\n" + + " .collect(Collectors.toList());\n" + + " }\n" + + "}\n" + }; + runner.runConformTest(); + } } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java index 1bd84d02b3..8242823b45 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java @@ -4401,6 +4401,12 @@ public class ModuleBuilderTests extends ModifyingResourceTests { IClasspathEntry dep = JavaCore.newProjectEntry(p1.getPath(), null, false, new IClasspathAttribute[] {modAttr}, false); IJavaProject p2 = setupModuleProject("com.greetings", src, new IClasspathEntry[] {dep}); getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null); + IMarker[] markers = p2.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE); + sortMarkers(markers); + assertMarkers("markers on com.greetings", + "The package bundle.org conflicts with a package accessible from another module: org.astro", + markers); + src = new String[] { "src/module-info.java", "module test {\n" + @@ -4420,8 +4426,8 @@ public class ModuleBuilderTests extends ModifyingResourceTests { }; IClasspathEntry dep2 = JavaCore.newProjectEntry(p2.getPath(), null, false, new IClasspathAttribute[] {modAttr}, false); IJavaProject p3 = setupModuleProject("test", src, new IClasspathEntry[] {dep, dep2}); - getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null); - IMarker[] markers = p3.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE); + p3.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null); + markers = p3.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE); assertMarkers("Unexpected markers", "", markers); } finally { this.deleteProject("test"); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java index c81cf482ef..2a2aa534f1 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java @@ -301,6 +301,7 @@ public class ModuleDeclaration extends ASTNode implements ReferenceContext { Map> pack2mods = new HashMap<>(); for (ModuleBinding requiredModule : this.binding.getAllRequiredModules()) { for (PackageBinding exportedPackage : requiredModule.getExports()) { + exportedPackage = exportedPackage.getVisibleFor(requiredModule, true); if (this.binding.canAccess(exportedPackage)) { String packName = String.valueOf(exportedPackage.readableName()); Set mods = pack2mods.get(packName); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/IntersectionTypeBinding18.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/IntersectionTypeBinding18.java index ce262d4ad0..649ff04324 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/IntersectionTypeBinding18.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/IntersectionTypeBinding18.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -217,6 +217,27 @@ public class IntersectionTypeBinding18 extends ReferenceBinding { public boolean isSubtypeOf(TypeBinding other, boolean simulatingBugJDK8026527) { if (TypeBinding.equalsEquals(this, other)) return true; + if (other instanceof ReferenceBinding) { + TypeBinding[] rightIntersectingTypes = ((ReferenceBinding) other).getIntersectingTypes(); + if (rightIntersectingTypes != null && rightIntersectingTypes.length > 1) { + int numRequired = rightIntersectingTypes.length; + TypeBinding[] required = new TypeBinding[numRequired]; + System.arraycopy(rightIntersectingTypes, 0, required, 0, numRequired); + for (int i = 0; i < this.length; i++) { + TypeBinding provided = this.intersectingTypes[i]; + for (int j = 0; j < required.length; j++) { + if (required[j] == null) continue; + if (provided.isSubtypeOf(required[j], simulatingBugJDK8026527)) { + required[j] = null; + if (--numRequired == 0) + return true; + break; + } + } + } + return false; + } + } for (int i = 0; i < this.intersectingTypes.length; i++) { if (this.intersectingTypes[i].isSubtypeOf(other, false)) return true; -- cgit v1.2.3 From 56c7200f17bcd06f03618a81316a7dbfe1d7dcf8 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Thu, 24 Jan 2019 15:44:07 -0500 Subject: Bug 543727 - False positive "Unnecessary cast" - change EqualExpression.resolveType() to add additional check before reporting an unnecessary cast if one side is parameterized and the other is a cast of a base type that may be compatible with parameterized type when boxed - add test to CastTest Change-Id: I9e3e1be9a0d42965dba9c8dbf629171248d0b26b Signed-off-by: Jeff Johnston --- .../core/tests/compiler/regression/CastTest.java | 50 +++++++++++++++++++++- .../jdt/internal/compiler/ast/EqualExpression.java | 27 +++++++++--- 2 files changed, 71 insertions(+), 6 deletions(-) diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java index e723cdbad6..e0e23ca878 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2017 IBM Corporation and others. + * Copyright (c) 2003, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -3297,6 +3297,54 @@ public void testAnonymous_bug520727() { runConformTest(source,""); } } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=543727 False positive "Unnecessary cast" +public void test543727() { + if (this.complianceLevel < ClassFileConstants.JDK1_7) + return; + Map customOptions = getCompilerOptions(); + customOptions.put(CompilerOptions.OPTION_ReportUnnecessaryTypeCheck, CompilerOptions.ERROR); + this.runConformTest( + new String[] { + "Bug.java", + "import java.util.ArrayList;\n" + + "import java.util.List;\n" + + "public class Bug {\n" + + " public static int main(String[] args) {\n" + + " List> vector = new ArrayList<>();\n" + + " vector.add(0);\n" + + " if (vector.get(0) == (Integer)0) {\n" + + " System.out.print(\"SUCCESS\");\n" + + " }\n" + + " return 0;\n" + + " }" + + "}\n", + }, + "SUCCESS"); +} +public void test543727_notequals() { + if (this.complianceLevel < ClassFileConstants.JDK1_7) + return; + Map customOptions = getCompilerOptions(); + customOptions.put(CompilerOptions.OPTION_ReportUnnecessaryTypeCheck, CompilerOptions.ERROR); + this.runConformTest( + new String[] { + "Bug.java", + "import java.util.ArrayList;\n" + + "import java.util.List;\n" + + "public class Bug {\n" + + " public static int main(String[] args) {\n" + + " List> vector = new ArrayList<>();\n" + + " vector.add(0);\n" + + " if (vector.get(0) != (Integer)1) {\n" + + " System.out.print(\"SUCCESS\");\n" + + " }\n" + + " return 0;\n" + + " }" + + "}\n", + }, + "SUCCESS"); +} + public static Class testClass() { return CastTest.class; } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java index c3bbd55075..bdf1ed81fe 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -936,10 +936,13 @@ public class EqualExpression extends BinaryExpression { if (unnecessaryLeftCast || unnecessaryRightCast) { TypeBinding alternateLeftType = unnecessaryLeftCast ? ((CastExpression)this.left).expression.resolvedType : leftType; TypeBinding alternateRightType = unnecessaryRightCast ? ((CastExpression)this.right).expression.resolvedType : rightType; - if (checkCastTypesCompatibility(scope, alternateLeftType, alternateRightType, null) - || checkCastTypesCompatibility(scope, alternateRightType, alternateLeftType, null)) { - if (unnecessaryLeftCast) scope.problemReporter().unnecessaryCast((CastExpression)this.left); - if (unnecessaryRightCast) scope.problemReporter().unnecessaryCast((CastExpression)this.right); + // Bug 543727 - check if either cast is really needed + if (!isCastNeeded(alternateLeftType, alternateRightType)) { + if (checkCastTypesCompatibility(scope, alternateLeftType, alternateRightType, null) + || checkCastTypesCompatibility(scope, alternateRightType, alternateLeftType, null)) { + if (unnecessaryLeftCast) scope.problemReporter().unnecessaryCast((CastExpression)this.left); + if (unnecessaryRightCast) scope.problemReporter().unnecessaryCast((CastExpression)this.right); + } } } // check whether comparing identical expressions @@ -955,6 +958,20 @@ public class EqualExpression extends BinaryExpression { scope.problemReporter().notCompatibleTypesError(this, leftType, rightType); return null; } + + private boolean isCastNeeded(TypeBinding leftType, TypeBinding rightType) { + // Bug 543727 - if either type is parameterized and the other is a base type, + // a cast is necessary, even if boxing the base type will result in a compatible + // type. + if (leftType.isParameterizedType()) { + return rightType.isBaseType(); + } + if (rightType.isParameterizedType()) { + return leftType.isBaseType(); + } + return false; + } + @Override public void traverse(ASTVisitor visitor, BlockScope scope) { if (visitor.visit(this, scope)) { -- cgit v1.2.3 From a9d77143a860475b4d660573eefc303be09d98f4 Mon Sep 17 00:00:00 2001 From: Stephan Herrmann Date: Thu, 7 Feb 2019 21:54:48 +0100 Subject: Bug 538192 - [1.8][compiler] Eclipse IDE compiler error (lambda), using io.cucumber.datatable.DataTableType Change-Id: I3af5f99587f34fdcbff08c5d1635115b382a159c Signed-off-by: Stephan Herrmann --- .../regression/GenericsRegressionTest_1_8.java | 20 ++++++++++++++++++++ .../jdt/internal/compiler/ast/LambdaExpression.java | 2 ++ 2 files changed, 22 insertions(+) diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java index 4bf0b94b6e..c57ea95c8e 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java @@ -9512,4 +9512,24 @@ public void testBug508834_comment0() { }; runner.runConformTest(); } + public void testBug538192() { + Runner runner = new Runner(); + runner.testFiles = new String[] { + "Test.java", + "import java.util.*;\n" + + "import java.util.function.Function;\n" + + "interface ListFunc extends Function, T> {}\n" + + "interface MapFunc extends Function, T> {}\n" + + "class DTT {\n" + + " public DTT(Class c, ListFunc f) {}\n" + + " public DTT(Class c, MapFunc f) {} \n" + + "}\n" + + "public class Test {\n" + + " void test() {\n" + + " new DTT(Integer.class, (Map row) -> Integer.valueOf(0));\n" + + " }\n" + + "}\n" + }; + runner.runConformTest(); + } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java index 08067d8306..b252d45f42 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java @@ -481,6 +481,8 @@ public class LambdaExpression extends FunctionalExpression implements IPolyExpre if (expected.isParameterizedType() && argument.isParameterizedType()) { TypeBinding[] expectedArgs = ((ParameterizedTypeBinding)expected).typeArguments(); TypeBinding[] args = ((ParameterizedTypeBinding)argument).typeArguments(); + if (args.length != expectedArgs.length) + return false; for (int j = 0; j < args.length; j++) { if (TypeBinding.notEquals(expectedArgs[j], args[j])) { if (expectedArgs[j].isWildcard() && args[j].isUnboundWildcard()) { -- cgit v1.2.3 From 17b1fb45e126edc8664ffdb798fb882faf8e102f Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Tue, 22 Jan 2019 15:39:12 -0500 Subject: Bug 496354 - Code completion for annotation parms should insert "=" - modify CompletionEngine.findAnnotationAttributes to add "=" to completion and add spaces before and after based on project code formatting settings - add new test case to CompletionTests - modify CompletionTest3, CompletionTests9, and CompletionTests_1_5 Change-Id: Id77352f3014fab869b95f30d53ea3d3e01619ce7 Signed-off-by: Jeff Johnston --- .../jdt/core/tests/model/CompletionTests.java | 36 ++++++ .../jdt/core/tests/model/CompletionTests3.java | 6 +- .../jdt/core/tests/model/CompletionTests9.java | 2 +- .../jdt/core/tests/model/CompletionTests_1_5.java | 128 ++++++++++----------- .../jdt/internal/codeassist/CompletionEngine.java | 15 ++- 5 files changed, 117 insertions(+), 70 deletions(-) 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 118f3c6287..304d2120df 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 @@ -35,6 +35,7 @@ import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.Signature; import org.eclipse.jdt.core.eval.IEvaluationContext; +import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.jdt.internal.codeassist.CompletionEngine; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.core.eval.EvaluationContextWrapper; @@ -25887,4 +25888,39 @@ public void testBug533740d() throws JavaModelException { "super[KEYWORD]{super, null, null, super, null, 51}", requestor.getResults()); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=496354 +public void testBug496354() throws Exception { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "Completion/src/Foo.java", + "package test;\n" + + "import java.io.IOException;\n" + + "import java.lang.annotation.ElementType;\n" + + "import java.lang.annotation.Target;\n" + + "import java.util.ArrayList;\n" + + "@Target(ElementType.METHOD)\n" + + "@interface T {\n" + + " int val1() default 1;\n" + + " int val2() default -1;\n" + + "}\n" + + "public class Foo {\n" + + " @T()\n" + + " public int add(int x, int y) {\n" + + " return x + y;\n" + + " };\n" + + "}\n"); + + COMPLETION_PROJECT.setOption(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, ""); + COMPLETION_PROJECT.setOption(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, ""); + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.allowAllRequiredProposals(); + String str = this.workingCopies[0].getSource(); + String completeBehind = "@T("; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + assertResults( + "val1[ANNOTATION_ATTRIBUTE_REF]{val1=, LT;, I, val1, null, 52}\n" + + "val2[ANNOTATION_ATTRIBUTE_REF]{val2=, LT;, I, val2, null, 52}", + requestor.getResults()); +} } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests3.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests3.java index 45025486f1..77022c605f 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests3.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests3.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017 IBM Corporation and others. + * Copyright (c) 2017, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -185,7 +185,7 @@ public void testBug425035a() throws CoreException { this.workingCopies[2].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( "Test[TYPE_REF]{Test, b, Lb.Test;, null, null, 52}\n" + - "value[ANNOTATION_ATTRIBUTE_REF]{value, La.Annotation;, [La.Values;, value, null, 52}\n" + + "value[ANNOTATION_ATTRIBUTE_REF]{value = , La.Annotation;, [La.Values;, value, null, 52}\n" + "Values[TYPE_REF]{a.Values, a, La.Values;, null, null, 99}\n" + "OTHER_VALUE[FIELD_REF]{Values.OTHER_VALUE, La.Values;, La.Values;, OTHER_VALUE, null, 104}\n" + "SOME_VALUE[FIELD_REF]{Values.SOME_VALUE, La.Values;, La.Values;, SOME_VALUE, null, 104}", @@ -431,7 +431,7 @@ public void testBug425035_method_a() throws CoreException { assertResults( "Test[TYPE_REF]{Test, b, Lb.Test;, null, null, 52}\n" + "i[FIELD_REF]{i, Lb.Test;, I, i, null, 52}\n" + - "value[ANNOTATION_ATTRIBUTE_REF]{value, La.Annotation;, [La.Values;, value, null, 52}\n" + + "value[ANNOTATION_ATTRIBUTE_REF]{value = , La.Annotation;, [La.Values;, value, null, 52}\n" + "Values[TYPE_REF]{a.Values, a, La.Values;, null, null, 99}\n" + "OTHER_VALUE[FIELD_REF]{Values.OTHER_VALUE, La.Values;, La.Values;, OTHER_VALUE, null, 104}\n" + "SOME_VALUE[FIELD_REF]{Values.SOME_VALUE, La.Values;, La.Values;, SOME_VALUE, null, 104}", diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests9.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests9.java index b9fc44645b..0fc84e4d81 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests9.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests9.java @@ -1578,7 +1578,7 @@ public void testBug530911() throws Exception { unit.codeComplete(cursorLocation, requestor); String expected = "NonNull[TYPE_REF]{NonNull, p, Lp.NonNull;, null, 52}\n" + - "value[ANNOTATION_ATTRIBUTE_REF]{value, Ljava.lang.annotation.Target;, [Ljava.lang.annotation.ElementType;, value, 52}\n" + + "value[ANNOTATION_ATTRIBUTE_REF]{value = , Ljava.lang.annotation.Target;, [Ljava.lang.annotation.ElementType;, value, 52}\n" + "ElementType[TYPE_REF]{ElementType, java.lang.annotation, Ljava.lang.annotation.ElementType;, null, 102}\n" + "ANNOTATION_TYPE[FIELD_REF]{ElementType.ANNOTATION_TYPE, Ljava.lang.annotation.ElementType;, Ljava.lang.annotation.ElementType;, ANNOTATION_TYPE, 104}\n" + "CONSTRUCTOR[FIELD_REF]{ElementType.CONSTRUCTOR, Ljava.lang.annotation.ElementType;, Ljava.lang.annotation.ElementType;, CONSTRUCTOR, 104}\n" + 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 b6be9e6fe1..2aa1dccdfb 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, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -2455,7 +2455,7 @@ public void test0088() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0088.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0088.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0089() throws JavaModelException { @@ -2478,7 +2478,7 @@ public void test0089() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0089.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0089.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0090() throws JavaModelException { @@ -2501,7 +2501,7 @@ public void test0090() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0090.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0090.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0091() throws JavaModelException { @@ -2526,7 +2526,7 @@ public void test0091() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0091.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0091.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0092() throws JavaModelException { @@ -2549,7 +2549,7 @@ public void test0092() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0092.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0092.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0093() throws JavaModelException { @@ -2573,7 +2573,7 @@ public void test0093() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0093.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0093.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0094() throws JavaModelException { @@ -2595,7 +2595,7 @@ public void test0094() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0094.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0094.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0095() throws JavaModelException { @@ -2618,7 +2618,7 @@ public void test0095() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0095.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0095.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0096() throws JavaModelException { @@ -2641,7 +2641,7 @@ public void test0096() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0096.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0096.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0097() throws JavaModelException { @@ -2666,7 +2666,7 @@ public void test0097() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0097.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0097.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0098() throws JavaModelException { @@ -2689,7 +2689,7 @@ public void test0098() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0098.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0098.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0099() throws JavaModelException { @@ -2713,7 +2713,7 @@ public void test0099() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0099.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0099.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0100() throws JavaModelException { @@ -2735,7 +2735,7 @@ public void test0100() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0100.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0100.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0101() throws JavaModelException { @@ -2758,7 +2758,7 @@ public void test0101() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0101.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0101.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0102() throws JavaModelException { @@ -2781,7 +2781,7 @@ public void test0102() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0102.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0102.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0103() throws JavaModelException { @@ -2806,7 +2806,7 @@ public void test0103() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0103.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0103.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0104() throws JavaModelException { @@ -2829,7 +2829,7 @@ public void test0104() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0104.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0104.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0105() throws JavaModelException { @@ -2853,7 +2853,7 @@ public void test0105() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0105.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0105.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0106() throws JavaModelException { @@ -2875,7 +2875,7 @@ public void test0106() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0106.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0106.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0107() throws JavaModelException { @@ -2898,7 +2898,7 @@ public void test0107() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0107.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0107.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0108() throws JavaModelException { @@ -2921,7 +2921,7 @@ public void test0108() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0108.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0108.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0109() throws JavaModelException { @@ -2946,7 +2946,7 @@ public void test0109() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0109.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0109.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0110() throws JavaModelException { @@ -2969,7 +2969,7 @@ public void test0110() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0110.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0110.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0111() throws JavaModelException { @@ -2993,7 +2993,7 @@ public void test0111() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0111.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0111.TestAnnotation;, Ljava.lang.String;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0112() throws JavaModelException { @@ -3016,7 +3016,7 @@ public void test0112() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0112.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0112.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0113() throws JavaModelException { @@ -3040,7 +3040,7 @@ public void test0113() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0113.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0113.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0114() throws JavaModelException { @@ -3064,7 +3064,7 @@ public void test0114() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0114.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0114.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0115() throws JavaModelException { @@ -3090,7 +3090,7 @@ public void test0115() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0115.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0115.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0116() throws JavaModelException { @@ -3114,7 +3114,7 @@ public void test0116() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0116.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0116.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0117() throws JavaModelException { @@ -3139,7 +3139,7 @@ public void test0117() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0117.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0117.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0118() throws JavaModelException { @@ -3162,7 +3162,7 @@ public void test0118() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0118.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0118.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0119() throws JavaModelException { @@ -3186,7 +3186,7 @@ public void test0119() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0119.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0119.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0120() throws JavaModelException { @@ -3210,7 +3210,7 @@ public void test0120() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0120.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0120.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0121() throws JavaModelException { @@ -3236,7 +3236,7 @@ public void test0121() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0121.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0121.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0122() throws JavaModelException { @@ -3260,7 +3260,7 @@ public void test0122() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0122.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0122.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0123() throws JavaModelException { @@ -3285,7 +3285,7 @@ public void test0123() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0123.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0123.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0124() throws JavaModelException { @@ -3308,7 +3308,7 @@ public void test0124() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0124.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0124.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0125() throws JavaModelException { @@ -3332,7 +3332,7 @@ public void test0125() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0125.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0125.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0126() throws JavaModelException { @@ -3356,7 +3356,7 @@ public void test0126() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0126.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0126.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0127() throws JavaModelException { @@ -3382,7 +3382,7 @@ public void test0127() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0127.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0127.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0128() throws JavaModelException { @@ -3406,7 +3406,7 @@ public void test0128() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0128.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0128.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0129() throws JavaModelException { @@ -3431,7 +3431,7 @@ public void test0129() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0129.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0129.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0130() throws JavaModelException { @@ -3454,7 +3454,7 @@ public void test0130() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0130.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0130.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0131() throws JavaModelException { @@ -3478,7 +3478,7 @@ public void test0131() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0131.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0131.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0132() throws JavaModelException { @@ -3502,7 +3502,7 @@ public void test0132() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0132.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0132.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0133() throws JavaModelException { @@ -3528,7 +3528,7 @@ public void test0133() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0133.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0133.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0134() throws JavaModelException { @@ -3552,7 +3552,7 @@ public void test0134() throws JavaModelException { this.wc.codeComplete(cursorLocation, requestor); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0134.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0134.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", requestor.getResults()); } public void test0135() throws JavaModelException { @@ -3571,7 +3571,7 @@ public void test0135() throws JavaModelException { "foo"); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0135.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0135.TestAnnotation;, Ljava.lang.String;, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}", result.proposals); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=84554 @@ -6219,8 +6219,8 @@ public void test0196b() throws JavaModelException { result.context); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0196.ZZAnnot;, I, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0196.ZZAnnot;, I, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0196.ZZAnnot;, I, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0196.ZZAnnot;, I, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", result.proposals); } public void test0197() throws JavaModelException { @@ -6266,8 +6266,8 @@ public void test0197b() throws JavaModelException { result.context); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0197.ZZAnnot;, I, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0197.ZZAnnot;, I, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0197.ZZAnnot;, I, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0197.ZZAnnot;, I, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", result.proposals); } public void test0198() throws JavaModelException { @@ -6313,8 +6313,8 @@ public void test0198b() throws JavaModelException { result.context); assertResults( - "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1, Ltest0198.ZZAnnot;, I, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0198.ZZAnnot;, I, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", + "foo1[ANNOTATION_ATTRIBUTE_REF]{foo1 = , Ltest0198.ZZAnnot;, I, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0198.ZZAnnot;, I, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", result.proposals); } public void test0199() throws JavaModelException { @@ -6358,7 +6358,7 @@ public void test0199b() throws JavaModelException { result.context); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0199.ZZAnnot;, I, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0199.ZZAnnot;, I, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", result.proposals); } public void test0200() throws JavaModelException { @@ -6404,7 +6404,7 @@ public void test0200b() throws JavaModelException { result.context); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0200.ZZAnnot;, I, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0200.ZZAnnot;, I, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", result.proposals); } public void test0201() throws JavaModelException { @@ -6450,7 +6450,7 @@ public void test0201b() throws JavaModelException { result.context); assertResults( - "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2, Ltest0201.ZZAnnot;, I, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", + "foo2[ANNOTATION_ATTRIBUTE_REF]{foo2 = , Ltest0201.ZZAnnot;, I, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", result.proposals); } public void test0202() throws JavaModelException { @@ -8080,8 +8080,8 @@ public void test0260() throws JavaModelException { this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "oneTwoThree[ANNOTATION_ATTRIBUTE_REF]{oneTwoThree, Lcamelcase.Annot;, Ljava.lang.String;, oneTwoThree, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CAMEL_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + - "oTTAttribute[ANNOTATION_ATTRIBUTE_REF]{oTTAttribute, Lcamelcase.Annot;, Ljava.lang.String;, oTTAttribute, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", + "oneTwoThree[ANNOTATION_ATTRIBUTE_REF]{oneTwoThree = , Lcamelcase.Annot;, Ljava.lang.String;, oneTwoThree, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CAMEL_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + + "oTTAttribute[ANNOTATION_ATTRIBUTE_REF]{oTTAttribute = , Lcamelcase.Annot;, Ljava.lang.String;, oTTAttribute, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", requestor.getResults()); } finally { JavaCore.setOptions(this.oldOptions); @@ -13894,9 +13894,9 @@ public void testBug343865a() throws JavaModelException { cu.codeComplete(cursorLocation, requestor); assertResults( - "name[ANNOTATION_ATTRIBUTE_REF]{name, Ltestxxx.YAAnnot;, Ljava.lang.String;, name, null, " + + "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, " + + "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()); } @@ -14558,7 +14558,7 @@ public void testBug526590() throws JavaModelException { assertResults( "Bug526590[TYPE_REF]{Bug526590, testbug526590, Ltestbug526590.Bug526590;, null, null, 52}\n" + - "value[ANNOTATION_ATTRIBUTE_REF]{value, Ltestbug526590.QQAnnotation;, [Ljava.lang.String;, value, null, 52}\n" + + "value[ANNOTATION_ATTRIBUTE_REF]{value = , Ltestbug526590.QQAnnotation;, [Ljava.lang.String;, value, null, 52}\n" + "String[TYPE_REF]{String, java.lang, Ljava.lang.String;, null, null, 82}", requestor.getResults()); } @@ -14590,7 +14590,7 @@ public void testBug526590b() throws JavaModelException { assertResults( "Bug526590[TYPE_REF]{Bug526590, testbug526590, Ltestbug526590.Bug526590;, null, null, 52}\n" + - "value[ANNOTATION_ATTRIBUTE_REF]{value, Ltestbug526590.QQAnnotation;, [Ljava.lang.String;, value, null, 52}\n" + + "value[ANNOTATION_ATTRIBUTE_REF]{value = , Ltestbug526590.QQAnnotation;, [Ljava.lang.String;, value, null, 52}\n" + "String[TYPE_REF]{String, java.lang, Ljava.lang.String;, null, null, 82}", requestor.getResults()); } diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java index 099d883256..a25328f3e7 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java @@ -26,6 +26,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Locale; import java.util.Map; + import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; @@ -50,6 +51,7 @@ import org.eclipse.jdt.core.WorkingCopyOwner; import org.eclipse.jdt.core.compiler.CategorizedProblem; import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.core.compiler.IProblem; +import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.jdt.core.search.IJavaSearchConstants; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; @@ -57,9 +59,9 @@ import org.eclipse.jdt.core.search.SearchMatch; import org.eclipse.jdt.core.search.SearchParticipant; import org.eclipse.jdt.core.search.SearchPattern; import org.eclipse.jdt.core.search.SearchRequestor; +import org.eclipse.jdt.internal.codeassist.complete.AssistNodeParentAnnotationArrayInitializer; import org.eclipse.jdt.internal.codeassist.complete.CompletionNodeDetector; import org.eclipse.jdt.internal.codeassist.complete.CompletionNodeFound; -import org.eclipse.jdt.internal.codeassist.complete.AssistNodeParentAnnotationArrayInitializer; import org.eclipse.jdt.internal.codeassist.complete.CompletionOnAnnotationOfType; import org.eclipse.jdt.internal.codeassist.complete.CompletionOnArgumentName; import org.eclipse.jdt.internal.codeassist.complete.CompletionOnBranchStatementLabel; @@ -5313,7 +5315,16 @@ public final class CompletionEngine proposal.setDeclarationSignature(getSignature(method.declaringClass)); proposal.setSignature(getSignature(method.returnType)); proposal.setName(method.selector); - proposal.setCompletion(method.selector); + // add "=" to completion since it will always be needed + char[] completion= method.selector; + if (JavaCore.INSERT.equals(this.javaProject.getOption(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, true))) { + completion= CharOperation.concat(completion, new char[] {' '}); + } + completion= CharOperation.concat(completion, new char[] {'='}); + if (JavaCore.INSERT.equals(this.javaProject.getOption(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, true))) { + completion= CharOperation.concat(completion, new char[] {' '}); + } + proposal.setCompletion(completion); proposal.setFlags(method.modifiers); proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); -- cgit v1.2.3 From 18baae4ac007703438f2e33f74d619dae2cf177f Mon Sep 17 00:00:00 2001 From: Stephan Herrmann Date: Sat, 9 Feb 2019 13:25:56 +0100 Subject: Bug 404648 - [1.8][compiler] investigate differences between ECJ & Javac Signed-off-by: Stephan Herrmann --- .../regression/AbstractRegressionTest.java | 7 +-- .../core/tests/compiler/regression/CastTest.java | 66 +++++++++++----------- 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java index 9473d14de8..bdbc45a2aa 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java @@ -919,7 +919,9 @@ protected static class JavacTestOptions { JavacBug8044196 = RUN_JAVAC ? // likely https://bugs.openjdk.java.net/browse/JDK-8044196, intermittently masked by https://bugs.openjdk.java.net/browse/JDK-8029161 new JavacHasABug(MismatchType.EclipseErrorsJavacNone, ClassFileConstants.JDK9, 0000, true) : null, JavacBug6337964 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=112433 - new JavacHasABug(MismatchType.JavacErrorsEclipseNone, ClassFileConstants.JDK1_6, 1045/*guessed*/, true) : null; + new JavacHasABug(MismatchType.JavacErrorsEclipseNone, ClassFileConstants.JDK1_6, 1045/*guessed*/, true) : null, + JavacBug8144832 = RUN_JAVAC ? // https://bugs.openjdk.java.net/browse/JDK-8144832 + new JavacHasABug(MismatchType.JavacErrorsEclipseNone, ClassFileConstants.JDK9, 0000) : null; // bugs that have been fixed but that we've not identified public static JavacHasABug @@ -941,9 +943,6 @@ protected static class JavacTestOptions { ClassFileConstants.JDK9, 0100 /* 9.0.1 or better */) : null; // bugs that have neither been fixed nor formally identified but which outcomes are obvious enough to clear any doubts public static JavacHasABug - JavacGeneratesByteCodeUponWhichJavaThrowsAnException = RUN_JAVAC ? - new JavacHasABug( - MismatchType.StandardOutputMismatch) : null, JavacThrowsAnException = RUN_JAVAC ? // some of these are transient - that is, depend on the system on which the test is run, aka stack overflow new JavacHasABug( MismatchType.JavacErrorsEclipseNone) : null, diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java index e0e23ca878..5deac455aa 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java @@ -21,6 +21,7 @@ import java.util.Map; import junit.framework.Test; import org.eclipse.jdt.core.ToolFactory; +import org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.JavacTestOptions.Excuse; import org.eclipse.jdt.core.tests.util.Util; import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; @@ -1497,7 +1498,7 @@ public void test036() { "no base" /* expected output string */, "" /* expected error string */, // javac options - JavacTestOptions.JavacHasABug.JavacGeneratesByteCodeUponWhichJavaThrowsAnException /* javac test options */); + JavacTestOptions.JavacHasABug.JavacBugFixed_7 /* javac test options */); } public void test037() { this.runNegativeTest( @@ -1828,7 +1829,8 @@ public void test048() { public void test049() { CompilerOptions options = new CompilerOptions(getCompilerOptions()); if (options.sourceLevel < ClassFileConstants.JDK1_5) return; - this.runNegativeTest( + Runner runner = new Runner(); + runner.testFiles = new String[] { "A.java", "public class A {\n" + @@ -1844,14 +1846,18 @@ public void test049() { " class Member2 extends Other.Member {\n" + " }\n" + "}\n" - }, + }; + runner.expectedCompilerLog = "----------\n" + "1. WARNING in A.java (at line 3)\n" + " Other.Member m = (Other.Member) om2;\n" + " ^^^^^^^^^^^^^^^^^^^^^\n" + "Unnecessary cast from Other2.Member2 to Other.Member\n" + - "----------\n" - ); + "----------\n"; + runner.javacTestOptions = + Excuse.EclipseHasSomeMoreWarnings; // javac is inconsistent: accepting both assignments, not issuing a warning though in simpler cases it does + // note that javac 1.6 doesn't even accept the syntax of this cast + runner.runWarningTest(); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=302919 public void test050() { @@ -2521,7 +2527,9 @@ public void testBug428274() { public void testBug428274b() { if (this.complianceLevel < ClassFileConstants.JDK1_5) return; // uses generics - String source = + Runner runner = new Runner(); + runner.testFiles = new String[] { + "Junk4.java", "public class Junk4 {\n" + " void setValue(T n) {\n" + " int rounded = (int) Math.round((double) n);\n" + @@ -2532,26 +2540,22 @@ public void testBug428274b() { " j.setValue(Double.valueOf(3.3));\n" + " j.setValue(Double.valueOf(3.7));\n" + " }\n" + - "}\n"; + "}\n" + }; if (this.complianceLevel < ClassFileConstants.JDK1_7) { - runNegativeTest( - new String[] { - "Junk4.java", - source - }, + runner.expectedCompilerLog = "----------\n" + "1. ERROR in Junk4.java (at line 3)\n" + " int rounded = (int) Math.round((double) n);\n" + " ^^^^^^^^^^\n" + "Cannot cast from T to double\n" + - "----------\n"); + "----------\n"; + runner.runNegativeTest(); } else { - runConformTest( - new String[] { - "Junk4.java", - source - }, - "3\n4"); + runner.expectedOutputString = + "3\n4"; + runner.javacTestOptions = JavacTestOptions.JavacHasABug.JavacBug8144832; + runner.runConformTest(); } } // note: spec allows all reference types, but neither javac nor common sense accept arrays :) @@ -3232,9 +3236,10 @@ public void test461706() { public void test461706a() { if (this.complianceLevel < ClassFileConstants.JDK1_8) return; - Map customOptions = getCompilerOptions(); - customOptions.put(CompilerOptions.OPTION_ReportUnnecessaryTypeCheck, CompilerOptions.ERROR); - this.runNegativeTest( + Runner runner = new Runner(); + runner.customOptions = getCompilerOptions(); + runner.customOptions.put(CompilerOptions.OPTION_ReportUnnecessaryTypeCheck, CompilerOptions.WARNING); + runner.testFiles = new String[] { "Bug.java", "import java.util.ArrayList;\n" + @@ -3261,16 +3266,15 @@ public void test461706a() { " .orElse(ICondition.TRUE);\n" + " }\n" + "}" - }, + }; + runner.expectedCompilerLog = "----------\n" + - "1. ERROR in Bug.java (at line 20)\n" + + "1. WARNING in Bug.java (at line 20)\n" + " .map(x -> (ICondition)x)\n" + " ^^^^^^^^^^^^^\n" + "Unnecessary cast from Bug.ICondition to Bug.ICondition\n" + - "----------\n", - null, - true, - customOptions); + "----------\n"; + runner.runWarningTest(); } public void testAnonymous_bug520727() { String[] source = { @@ -3309,13 +3313,12 @@ public void test543727() { "import java.util.ArrayList;\n" + "import java.util.List;\n" + "public class Bug {\n" + - " public static int main(String[] args) {\n" + + " public static void main(String[] args) {\n" + " List> vector = new ArrayList<>();\n" + " vector.add(0);\n" + " if (vector.get(0) == (Integer)0) {\n" + " System.out.print(\"SUCCESS\");\n" + " }\n" + - " return 0;\n" + " }" + "}\n", }, @@ -3332,13 +3335,12 @@ public void test543727_notequals() { "import java.util.ArrayList;\n" + "import java.util.List;\n" + "public class Bug {\n" + - " public static int main(String[] args) {\n" + + " public static void main(String[] args) {\n" + " List> vector = new ArrayList<>();\n" + " vector.add(0);\n" + " if (vector.get(0) != (Integer)1) {\n" + " System.out.print(\"SUCCESS\");\n" + " }\n" + - " return 0;\n" + " }" + "}\n", }, -- cgit v1.2.3 From c0a450d6d478972de7ffb4ec43ebd4a908dfbbbc Mon Sep 17 00:00:00 2001 From: Stephan Herrmann Date: Sun, 10 Feb 2019 11:35:48 +0100 Subject: Bug 395051 - Access restriction on method invocation: error range too big Change-Id: I533f832054f79ee59b31e902bcfe466be62bf517 Signed-off-by: Stephan Herrmann --- .../compiler/regression/BatchCompilerTest.java | 16 ++++----- .../core/tests/model/AccessRestrictionsTests.java | 42 +++++++++++----------- .../eclipse/jdt/internal/compiler/ast/ASTNode.java | 6 ++-- .../compiler/ast/AllocationExpression.java | 10 +++++- .../compiler/ast/ExplicitConstructorCall.java | 4 +-- .../compiler/ast/JavadocAllocationExpression.java | 4 +-- .../internal/compiler/ast/JavadocMessageSend.java | 4 +-- .../jdt/internal/compiler/ast/MessageSend.java | 12 +++++-- .../ast/QualifiedAllocationExpression.java | 4 +-- .../internal/compiler/ast/ReferenceExpression.java | 4 +-- .../internal/compiler/lookup/InvocationSite.java | 4 ++- .../internal/compiler/problem/ProblemReporter.java | 10 +++--- .../eval/CodeSnippetAllocationExpression.java | 4 +-- .../jdt/internal/eval/CodeSnippetMessageSend.java | 4 +-- 14 files changed, 73 insertions(+), 55 deletions(-) diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java index ca1357961d..030401eee6 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -2527,13 +2527,13 @@ public void test039(){ "----------\n" + "4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/src2/Y.java (at line 4)\n" + " X x2 = new X();\n" + - " ^^^^^^^^^^^^^^^\n" + - "Discouraged access: The constructor \'X()\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---/bin1\')\n" + + " ^\n" + + "Discouraged access: The type \'X\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---/bin1\')\n" + "----------\n" + "5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/src2/Y.java (at line 4)\n" + " X x2 = new X();\n" + " ^\n" + - "Discouraged access: The type \'X\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---/bin1\')\n" + + "Discouraged access: The constructor \'X()\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---/bin1\')\n" + "----------\n" + "5 problems (5 warnings)\n", false); @@ -5331,17 +5331,17 @@ public void test148_access_restrictions(){ "----------\n" + "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + " ko = new KO();\n" + - " ^^^^^^^^\n" + - "Access restriction: The constructor \'KO()\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" + + " ^^\n" + + "Access restriction: The type \'KO\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" + "----------\n" + "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + " ko = new KO();\n" + " ^^\n" + - "Access restriction: The type \'KO\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" + + "Access restriction: The constructor \'KO()\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" + "----------\n" + "4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 6)\n" + " ko.bar();\n" + - " ^^^^^^^^\n" + + " ^^^\n" + "Access restriction: The method \'KO.bar()\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" + "----------\n" + "5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 7)\n" + diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java index 59b37f6f23..994a526d58 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java @@ -167,7 +167,7 @@ public void test001() throws CoreException { "----------\n" + "1. ERROR in /P2/src/p/Y.java (at line 4)\n" + " foo(); // accesses X1.foo, should trigger an error\n" + - " ^^^^^\n" + + " ^^^\n" + "Access restriction: The method \'X1.foo()\' is not API (restriction on required project \'P1\')\n" + "----------\n" ); @@ -352,7 +352,7 @@ public void test003() throws CoreException { "----------\n" + "3. ERROR in /P2/src/p/Y.java (at line 6)\n" + " foo(); // error\n" + - " ^^^^^\n" + + " ^^^\n" + "Access restriction: The method \'X1.C1.foo()\' is not API (restriction on required project \'P1\')\n" + "----------\n" + "4. ERROR in /P2/src/p/Y.java (at line 11)\n" + @@ -362,13 +362,13 @@ public void test003() throws CoreException { "----------\n" + "5. ERROR in /P2/src/p/Y.java (at line 12)\n" + " new C1(0); // error\n" + - " ^^^^^^^^^\n" + - "Access restriction: The constructor \'X1.C1(int)\' is not API (restriction on required project \'P1\')\n" + + " ^^\n" + + "Access restriction: The type \'X1.C1\' is not API (restriction on required project \'P1\')\n" + "----------\n" + "6. ERROR in /P2/src/p/Y.java (at line 12)\n" + " new C1(0); // error\n" + " ^^\n" + - "Access restriction: The type \'X1.C1\' is not API (restriction on required project \'P1\')\n" + + "Access restriction: The constructor \'X1.C1(int)\' is not API (restriction on required project \'P1\')\n" + "----------\n" ); } finally { @@ -531,7 +531,7 @@ public void test005() throws CoreException { "----------\n" + "1. ERROR in /P2/src/r/Y.java (at line 4)\n" + " (new q.X2()).foo(); // accesses p.X1#foo, should trigger an error\n" + - " ^^^^^^^^^^^^^^^^^^\n" + + " ^^^\n" + "Access restriction: The method \'X1.foo()\' is not API (restriction on required project \'P1\')\n" + "----------\n" ); @@ -617,13 +617,13 @@ public void test006() throws CoreException { "----------\n" + "3. ERROR in /P2/src/p/Y.java (at line 4)\n" + " X x2 = new X();\n" + - " ^^^^^^^^^^^^^^^\n" + - "Access restriction: The constructor \'X()\' is not API (restriction on required project \'P1\')\n" + + " ^\n" + + "Access restriction: The type \'X\' is not API (restriction on required project \'P1\')\n" + "----------\n" + "4. ERROR in /P2/src/p/Y.java (at line 4)\n" + " X x2 = new X();\n" + " ^\n" + - "Access restriction: The type \'X\' is not API (restriction on required project \'P1\')\n" + + "Access restriction: The constructor \'X()\' is not API (restriction on required project \'P1\')\n" + "----------\n"); } finally { if (x != null) { @@ -709,13 +709,13 @@ public void test007() throws CoreException { "----------\n" + "3. ERROR in /P2/src/p/Y.java (at line 4)\n" + " X x2 = new X(\"\");\n" + - " ^^^^^^^^^^^^^^^^^\n" + - "Access restriction: The constructor \'X(String)\' is not API (restriction on required project \'P1\')\n" + + " ^\n" + + "Access restriction: The type \'X\' is not API (restriction on required project \'P1\')\n" + "----------\n" + "4. ERROR in /P2/src/p/Y.java (at line 4)\n" + " X x2 = new X(\"\");\n" + " ^\n" + - "Access restriction: The type \'X\' is not API (restriction on required project \'P1\')\n" + + "Access restriction: The constructor \'X(String)\' is not API (restriction on required project \'P1\')\n" + "----------\n"); } finally { if (x != null) { @@ -800,7 +800,7 @@ public void test008() throws CoreException { "----------\n" + "1. ERROR in /P2/src/p/Y.java (at line 4)\n" + " foo(); // accesses X1.foo, should trigger an error\n" + - " ^^^^^\n" + + " ^^^\n" + "Access restriction: The method \'X1.foo()\' is not API (restriction on required project \'P1\')\n" + "----------\n" ); @@ -996,7 +996,7 @@ public void test010() throws CoreException { "----------\n" + "3. ERROR in /P2/src/p/Y.java (at line 6)\n" + " foo(); // error\n" + - " ^^^^^\n" + + " ^^^\n" + "Access restriction: The method \'X1.C1.foo()\' is not API (restriction on required project \'P1\')\n" + "----------\n" + "4. ERROR in /P2/src/p/Y.java (at line 11)\n" + @@ -1006,13 +1006,13 @@ public void test010() throws CoreException { "----------\n" + "5. ERROR in /P2/src/p/Y.java (at line 12)\n" + " new C1(0); // error\n" + - " ^^^^^^^^^\n" + - "Access restriction: The constructor \'X1.C1(int)\' is not API (restriction on required project \'P1\')\n" + + " ^^\n" + + "Access restriction: The type \'X1.C1\' is not API (restriction on required project \'P1\')\n" + "----------\n" + "6. ERROR in /P2/src/p/Y.java (at line 12)\n" + " new C1(0); // error\n" + " ^^\n" + - "Access restriction: The type \'X1.C1\' is not API (restriction on required project \'P1\')\n" + + "Access restriction: The constructor \'X1.C1(int)\' is not API (restriction on required project \'P1\')\n" + "----------\n" ); } finally { @@ -1070,17 +1070,17 @@ public void test011() throws CoreException { "----------\n" + "2. ERROR in /P1/src/q/Y.java (at line 4)\n" + " p.X x = new p.X();\n" + - " ^^^^^^^^^\n" + - "Access restriction: The constructor \'X()\' is not API (restriction on required library \'AccessRestrictions/lib.jar\')\n" + + " ^^^\n" + + "Access restriction: The type \'X\' is not API (restriction on required library \'AccessRestrictions/lib.jar\')\n" + "----------\n" + "3. ERROR in /P1/src/q/Y.java (at line 4)\n" + " p.X x = new p.X();\n" + " ^^^\n" + - "Access restriction: The type \'X\' is not API (restriction on required library \'AccessRestrictions/lib.jar\')\n" + + "Access restriction: The constructor \'X()\' is not API (restriction on required library \'AccessRestrictions/lib.jar\')\n" + "----------\n" + "4. ERROR in /P1/src/q/Y.java (at line 5)\n" + " x.foo();\n" + - " ^^^^^^^\n" + + " ^^^\n" + "Access restriction: The method \'X.foo()\' is not API (restriction on required library \'AccessRestrictions/lib.jar\')\n" + "----------\n" + "5. ERROR in /P1/src/q/Y.java (at line 6)\n" + diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java index 50391b4520..78b31ccf23 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -513,7 +513,7 @@ public abstract class ASTNode implements TypeConstants, TypeIds { * An access in the same compilation unit is allowed. */ public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope, - boolean isExplicitUse) { + boolean isExplicitUse, InvocationSite invocation) { // ignore references insing Javadoc comments if ((this.bits & ASTNode.InsideJavadoc) == 0 && method.isOrEnclosedByPrivateType() && !scope.isDefinedInMethod(method)) { // ignore cases where method is used from inside itself (e.g. direct recursions) @@ -530,7 +530,7 @@ public abstract class ASTNode implements TypeConstants, TypeIds { AccessRestriction restriction = env.getAccessRestriction(method.declaringClass.erasure()); if (restriction != null) { - scope.problemReporter().forbiddenReference(method, this, + scope.problemReporter().forbiddenReference(method, invocation, restriction.classpathEntryType, restriction.classpathEntryName, restriction.getProblemId()); } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java index 7710fcfdee..d53c24f175 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java @@ -503,7 +503,7 @@ public TypeBinding resolveType(BlockScope scope) { if ((this.binding.tagBits & TagBits.HasMissingType) != 0) { scope.problemReporter().missingTypeInConstructor(this, this.binding); } - if (isMethodUseDeprecated(this.binding, scope, true)) { + if (isMethodUseDeprecated(this.binding, scope, true, this)) { scope.problemReporter().deprecatedMethod(this.binding, this); } if (checkInvocationArguments(scope, null, this.resolvedType, this.binding, this.arguments, this.argumentTypes, this.argsContainCast, this)) { @@ -809,4 +809,12 @@ public ExpressionContext getExpressionContext() { public InferenceContext18 freshInferenceContext(Scope scope) { return new InferenceContext18(scope, this.arguments, this, this.outerInferenceContext); } +@Override +public int nameSourceStart() { + return this.type.sourceStart; +} +@Override +public int nameSourceEnd() { + return this.type.sourceEnd; +} } \ No newline at end of file diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java index 0553640750..de4fc80b4d 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -446,7 +446,7 @@ public class ExplicitConstructorCall extends Statement implements Invocation { scope.problemReporter().missingTypeInConstructor(this, this.binding); } } - if (isMethodUseDeprecated(this.binding, scope, this.accessMode != ExplicitConstructorCall.ImplicitSuper)) { + if (isMethodUseDeprecated(this.binding, scope, this.accessMode != ExplicitConstructorCall.ImplicitSuper, this)) { scope.problemReporter().deprecatedMethod(this.binding, this); } if (checkInvocationArguments(scope, null, receiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this)) { diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java index 7b69cf564b..d0c1c6d56a 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -144,7 +144,7 @@ public class JavadocAllocationExpression extends AllocationExpression { } } } - if (isMethodUseDeprecated(this.binding, scope, true)) { + if (isMethodUseDeprecated(this.binding, scope, true, this)) { scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getDeclarationModifiers()); } return allocationType; diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java index a1988de9bf..4fdc64dc71 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -172,7 +172,7 @@ public class JavadocMessageSend extends MessageSend { } } } - if (isMethodUseDeprecated(this.binding, scope, true)) { + if (isMethodUseDeprecated(this.binding, scope, true, this)) { scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getDeclarationModifiers()); } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java index 2421cfb906..2e52f5a05e 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -898,7 +898,7 @@ public TypeBinding resolveType(BlockScope scope) { } // abstract private methods cannot occur nor abstract static............ } - if (isMethodUseDeprecated(this.binding, scope, true)) + if (isMethodUseDeprecated(this.binding, scope, true, this)) scope.problemReporter().deprecatedMethod(this.binding, this); TypeBinding returnType; @@ -1171,4 +1171,12 @@ public InferenceContext18 freshInferenceContext(Scope scope) { public boolean isQualifiedSuper() { return this.receiver.isQualifiedSuper(); } +@Override +public int nameSourceStart() { + return (int) (this.nameSourcePosition >>> 32); +} +@Override +public int nameSourceEnd() { + return (int) this.nameSourcePosition; +} } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java index bed5d38c3f..bd4ba12a44 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -561,7 +561,7 @@ public class QualifiedAllocationExpression extends AllocationExpression { ReferenceBinding receiver = (ReferenceBinding) receiverType; ReferenceBinding superType = receiver.isInterface() ? scope.getJavaLangObject() : receiver; if (constructorBinding.isValidBinding()) { - if (isMethodUseDeprecated(constructorBinding, scope, true)) { + if (isMethodUseDeprecated(constructorBinding, scope, true, this)) { scope.problemReporter().deprecatedMethod(constructorBinding, this); } if (checkInvocationArguments(scope, null, superType, constructorBinding, this.arguments, diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java index c7e4eb8909..d6d044c7a5 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -799,7 +799,7 @@ public class ReferenceExpression extends FunctionalExpression implements IPolyEx srcMethod.bits &= ~ASTNode.CanBeStatic; } - if (isMethodUseDeprecated(this.binding, scope, true)) + if (isMethodUseDeprecated(this.binding, scope, true, this)) scope.problemReporter().deprecatedMethod(this.binding, this); if (this.typeArguments != null && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES) diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java index 8513fed83b..aa57e1214e 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -34,6 +34,8 @@ public interface InvocationSite { void setFieldIndex(int depth); int sourceEnd(); int sourceStart(); + default int nameSourceStart() { return sourceStart(); } + default int nameSourceEnd() { return sourceEnd(); } TypeBinding invocationTargetType(); boolean receiverIsImplicitThis(); boolean checkingPotentialCompatibility(); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java index a4db767ee5..1a47e1d8c2 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java @@ -2453,7 +2453,7 @@ public void forbiddenReference(FieldBinding field, ASTNode location, } /** @param classpathEntryType one of {@link AccessRestriction#COMMAND_LINE}, * {@link AccessRestriction#LIBRARY}, {@link AccessRestriction#PROJECT} */ -public void forbiddenReference(MethodBinding method, ASTNode location, +public void forbiddenReference(MethodBinding method, InvocationSite location, byte classpathEntryType, String classpathEntryName, int problemId) { int severity = computeSeverity(problemId); if (severity == ProblemSeverities.Ignore) return; @@ -2466,8 +2466,8 @@ public void forbiddenReference(MethodBinding method, ASTNode location, classpathEntryName, new String(method.shortReadableName())}, severity, - location.sourceStart, - location.sourceEnd); + location.nameSourceStart(), + location.nameSourceEnd()); else this.handle( problemId, @@ -2478,8 +2478,8 @@ public void forbiddenReference(MethodBinding method, ASTNode location, new String(method.shortReadableName()), new String(method.declaringClass.shortReadableName())}, severity, - location.sourceStart, - location.sourceEnd); + location.nameSourceStart(), + location.nameSourceEnd()); } /** @param classpathEntryType one of {@link AccessRestriction#COMMAND_LINE}, * {@link AccessRestriction#LIBRARY}, {@link AccessRestriction#PROJECT} */ diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java index 2de2f1abcf..1536b4faf0 100644 --- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java +++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -279,7 +279,7 @@ public TypeBinding resolveType(BlockScope scope) { return this.resolvedType; } } - if (isMethodUseDeprecated(this.binding, scope, true)) { + if (isMethodUseDeprecated(this.binding, scope, true, this)) { scope.problemReporter().deprecatedMethod(this.binding, this); } if (this.arguments != null) { diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java index 98d1f8631c..9a00586b24 100644 --- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java +++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -337,7 +337,7 @@ public TypeBinding resolveType(BlockScope scope) { } // abstract private methods cannot occur nor abstract static............ } - if (isMethodUseDeprecated(this.binding, scope, true)) + if (isMethodUseDeprecated(this.binding, scope, true, this)) scope.problemReporter().deprecatedMethod(this.binding, this); // from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object) -- cgit v1.2.3 From 7411c5d64b4f841347cb94c0ae326a6cb0df5581 Mon Sep 17 00:00:00 2001 From: Stephan Herrmann Date: Wed, 13 Feb 2019 00:09:45 +0100 Subject: Bug 544017 - [9] bogus error in editor: "The type com.example.sub.b.B is not accessable." Change-Id: I8f395c4ccb270c7c86d2016761221095f1d94dec Signed-off-by: Stephan Herrmann --- .../core/tests/model/AbstractJavaModelTests.java | 9 +++ .../jdt/core/tests/model/ModuleBuilderTests.java | 7 -- .../jdt/core/tests/model/ReconcilerTests9.java | 79 ++++++++++++++++++++++ .../internal/compiler/lookup/ModuleBinding.java | 11 ++- 4 files changed, 96 insertions(+), 10 deletions(-) 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 755fbfc24a..df6e565b35 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 @@ -620,6 +620,15 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases { exported); addClasspathEntry(project, entry); } + + protected void addModularProjectEntry(IJavaProject project, IJavaProject depProject) throws JavaModelException { + addClasspathEntry(project, newModularProjectEntry(depProject)); + } + + protected IClasspathEntry newModularProjectEntry(IJavaProject depProject) { + return JavaCore.newProjectEntry(depProject.getPath(), null, false, moduleAttribute(), false); + } + protected void assertSortedElementsEqual(String message, String expected, IJavaElement[] elements) { sortElements(elements); assertElementsEqual(message, expected, elements); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java index 8242823b45..725f615ff1 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java @@ -41,7 +41,6 @@ import org.eclipse.jdt.core.IModuleDescription; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.IProblemRequestor; import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.WorkingCopyOwner; import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.CompilationUnit; @@ -103,12 +102,6 @@ public class ModuleBuilderTests extends ModifyingResourceTests { deleteProject("P1"); } - void addModularProjectEntry(IJavaProject project, IJavaProject depProject) throws JavaModelException { - addClasspathEntry(project, newModularProjectEntry(depProject)); - } - IClasspathEntry newModularProjectEntry(IJavaProject depProject) { - return JavaCore.newProjectEntry(depProject.getPath(), null, false, moduleAttribute(), false); - } // Test that the java.base found as a module package fragment root in the project public void test001() throws CoreException { try { diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java index 16166b5a8d..7c7f99d85c 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java @@ -570,4 +570,83 @@ public void testBug543092b() throws Exception { deleteProject(p); } } +public void testBug544017() throws CoreException { + if (!isJRE9) { + System.err.println("Test "+getName()+" requires a JRE 9"); + return; + } + IJavaProject testa = createJava9Project("testa"); + IJavaProject testb = createJava9Project("testb"); + IJavaProject testmain = createJava9Project("testmain"); + try { + createFolder("testb/src/com/example/sub/b"); + createFile("testb/src/com/example/sub/b/B.java", + "package com.example.sub.b;\n" + + "public class B {\n" + + " public static void main(String[] args) {\n" + + " System.out.println(\"B\");\n" + + " }\n" + + "}\n"); + createFile("testb/src/module-info.java", + "open module com.example.sub.b {\n" + + " exports com.example.sub.b;\n" + + "}\n"); + + addModularProjectEntry(testa, testb); + createFolder("testa/src/com/example/sub/a"); + createFile("testa/src/com/example/sub/a/A.java", + "package com.example.sub.a;\n" + + "public class A {\n" + + " public static void main(String[] args) {\n" + + " System.out.println(\"A\");\n" + + " }\n" + + "}\n"); + createFile("testa/src/module-info.java", + "open module com.example.sub.a {\n" + + " exports com.example.sub.a;\n" + + " requires com.example.sub.b;\n" + + "}\n"); + + addModularProjectEntry(testmain, testa); + addModularProjectEntry(testmain, testb); + createFolder("testmain/src/com/example"); + createFile("testmain/src/module-info.java", + "open module com.example {\n" + + " requires com.example.sub.a;\n" + + " requires com.example.sub.b;\n" + + "}\n"); + String pathExample = "testmain/src/com/example/Example.java"; + String sourceExample = + "package com.example;\n" + + "import com.example.sub.a.A;\n" + + "import com.example.sub.b.B;\n" + + "\n" + + "public class Example {\n" + + " public static void main(String[] args) {\n" + + " A.main(null);\n" + + " B.main(null);\n" + + " }\n" + + "}\n"; + createFile(pathExample, sourceExample); + + getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null); + IMarker[] markers = testmain.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE); + assertMarkers("markers in testmain", + "", + markers); + + ICompilationUnit wc = getCompilationUnit(pathExample).getWorkingCopy(this.wcOwner, null); + wc.getBuffer().append(" "); + this.problemRequestor.initialize((sourceExample+" ").toCharArray()); + wc.reconcile(AST_INTERNAL_JLS11, true, this.wcOwner, null); + assertProblems("Expecting no problems", + "----------\n" + + "----------\n", + this.problemRequestor); + } finally { + deleteProject(testa); + deleteProject(testb); + deleteProject(testmain); + } +} } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java index 44235199f0..32df973735 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java @@ -513,7 +513,7 @@ public class ModuleBinding extends Binding implements IUpdatableModule { // remember: if (binding != null) { this.environment.knownPackages.put(name, binding); - binding = addPackage(binding, false); + binding = addPackage(binding, false); // no further lookup needed, binding is already complete (split?) } else { this.environment.knownPackages.put(name, LookupEnvironment.TheNotFoundPackage); } @@ -595,6 +595,8 @@ public class ModuleBinding extends Binding implements IUpdatableModule { // enrich with split-siblings from visible modules: if (considerRequiredModules) { + if (parent != null && binding != null) + parent.addPackage(binding, this); // preliminarily add to avoid creating duplicates, will be updated below binding = combineWithPackagesFromOtherRelevantModules(binding, subPkgCompoundName, declaringModuleNames); } if (binding == null || !binding.isValidBinding()) { @@ -607,10 +609,13 @@ public class ModuleBinding extends Binding implements IUpdatableModule { return null; } // remember - if (parentName.length == 0) + if (parentName.length == 0) { binding.environment.knownPackages.put(name, binding); - else if (parent != null) + } else if (parent != null) { binding = parent.addPackage(binding, this); + } + if (packageMayBeIncomplete) + return binding; return addPackage(binding, false); } -- cgit v1.2.3 From d72112c8968b4b1fb650450aadf69127448ef933 Mon Sep 17 00:00:00 2001 From: Vikas Chandra Date: Mon, 11 Feb 2019 09:46:22 +0530 Subject: Bug 543996 - [11][javadoc] Support all javadoc tags in module documentation Change-Id: Ie0358004fcefd9fab47ef08ad973f456bf26c65b Signed-off-by: Vikas Chandra --- .../parser/JavadocCompletionParserTest.java | 21 ++++++++--- .../jdt/internal/codeassist/CompletionEngine.java | 41 +++++++++++++++++++++- .../complete/CompletionOnJavadocTag.java | 6 +++- .../internal/compiler/parser/JavadocParser.java | 14 ++++++-- .../compiler/parser/JavadocTagConstants.java | 26 ++++++++++++-- 5 files changed, 97 insertions(+), 11 deletions(-) diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/JavadocCompletionParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/JavadocCompletionParserTest.java index 677874c917..a12ef9f626 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/JavadocCompletionParserTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/JavadocCompletionParserTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -159,6 +159,7 @@ protected void verifyCompletionOnJavadocTag(char[] tag, char[][] expectedTags, b } protected void verifyAllTagsCompletion() { + char[][] allTagsFinal =null; char[][] allTags = { // Block tags TAG_AUTHOR, TAG_DEPRECATED, TAG_EXCEPTION, TAG_PARAM, TAG_RETURN, TAG_SEE, TAG_VERSION, TAG_CATEGORY, @@ -168,6 +169,15 @@ protected void verifyAllTagsCompletion() { TAG_LINK, TAG_DOC_ROOT, }; + char[][] allTagsJava9Plus = { + // Block tags + TAG_AUTHOR, TAG_DEPRECATED, TAG_EXCEPTION, TAG_PARAM, TAG_RETURN, TAG_SEE, TAG_VERSION, TAG_CATEGORY, + TAG_SINCE, + TAG_SERIAL, TAG_SERIAL_DATA, TAG_SERIAL_FIELD , TAG_THROWS, TAG_USES, TAG_PROVIDES, + // Inline tags + TAG_LINK, + TAG_DOC_ROOT + }; char[][] additionalTags = null; if(this.complianceLevel == ClassFileConstants.JDK1_4) { additionalTags = new char[][] { @@ -179,13 +189,14 @@ protected void verifyAllTagsCompletion() { TAG_CODE, TAG_LITERAL }; } + allTagsFinal = this.complianceLevel > ClassFileConstants.JDK1_8 ? allTagsJava9Plus : allTags; if (additionalTags != null) { - int length = allTags.length; + int length = allTagsFinal.length; int add = additionalTags.length; - System.arraycopy(allTags, 0, allTags = new char[length+add][], 0, length); - System.arraycopy(additionalTags, 0, allTags, length, add); + System.arraycopy(allTagsFinal, 0, allTagsFinal = new char[length+add][], 0, length); + System.arraycopy(additionalTags, 0, allTagsFinal, length, add); } - verifyCompletionOnJavadocTag(null, allTags, false); + verifyCompletionOnJavadocTag(null, allTagsFinal, false); } /** diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java index a25328f3e7..ba6cc119a2 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java @@ -60,6 +60,7 @@ import org.eclipse.jdt.core.search.SearchParticipant; import org.eclipse.jdt.core.search.SearchPattern; import org.eclipse.jdt.core.search.SearchRequestor; import org.eclipse.jdt.internal.codeassist.complete.AssistNodeParentAnnotationArrayInitializer; +import org.eclipse.jdt.internal.codeassist.complete.CompletionJavadoc; import org.eclipse.jdt.internal.codeassist.complete.CompletionNodeDetector; import org.eclipse.jdt.internal.codeassist.complete.CompletionNodeFound; import org.eclipse.jdt.internal.codeassist.complete.CompletionOnAnnotationOfType; @@ -2236,7 +2237,8 @@ public final class CompletionEngine } } } - + // javadoc tag completion in module-info file + contextAccepted = completeJavadocTagInModuleInfo(parsedUnit); if (parsedUnit.types != null) { try { this.lookupEnvironment.buildTypeBindings(parsedUnit, null /*no access restriction*/); @@ -2339,6 +2341,43 @@ public final class CompletionEngine } } + private boolean completeJavadocTagInModuleInfo(CompilationUnitDeclaration parsedUnit) { + boolean contextAccepted = false; + if (this.parser.assistNodeParent instanceof CompletionJavadoc && parsedUnit.isModuleInfo() ) { + try { + this.lookupEnvironment.buildTypeBindings(parsedUnit, null /*no access restriction*/); + if(this.parser.assistNode instanceof CompletionOnJavadocTag) { + ((CompletionOnJavadocTag)this.parser.assistNode).filterPossibleTags(parsedUnit.scope); + } + throw new CompletionNodeFound(this.parser.assistNode, null, parsedUnit.scope); + } + catch (CompletionNodeFound e) { + if (e.astNode != null) { + // if null then we found a problem in the completion node + if(DEBUG) { + System.out.print("COMPLETION - Completion node : "); //$NON-NLS-1$ + System.out.println(e.astNode.toString()); + if(this.parser.assistNodeParent != null) { + System.out.print("COMPLETION - Parent Node : "); //$NON-NLS-1$ + System.out.println(this.parser.assistNodeParent); + } + } + this.lookupEnvironment.unitBeingCompleted = parsedUnit; // better resilient to further error reporting + contextAccepted = + complete( + e.astNode, + this.parser.assistNodeParent, + this.parser.enclosingNode, + parsedUnit, + e.qualifiedBinding, + e.scope, + e.insideTypeAnnotation); + } + } + } + return contextAccepted; + } + private boolean checkForCNF(TypeReference ref, CompilationUnitDeclaration parsedUnit, boolean showAll) { this.lookupEnvironment.buildTypeBindings(parsedUnit, null); this.lookupEnvironment.completeTypeBindings(parsedUnit, true); diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnJavadocTag.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnJavadocTag.java index 15215c711d..b620240aec 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnJavadocTag.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnJavadocTag.java @@ -86,8 +86,12 @@ public class CompletionOnJavadocTag extends JavadocSingleNameReference implement switch (kind) { case Scope.COMPILATION_UNIT_SCOPE: // bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=255752 - // Check for FAKE_TYPE_NAME to allow proposals (@see CompletionParser#consumeCompilationUnit) + // Check for FAKE_TYPE_NAME to allow proposals (@see CompletionParser#consumeCompilationUnit) CompilationUnitDeclaration compilationUnit = scope.referenceCompilationUnit(); + if(compilationUnit != null && compilationUnit.isModuleInfo() ) { + specifiedTags = MODULE_TAGS; + break; + } if (compilationUnit != null && (compilationUnit.types.length > 0 && compilationUnit.types[0].name == CompletionParser.FAKE_TYPE_NAME)) { specifiedTags = CLASS_TAGS; diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java index efad084512..3817b6db1a 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -609,6 +609,10 @@ public class JavadocParser extends AbstractCommentParser { valid = parseParam(); } } + if (length == TAG_PROVIDES_LENGTH && CharOperation.equals(TAG_PROVIDES, tagName, 0, length)) { + this.tagValue = TAG_PROVIDES_VALUE; + this.tagWaitingForDescription = this.tagValue; + } break; case 'r': if (length == TAG_RETURN_LENGTH && CharOperation.equals(TAG_RETURN, tagName, 0, length)) { @@ -636,7 +640,7 @@ public class JavadocParser extends AbstractCommentParser { } else if (length == TAG_SINCE_LENGTH && CharOperation.equals(TAG_SINCE, tagName, 0, length)) { this.tagValue = TAG_SINCE_VALUE; this.tagWaitingForDescription = this.tagValue; - } + } break; case 't': if (length == TAG_THROWS_LENGTH && CharOperation.equals(TAG_THROWS, tagName, 0, length)) { @@ -646,6 +650,12 @@ public class JavadocParser extends AbstractCommentParser { } } break; + case 'u': + if (length == TAG_USES_LENGTH && CharOperation.equals(TAG_USES, tagName, 0, length)) { + this.tagValue = TAG_USES_VALUE; + this.tagWaitingForDescription = this.tagValue; + } + break; case 'v': if (length == TAG_VALUE_LENGTH && CharOperation.equals(TAG_VALUE, tagName, 0, length)) { this.tagValue = TAG_VALUE_VALUE; diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java index 64077fde76..10f540e36f 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java @@ -44,6 +44,8 @@ public interface JavadocTagConstants { public static final char[] TAG_SINCE = "since".toCharArray(); //$NON-NLS-1$ public static final char[] TAG_VERSION = "version".toCharArray(); //$NON-NLS-1$ public static final char[] TAG_CATEGORY = "category".toCharArray(); //$NON-NLS-1$ + public static final char[] TAG_USES = "uses".toCharArray(); //$NON-NLS-1$ + public static final char[] TAG_PROVIDES = "provides".toCharArray(); //$NON-NLS-1$ // tags lengthes public static final int TAG_DEPRECATED_LENGTH = TAG_DEPRECATED.length; @@ -66,6 +68,8 @@ public interface JavadocTagConstants { public static final int TAG_CODE_LENGTH = TAG_CODE.length; public static final int TAG_LITERAL_LENGTH = TAG_LITERAL.length; public static final int TAG_DOC_ROOT_LENGTH = TAG_DOC_ROOT.length; + public static final int TAG_USES_LENGTH = TAG_USES.length; + public static final int TAG_PROVIDES_LENGTH = TAG_PROVIDES.length; // tags value public static final int NO_TAG_VALUE = 0; @@ -89,8 +93,9 @@ public interface JavadocTagConstants { public static final int TAG_CODE_VALUE = 18; public static final int TAG_LITERAL_VALUE = 19; public static final int TAG_DOC_ROOT_VALUE = 20; + public static final int TAG_USES_VALUE=21; + public static final int TAG_PROVIDES_VALUE=22; public static final int TAG_OTHERS_VALUE = 100; - // Tag names array public static final char[][] TAG_NAMES = { CharOperation.NO_CHAR, @@ -153,7 +158,7 @@ public interface JavadocTagConstants { // since 1.8 {}, // since 9 - {}, + {TAG_USES, TAG_PROVIDES}, // since 10 {}, // since 11 @@ -280,4 +285,21 @@ public interface JavadocTagConstants { TAG_CODE, TAG_LITERAL }; + public static final char[][] MODULE_TAGS = { + TAG_SEE, + TAG_SINCE, + TAG_DEPRECATED, + TAG_SERIAL, + TAG_AUTHOR, + TAG_VERSION, + TAG_CATEGORY, + TAG_LINK, + TAG_LINKPLAIN, + TAG_DOC_ROOT, + TAG_VALUE, + TAG_CODE, + TAG_LITERAL, + TAG_USES, + TAG_PROVIDES + }; } -- cgit v1.2.3 From f6fff1a722a8bd4870014d160c0fef71185b719b Mon Sep 17 00:00:00 2001 From: Stephan Herrmann Date: Thu, 14 Feb 2019 19:20:55 +0100 Subject: Bug 544426 - Version 10/11 not supported by compiler? Change-Id: I74cd851e773647f34ee7fa416b986b62c596f228 Signed-off-by: Stephan Herrmann --- .../batch/org/eclipse/jdt/internal/compiler/batch/messages.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties index c02926b66d..37a2143e9d 100644 --- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties +++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties @@ -66,7 +66,7 @@ configure.duplicateTarget = duplicate target compliance setting specification: { configure.unsupportedReleaseOption = option --release is supported only when run with JDK 9 or above configure.unsupportedWithRelease = option {0} is not supported when --release is used configure.unsupportedReleaseVersion = release version {0} is not supported -configure.source = source level should be comprised in between ''1.3'' and ''1.9'' (or ''5'', ''5.0'', ..., ''9'' or ''9.0''): {0} +configure.source = source level should be in ''1.1''...''1.8'',''9''...''11'' (or ''5.0''..''11.0''): {0} configure.invalidSystem = invalid location for system libraries: {0} configure.unsupportedOption = option {0} not supported at compliance level 9 and above configure.duplicateOutputPath = duplicate output path specification: {0} @@ -83,7 +83,7 @@ configure.invalidDebugOption = invalid debug option: {0} configure.invalidWarningConfiguration = invalid warning configuration: ''{0}'' configure.invalidWarning = invalid warning token: ''{0}''. Ignoring warning and compiling configure.invalidWarningOption = invalid warning option: ''{0}''. Must specify a warning token -configure.targetJDK = target level should be comprised in between ''1.1'' and ''1.9'' (or ''5'', ''5.0'', ..., ''9'' or ''9.0'') or cldc1.1: {0} +configure.targetJDK = target level should be in ''1.1''...''1.8'',''9''...''11'' (or ''5.0''..''11.0'') or cldc1.1: {0} configure.incompatibleTargetForSource = Target level ''{0}'' is incompatible with source level ''{1}''. A target level ''{1}'' or better is required configure.incompatibleTargetForGenericSource = Target level ''{0}'' is incompatible with source level ''{1}''. A source level ''1.5'' or better is required configure.incompatibleComplianceForSource = Compliance level ''{0}'' is incompatible with source level ''{1}''. A compliance level ''{1}'' or better is required -- cgit v1.2.3 From 46390363cfd3003b683a7a4fcf6b40da4f877f1d Mon Sep 17 00:00:00 2001 From: Stephan Herrmann Date: Thu, 14 Feb 2019 21:26:06 +0100 Subject: Bug 544432 - [9] Eclipse compiler error "The type com.a.A is not accessible" while javac works Change-Id: I9b0985187b14356aef6300312265793343a1e812 Signed-off-by: Stephan Herrmann --- .../jdt/core/tests/model/ModuleBuilderTests.java | 47 ++++++++++++++++++++++ .../internal/compiler/lookup/ModuleBinding.java | 12 +++++- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java index 725f615ff1..b80de70c73 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java @@ -7992,6 +7992,53 @@ public class ModuleBuilderTests extends ModifyingResourceTests { Util.flushDirectoryContent(outputDir); } } + + public void testBug544432() throws CoreException { + IJavaProject prjA = createJava9Project("A"); + IJavaProject prjB = createJava9Project("B"); + try { + createFolder("A/src/com/a"); + createFile("A/src/com/a/A.java", + "package com.a;\n" + + "\n" + + "public class A {}\n"); + createFile("A/src/module-info.java", + "open module com.a {\n" + + " exports com.a;\n" + + "}\n"); + + addModularProjectEntry(prjB, prjA); + createFolder("B/src/com/a/b"); + String bPath = "B/src/com/a/b/B.java"; + String bSource = + "package com.a.b;\n" + + "import com.a.A;\n" + + "public class B {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " A a = new A();\n" + + " System.out.println(a);\n" + + " }\n" + + "}\n"; + createFile(bPath, bSource); + createFile("B/src/module-info.java", + "open module com.a.b {\n" + + " requires com.a;\n" + + "}\n"); + getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null); + assertNoErrors(); + + this.problemRequestor.initialize(bSource.toCharArray()); + getCompilationUnit(bPath).getWorkingCopy(this.wcOwner, null); + assertProblems("unexpected problems", + "----------\n" + + "----------\n", + this.problemRequestor); + } finally { + deleteProject(prjA); + deleteProject(prjB); + } + } protected void assertNoErrors() throws CoreException { for (IProject p : getWorkspace().getRoot().getProjects()) { diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java index 32df973735..3b31a807a4 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java @@ -564,8 +564,16 @@ public class ModuleBinding extends Binding implements IUpdatableModule { declaringModuleNames = moduleEnv.getUniqueModulesDeclaringPackage(parentName, name, nameForLookup()); if (declaringModuleNames != null) { if (CharOperation.containsEqual(declaringModuleNames, this.moduleName)) { - // declared here, not yet known, so create it now: - binding = new PackageBinding(subPkgCompoundName, parent, this.environment, this); + if (parent instanceof SplitPackageBinding) { + // parent.getPackage0() may have been too shy, so drill into the split: + PackageBinding singleParent = ((SplitPackageBinding) parent).getIncarnation(this); + if (singleParent != null) + binding = singleParent.getPackage0(name); + } + if (binding == null) { + // declared here, not yet known, so create it now: + binding = new PackageBinding(subPkgCompoundName, parent, this.environment, this); + } } else if (considerRequiredModules) { // visible but foreign (when current is unnamed or auto): for (char[] declaringModuleName : declaringModuleNames) { -- cgit v1.2.3 From 8cb6c49413fa655cdea19b327484167f0937c131 Mon Sep 17 00:00:00 2001 From: Mateusz Matela Date: Sun, 17 Feb 2019 13:19:59 +0100 Subject: Bug 541011 - [formatter] Option to wrap chained conditionals as one group --- .../tests/formatter/FormatterRegressionTests.java | 64 ++++++++++++++++++++++ .../workspace/Formatter/test541011/A_out.java | 15 +++++ .../workspace/Formatter/test541011/B_out.java | 15 +++++ .../workspace/Formatter/test541011/C_out.java | 17 ++++++ .../workspace/Formatter/test541011/D_out.java | 19 +++++++ .../workspace/Formatter/test541011/E_out.java | 35 ++++++++++++ .../workspace/Formatter/test541011/F_out.java | 35 ++++++++++++ .../workspace/Formatter/test541011/G_out.java | 35 ++++++++++++ .../workspace/Formatter/test541011/in.java | 9 +++ .../formatter/DefaultCodeFormatterConstants.java | 14 +++++ .../formatter/DefaultCodeFormatterOptions.java | 6 ++ .../formatter/linewrap/WrapPreparator.java | 48 +++++++++++++--- 12 files changed, 305 insertions(+), 7 deletions(-) create mode 100644 org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/A_out.java create mode 100644 org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/B_out.java create mode 100644 org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/C_out.java create mode 100644 org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/D_out.java create mode 100644 org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/E_out.java create mode 100644 org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/F_out.java create mode 100644 org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/G_out.java create mode 100644 org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/in.java diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java index 36879049c5..36ec699cc1 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java @@ -14773,4 +14773,68 @@ public void testBug159565g() throws JavaModelException { String input = getCompilationUnit("Formatter", "", "test159565", "in.java").getSource(); formatSource(input, getCompilationUnit("Formatter", "", "test159565", "G_out.java").getSource()); } +/** + * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group + */ +public void testBug541011a() throws JavaModelException { + this.formatterPrefs.page_width = 80; + String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test541011", "A_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group + */ +public void testBug541011b() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_conditional_expression_chain = Alignment.M_COMPACT_SPLIT; + String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test541011", "B_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group + */ +public void testBug541011c() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_conditional_expression_chain = Alignment.M_ONE_PER_LINE_SPLIT; + String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test541011", "C_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group + */ +public void testBug541011d() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_conditional_expression_chain = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test541011", "D_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group + */ +public void testBug541011e() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_conditional_expression_chain = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + this.formatterPrefs.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test541011", "E_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group + */ +public void testBug541011f() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_conditional_expression_chain = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; + this.formatterPrefs.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; + String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test541011", "F_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group + */ +public void testBug541011g() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; + String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test541011", "G_out.java").getSource()); +} } diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/A_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/A_out.java new file mode 100644 index 0000000000..a41e1d02a8 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/A_out.java @@ -0,0 +1,15 @@ +class C { + void f() { + return argument ? 100000 : 200000; + boolean someValue1 = condition1() ? value1 + : condition2() ? value2 : condition3 ? value3 : value4; + boolean someValue2 = condition1() ? value1 + : (condition2() ? value2 : condition3 ? value3 : value4); + boolean otherValue1 = condition1 + ? condition2 ? condition3 ? value4 : value3 : value2 + : value1; + boolean otherValue2 = condition1 + ? (condition2 ? condition3 ? value4 : value3 : value2) + : value1; + } +} \ No newline at end of file diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/B_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/B_out.java new file mode 100644 index 0000000000..fb351ad9d6 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/B_out.java @@ -0,0 +1,15 @@ +class C { + void f() { + return argument ? 100000 : 200000; + boolean someValue1 = condition1() ? value1 : condition2() ? value2 + : condition3 ? value3 : value4; + boolean someValue2 = condition1() ? value1 + : (condition2() ? value2 : condition3 ? value3 : value4); + boolean otherValue1 = condition1 + ? condition2 ? condition3 ? value4 : value3 : value2 + : value1; + boolean otherValue2 = condition1 + ? (condition2 ? condition3 ? value4 : value3 : value2) + : value1; + } +} \ No newline at end of file diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/C_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/C_out.java new file mode 100644 index 0000000000..d73ac71267 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/C_out.java @@ -0,0 +1,17 @@ +class C { + void f() { + return argument ? 100000 : 200000; + boolean someValue1 = condition1() ? value1 + : condition2() ? value2 + : condition3 ? value3 + : value4; + boolean someValue2 = condition1() ? value1 + : (condition2() ? value2 : condition3 ? value3 : value4); + boolean otherValue1 = condition1 + ? condition2 ? condition3 ? value4 : value3 : value2 + : value1; + boolean otherValue2 = condition1 + ? (condition2 ? condition3 ? value4 : value3 : value2) + : value1; + } +} \ No newline at end of file diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/D_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/D_out.java new file mode 100644 index 0000000000..3d4217839c --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/D_out.java @@ -0,0 +1,19 @@ +class C { + void f() { + return argument ? 100000 : 200000; + boolean someValue1 = condition1() ? value1 + : condition2() ? value2 + : condition3 ? value3 + : value4; + boolean someValue2 = condition1() ? value1 + : (condition2() ? value2 + : condition3 ? value3 + : value4); + boolean otherValue1 = condition1 + ? condition2 ? condition3 ? value4 : value3 : value2 + : value1; + boolean otherValue2 = condition1 + ? (condition2 ? condition3 ? value4 : value3 : value2) + : value1; + } +} \ No newline at end of file diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/E_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/E_out.java new file mode 100644 index 0000000000..8687c40352 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/E_out.java @@ -0,0 +1,35 @@ +class C { + void f() { + return argument + ? 100000 + : 200000; + boolean someValue1 = condition1() + ? value1 + : condition2() + ? value2 + : condition3 + ? value3 + : value4; + boolean someValue2 = condition1() + ? value1 + : (condition2() + ? value2 + : condition3 + ? value3 + : value4); + boolean otherValue1 = condition1 + ? condition2 + ? condition3 + ? value4 + : value3 + : value2 + : value1; + boolean otherValue2 = condition1 + ? (condition2 + ? condition3 + ? value4 + : value3 + : value2) + : value1; + } +} \ No newline at end of file diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/F_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/F_out.java new file mode 100644 index 0000000000..34bdfc122d --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/F_out.java @@ -0,0 +1,35 @@ +class C { + void f() { + return argument + ? 100000 + : 200000; + boolean someValue1 = condition1() + ? value1 + : condition2() + ? value2 + : condition3 + ? value3 + : value4; + boolean someValue2 = condition1() + ? value1 + : (condition2() + ? value2 + : condition3 + ? value3 + : value4); + boolean otherValue1 = condition1 + ? condition2 + ? condition3 + ? value4 + : value3 + : value2 + : value1; + boolean otherValue2 = condition1 + ? (condition2 + ? condition3 + ? value4 + : value3 + : value2) + : value1; + } +} \ No newline at end of file diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/G_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/G_out.java new file mode 100644 index 0000000000..47713f69e9 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/G_out.java @@ -0,0 +1,35 @@ +class C { + void f() { + return argument + ? 100000 + : 200000; + boolean someValue1 = condition1() + ? value1 + : condition2() + ? value2 + : condition3 + ? value3 + : value4; + boolean someValue2 = condition1() + ? value1 + : (condition2() + ? value2 + : condition3 + ? value3 + : value4); + boolean otherValue1 = condition1 + ? condition2 + ? condition3 + ? value4 + : value3 + : value2 + : value1; + boolean otherValue2 = condition1 + ? (condition2 + ? condition3 + ? value4 + : value3 + : value2) + : value1; + } +} \ No newline at end of file diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/in.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/in.java new file mode 100644 index 0000000000..8bb256b4c0 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test541011/in.java @@ -0,0 +1,9 @@ +class C { + void f() { + return argument ? 100000 : 200000; + boolean someValue1 = condition1() ? value1 : condition2() ? value2 : condition3 ? value3 : value4; + boolean someValue2 = condition1() ? value1 : (condition2() ? value2 : condition3 ? value3 : value4); + boolean otherValue1 = condition1 ? condition2 ? condition3 ? value4 : value3 : value2 : value1; + boolean otherValue2 = condition1 ? (condition2 ? condition3 ? value4 : value3 : value2) : value1; + } +} \ No newline at end of file diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java index 8390c3a88b..922b1b50a1 100644 --- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java +++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java @@ -323,9 +323,23 @@ public class DefaultCodeFormatterConstants { * - default: createAlignmentValue(false, WRAP_ONE_PER_LINE, INDENT_DEFAULT) * * @see #createAlignmentValue(boolean, int, int) + * @see #FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION_CHAIN * @since 3.0 */ public static final String FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION = JavaCore.PLUGIN_ID + ".formatter.alignment_for_conditional_expression"; //$NON-NLS-1$ + /** + *
+	 * FORMATTER / Option for alignment of conditional expression chains. If disabled, chains are not recognized
+	 *             and only {@link #FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION} policy is used instead.
+	 *     - option id:         "org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain"
+	 *     - possible values:   values returned by createAlignmentValue(boolean, int, int) call
+	 *     - default:           createAlignmentValue(false, WRAP_NO_SPLIT, INDENT_DEFAULT)
+	 * 
+ * @see #createAlignmentValue(boolean, int, int) + * @see #FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION + * @since 3.17 + */ + public static final String FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION_CHAIN = JavaCore.PLUGIN_ID + ".formatter.alignment_for_conditional_expression_chain"; //$NON-NLS-1$ /** *
 	 * FORMATTER / Option for alignment of enum constants
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java
index 12b0b2f2f0..20de7be46a 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java
@@ -134,6 +134,7 @@ public class DefaultCodeFormatterOptions {
 	public int alignment_for_compact_if;
 	public int alignment_for_compact_loop;
 	public int alignment_for_conditional_expression;
+	public int alignment_for_conditional_expression_chain;
 	public int alignment_for_enum_constants;
 	public int alignment_for_expressions_in_array_initializer;
 	public int alignment_for_expressions_in_for_loop_header;
@@ -518,6 +519,7 @@ public class DefaultCodeFormatterOptions {
 		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF, getAlignment(this.alignment_for_compact_if));
 		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_LOOP, getAlignment(this.alignment_for_compact_loop));
 		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION, getAlignment(this.alignment_for_conditional_expression));
+		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION_CHAIN, getAlignment(this.alignment_for_conditional_expression_chain));
 		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, getAlignment(this.alignment_for_enum_constants));
 		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, getAlignment(this.alignment_for_expressions_in_array_initializer));
 		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_FOR_LOOP_HEADER, getAlignment(this.alignment_for_expressions_in_for_loop_header));
@@ -965,6 +967,8 @@ public class DefaultCodeFormatterOptions {
 				this.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT;
 			}
 		}
+		setInt(settings, DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION_CHAIN,
+				v -> this.alignment_for_conditional_expression_chain = v);
 		final Object alignmentForEnumConstantsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS);
 		if (alignmentForEnumConstantsOption != null) {
 			try {
@@ -2778,6 +2782,7 @@ public class DefaultCodeFormatterOptions {
 		this.alignment_for_compact_if = Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_INDENT_BY_ONE;
 		this.alignment_for_compact_loop = Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_INDENT_BY_ONE;
 		this.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT;
+		this.alignment_for_conditional_expression_chain = Alignment.M_NO_ALIGNMENT;
 		this.alignment_for_enum_constants = Alignment.M_NO_ALIGNMENT;
 		this.alignment_for_expressions_in_array_initializer = Alignment.M_COMPACT_SPLIT;
 		this.alignment_for_expressions_in_for_loop_header = Alignment.M_NO_ALIGNMENT;
@@ -3127,6 +3132,7 @@ public class DefaultCodeFormatterOptions {
 		this.alignment_for_compact_if = Alignment.M_COMPACT_SPLIT;
 		this.alignment_for_compact_loop = Alignment.M_COMPACT_SPLIT;
 		this.alignment_for_conditional_expression = Alignment.M_NEXT_PER_LINE_SPLIT;
+		this.alignment_for_conditional_expression_chain = Alignment.M_NO_ALIGNMENT;
 		this.alignment_for_enum_constants = Alignment.M_COMPACT_SPLIT;
 		this.alignment_for_expressions_in_array_initializer = Alignment.M_COMPACT_SPLIT;
 		this.alignment_for_expressions_in_for_loop_header = Alignment.M_NO_ALIGNMENT;
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java
index 0d39d3e9ed..5c12e80886 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java
@@ -682,16 +682,50 @@ public class WrapPreparator extends ASTVisitor {
 
 	@Override
 	public boolean visit(ConditionalExpression node) {
+		boolean chainsMatter = (this.options.alignment_for_conditional_expression_chain
+				& Alignment.SPLIT_MASK) != Alignment.M_NO_ALIGNMENT;
+		boolean isNextInChain = node.getParent() instanceof ConditionalExpression
+				&& node == ((ConditionalExpression) node.getParent()).getElseExpression();
+		boolean isFirstInChain = node.getElseExpression() instanceof ConditionalExpression && !isNextInChain;
 		boolean wrapBefore = this.options.wrap_before_conditional_operator;
 		List before = wrapBefore ? this.wrapIndexes : this.secondaryWrapIndexes;
 		List after = wrapBefore ? this.secondaryWrapIndexes : this.wrapIndexes;
-		before.add(this.tm.firstIndexAfter(node.getExpression(), TokenNameQUESTION));
-		before.add(this.tm.firstIndexAfter(node.getThenExpression(), TokenNameCOLON));
-		after.add(this.tm.firstIndexIn(node.getThenExpression(), -1));
-		after.add(this.tm.firstIndexIn(node.getElseExpression(), -1));
-		this.wrapParentIndex = this.tm.lastIndexIn(node.getExpression(), -1);
-		this.wrapGroupEnd = this.tm.lastIndexIn(node, -1);
-		handleWrap(this.options.alignment_for_conditional_expression);
+		if (!chainsMatter || (!isFirstInChain && !isNextInChain)) {
+			before.add(this.tm.firstIndexAfter(node.getExpression(), TokenNameQUESTION));
+			before.add(this.tm.firstIndexAfter(node.getThenExpression(), TokenNameCOLON));
+			after.add(this.tm.firstIndexIn(node.getThenExpression(), -1));
+			after.add(this.tm.firstIndexIn(node.getElseExpression(), -1));
+			this.wrapParentIndex = this.tm.lastIndexIn(node.getExpression(), -1);
+			this.wrapGroupEnd = this.tm.lastIndexIn(node, -1);
+			handleWrap(this.options.alignment_for_conditional_expression);
+
+		} else if (isFirstInChain) {
+			List chain = new ArrayList<>();
+			chain.add(node);
+			ConditionalExpression next = node;
+			while (next.getElseExpression() instanceof ConditionalExpression) {
+				next = (ConditionalExpression) next.getElseExpression();
+				chain.add(next);
+			}
+
+			for (ConditionalExpression conditional : chain) {
+				before.add(this.tm.firstIndexAfter(conditional.getThenExpression(), TokenNameCOLON));
+				after.add(this.tm.firstIndexIn(conditional.getElseExpression(), -1));
+			}
+			this.wrapParentIndex = this.tm.firstIndexIn(node.getExpression(), -1);
+			this.wrapGroupEnd = this.tm.lastIndexIn(node, -1);
+			handleWrap(this.options.alignment_for_conditional_expression_chain);
+
+			this.currentDepth++;
+			for (ConditionalExpression conditional : chain) {
+				before.add(this.tm.firstIndexAfter(conditional.getExpression(), TokenNameQUESTION));
+				after.add(this.tm.firstIndexIn(conditional.getThenExpression(), -1));
+				this.wrapParentIndex = this.tm.firstIndexIn(conditional.getExpression(), -1);
+				this.wrapGroupEnd = this.tm.lastIndexIn(conditional.getThenExpression(), -1);
+				handleWrap(this.options.alignment_for_conditional_expression);
+			}
+			this.currentDepth--;
+		}
 		return true;
 	}
 
-- 
cgit v1.2.3


From ea4f41646d0f2948e1afa9cf9af9031a5f522827 Mon Sep 17 00:00:00 2001
From: Jay Arthanareeswaran
Date: Mon, 18 Feb 2019 10:55:44 +0530
Subject: Bug 544407 - JDT Core bundles (+doc) need a version increment

Change-Id: Iac679bea4f9c0eda121762b9faa324d0a7e7591f
Signed-off-by: Jay Arthanareeswaran ---
 org.eclipse.jdt.apt.pluggable.tests/META-INF/MANIFEST.MF | 2 +-
 org.eclipse.jdt.apt.pluggable.tests/pom.xml              | 4 ++--
 org.eclipse.jdt.compiler.apt/META-INF/MANIFEST.MF        | 2 +-
 org.eclipse.jdt.compiler.apt/pom.xml                     | 4 ++--
 org.eclipse.jdt.compiler.tool/META-INF/MANIFEST.MF       | 2 +-
 org.eclipse.jdt.compiler.tool/pom.xml                    | 4 ++--
 org.eclipse.jdt.core.tests.builder/META-INF/MANIFEST.MF  | 2 +-
 org.eclipse.jdt.core.tests.builder/pom.xml               | 2 +-
 8 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/org.eclipse.jdt.apt.pluggable.tests/META-INF/MANIFEST.MF b/org.eclipse.jdt.apt.pluggable.tests/META-INF/MANIFEST.MF
index 381ea02118..922bd06b63 100644
--- a/org.eclipse.jdt.apt.pluggable.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.apt.pluggable.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.jdt.apt.pluggable.tests;singleton:=true
-Bundle-Version: 3.4.500.qualifier
+Bundle-Version: 3.4.600.qualifier
 Bundle-Activator: org.eclipse.jdt.apt.pluggable.tests.Apt6TestsPlugin
 Bundle-Localization: plugin
 Require-Bundle: org.junit,
diff --git a/org.eclipse.jdt.apt.pluggable.tests/pom.xml b/org.eclipse.jdt.apt.pluggable.tests/pom.xml
index 915f64c3b3..069cbd4f71 100644
--- a/org.eclipse.jdt.apt.pluggable.tests/pom.xml
+++ b/org.eclipse.jdt.apt.pluggable.tests/pom.xml
@@ -1,6 +1,6 @@