From cbe4bad0dbb26d830f40bc961abdf5756b16262f Mon Sep 17 00:00:00 2001 From: Eric Milles Date: Sun, 28 Feb 2021 13:56:37 -0600 Subject: [PATCH] Eclipse 4.19 (RC1) JDT Patch for Groovy-Eclipse: JDT commit 37880e2 #1217 --- .../feature.xml | 2 +- .../internal/codeassist/SelectionEngine.java | 9 +++- .../eclipse/jdt/internal/core/BinaryType.java | 47 +++++++++++++++++++ .../core/CompilationUnitProblemFinder.java | 4 +- .../jdt/internal/core/ModuleUpdater.java | 4 +- .../jdt/internal/core/builder/State.java | 19 ++++---- .../e419/org.eclipse.jdt.core/readme.txt | 1 + pom.xml | 2 +- 8 files changed, 72 insertions(+), 16 deletions(-) diff --git a/jdt-patch/e419/Feature-org.codehaus.groovy.jdt.patch/feature.xml b/jdt-patch/e419/Feature-org.codehaus.groovy.jdt.patch/feature.xml index 3bb1b49459..b20de56161 100644 --- a/jdt-patch/e419/Feature-org.codehaus.groovy.jdt.patch/feature.xml +++ b/jdt-patch/e419/Feature-org.codehaus.groovy.jdt.patch/feature.xml @@ -18,7 +18,7 @@ - + 0) { + buf.append(moduleName); + buf.append('/'); + } + } +} + +private static IModuleDescription getModuleDescription(IPackageFragment pack) { + if (pack == null) { + return null; + } + IModuleDescription moduleDescription= null; + /* + * The Javadoc tool for Java SE 11 uses module name in the created URL. + * We can't know what format is required, so we just guess by the project's compiler compliance. + */ + IJavaProject javaProject= pack.getJavaProject(); + if (javaProject != null && isComplianceJava11OrHigher(javaProject)) { + if (pack.isReadOnly()) { + IPackageFragmentRoot root= (IPackageFragmentRoot) pack.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); + if (root != null) { + moduleDescription= root.getModuleDescription(); + } + } else { + try { + moduleDescription= javaProject.getModuleDescription(); + } catch (JavaModelException e) { + // do nothing + } + } + } + return moduleDescription; +} + +private static boolean isComplianceJava11OrHigher(IJavaProject javaProject) { + if (javaProject == null) { + return false; + } + return CompilerOptions.versionToJdkLevel(javaProject.getOption(JavaCore.COMPILER_COMPLIANCE, true)) >= ClassFileConstants.JDK11; +} } diff --git a/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java b/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java index 952e1f017c..f2ccaad560 100644 --- a/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java +++ b/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java @@ -1,6 +1,6 @@ // GROOVY PATCHED /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -133,7 +133,9 @@ public void accept(ISourceType[] sourceTypes, PackageBinding packageBinding, Acc if (unit != null) { environment.buildTypeBindings(unit, accessRestriction); + CompilationUnitDeclaration previousUnitBeingCompleted = this.lookupEnvironment.unitBeingCompleted; environment.completeTypeBindings(unit); + this.lookupEnvironment.unitBeingCompleted = previousUnitBeingCompleted; } } finally { this.options.complianceLevel = savedComplianceLevel; diff --git a/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModuleUpdater.java b/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModuleUpdater.java index 8984f57d81..836c64b2a3 100644 --- a/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModuleUpdater.java +++ b/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModuleUpdater.java @@ -55,7 +55,7 @@ public ModuleUpdater(JavaProject javaProject) { * Detects any ADD_EXPORTS or ADD_READS classpath attributes, parses the value, * and collects the resulting module updates. * @param entry a classpath entry of the current project. - * @throws JavaModelException + * @throws JavaModelException */ public void computeModuleUpdates(IClasspathEntry entry) throws JavaModelException { for (IClasspathAttribute attribute : entry.getExtraAttributes()) { @@ -128,7 +128,7 @@ private static boolean containsNonModularDependency(IClasspathEntry[] entries) { public void addReadUnnamedForNonEmptyClasspath(JavaProject project, IClasspathEntry[] expandedClasspath) throws JavaModelException { for (String moduleName : determineModulesOfProjectsWithNonEmptyClasspath(project, expandedClasspath)) { - addModuleUpdate(moduleName, m -> m.addReads(ModuleBinding.ALL_UNNAMED), UpdateKind.MODULE); + addModuleUpdate(moduleName, new IUpdatableModule.AddReads(ModuleBinding.ALL_UNNAMED), UpdateKind.MODULE); } } diff --git a/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/State.java b/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/State.java index e855d95a72..f84285e368 100644 --- a/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/State.java +++ b/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/State.java @@ -790,19 +790,17 @@ private void writeBinaryLocations(DataOutputStream out, ClasspathLocation[] loca if (c.updates != null) { List> pu = c.updates.getList(UpdateKind.PACKAGE, false); if (pu != null) { - Map>> map = pu.stream(). - collect(Collectors.groupingBy( - update -> CharOperation.charToString(((IUpdatableModule.AddExports)update).getName()))); + Map> map = pu.stream().filter(AddExports.class::isInstance) + .map(AddExports.class::cast) + .collect(Collectors.groupingBy(addExport -> CharOperation.charToString(addExport.getName()))); out.writeInt(map.size()); map.entrySet().stream().forEach(entry -> { String pkgName = entry.getKey(); try { writeName(pkgName.toCharArray(), out); char[][] targetModules = entry.getValue().stream() - .map(consumer -> ((IUpdatableModule.AddExports) consumer).getTargetModules()) - .filter(targets -> targets != null) - .reduce((f,s) -> CharOperation.arrayConcat(f,s)) - .orElse(null); + .map(addExport -> addExport.getTargetModules()).filter(targets -> targets != null) + .reduce((f, s) -> CharOperation.arrayConcat(f, s)).orElse(null); writeNames(targetModules, out); } catch (IOException e) { // ignore @@ -814,9 +812,10 @@ private void writeBinaryLocations(DataOutputStream out, ClasspathLocation[] loca } List> mu = c.updates.getList(UpdateKind.MODULE, false); if (mu != null) { - out.writeInt(mu.size()); - for (Consumer cons : mu) { - AddReads m = (AddReads) cons; + // TODO, here we cannot handle MODULE_MAIN_CLASS nor MODULE_PACKAGES (ModuleUpdater stores a lambda), should we? + List allReads = mu.stream().filter(AddReads.class::isInstance).map(AddReads.class::cast).collect(Collectors.toList()); + out.writeInt(allReads.size()); + for (AddReads m : allReads) { writeName(m.getTarget(), out); } } else { diff --git a/jdt-patch/e419/org.eclipse.jdt.core/readme.txt b/jdt-patch/e419/org.eclipse.jdt.core/readme.txt index a2ee52a7a5..360483e99a 100644 --- a/jdt-patch/e419/org.eclipse.jdt.core/readme.txt +++ b/jdt-patch/e419/org.eclipse.jdt.core/readme.txt @@ -1,3 +1,4 @@ 2021-01-08: d5c188d (2021-03 M1) 2021-02-08: babeca4 (2021-03 M2) 2021-02-22: 96e9f52 (2021-03 M3) +2021-02-28: 37880e2 (2021-03 RC1) diff --git a/pom.xml b/pom.xml index 7fe54ea513..dded71abb2 100644 --- a/pom.xml +++ b/pom.xml @@ -120,7 +120,7 @@ eclipse p2 - https://download.eclipse.org/eclipse/updates/4.19-I-builds/I20210217-1800 + https://download.eclipse.org/eclipse/updates/4.19-I-builds/I20210224-1800