Skip to content

Commit 4b504d5

Browse files
committed
Merge remote-tracking branch 'fabric/main' into develop
2 parents 9c7d29a + 051f42a commit 4b504d5

9 files changed

Lines changed: 80 additions & 104 deletions

File tree

build.gradle.kts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ dependencyLocking {
4444
lockMode.set(LockMode.STRICT)
4545
}
4646

47-
val jdtVersion = "org.eclipse.jdt:org.eclipse.jdt.core:3.35.0"
47+
val jdtVersion = "org.eclipse.jdt:org.eclipse.jdt.core:3.43.0"
4848
dependencies {
49-
// JDT pulls all of these deps in, however they do not specify the exact version to use so they can get updated without us knowing.
50-
// Depend specifically on these versions to prevent them from being updated under our feet.
51-
// The POM is also patched later on to as this strict versioning does not make it through.
52-
"jdt" (jdtVersion)
49+
"jdt" (jdtVersion) {
50+
exclude(group = "net.java.dev.jna")
51+
}
5352

5453
// TODO: Split in separate modules
5554
api("org.cadixdev:at:0.1.0-rc1")
@@ -80,6 +79,7 @@ val extract = task<Copy>("extractJdt") {
8079
destinationDir = patches.rootDir
8180

8281
include("org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java")
82+
include("org/eclipse/jdt/core/dom/CompilationUnitResolver.java")
8383
include("org/eclipse/jdt/internal/core/dom/rewrite/imports/*.java")
8484
}
8585
tasks["applyPatches"].inputs.files(extract)

gradle.lockfile

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ org.cadixdev:at:0.1.0-rc1=compileClasspath,runtimeClasspath,testCompileClasspath
66
org.cadixdev:bombe:0.3.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
77
org.cadixdev:lorenz-io-jam:0.5.7=testRuntimeClasspath
88
org.cadixdev:lorenz:0.5.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
9-
org.eclipse.jdt:ecj:3.35.0=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
10-
org.eclipse.jdt:org.eclipse.jdt.core:3.35.0=compileClasspath,jdt,jdtSources,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
11-
org.eclipse.platform:org.eclipse.core.commands:3.11.100=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
12-
org.eclipse.platform:org.eclipse.core.contenttype:3.9.100=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
13-
org.eclipse.platform:org.eclipse.core.expressions:3.9.100=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
14-
org.eclipse.platform:org.eclipse.core.filesystem:1.10.100=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
15-
org.eclipse.platform:org.eclipse.core.jobs:3.15.0=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
16-
org.eclipse.platform:org.eclipse.core.resources:3.19.100=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
17-
org.eclipse.platform:org.eclipse.core.runtime:3.29.0=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
18-
org.eclipse.platform:org.eclipse.equinox.app:1.6.300=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
19-
org.eclipse.platform:org.eclipse.equinox.common:3.18.100=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
20-
org.eclipse.platform:org.eclipse.equinox.preferences:3.10.300=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
21-
org.eclipse.platform:org.eclipse.equinox.registry:3.11.300=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
22-
org.eclipse.platform:org.eclipse.osgi:3.18.500=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
23-
org.eclipse.platform:org.eclipse.text:3.13.100=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
9+
org.eclipse.jdt:ecj:3.43.0=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
10+
org.eclipse.jdt:org.eclipse.jdt.core:3.43.0=compileClasspath,jdt,jdtSources,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
11+
org.eclipse.platform:org.eclipse.core.commands:3.12.400=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
12+
org.eclipse.platform:org.eclipse.core.contenttype:3.9.700=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
13+
org.eclipse.platform:org.eclipse.core.expressions:3.9.500=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
14+
org.eclipse.platform:org.eclipse.core.filesystem:1.11.300=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
15+
org.eclipse.platform:org.eclipse.core.jobs:3.15.700=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
16+
org.eclipse.platform:org.eclipse.core.resources:3.23.0=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
17+
org.eclipse.platform:org.eclipse.core.runtime:3.34.0=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
18+
org.eclipse.platform:org.eclipse.equinox.app:1.7.500=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
19+
org.eclipse.platform:org.eclipse.equinox.common:3.20.200=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
20+
org.eclipse.platform:org.eclipse.equinox.preferences:3.12.0=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
21+
org.eclipse.platform:org.eclipse.equinox.registry:3.12.500=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
22+
org.eclipse.platform:org.eclipse.osgi:3.23.200=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
23+
org.eclipse.platform:org.eclipse.text:3.14.400=compileClasspath,jdt,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
2424
org.junit.jupiter:junit-jupiter-api:5.7.0=testCompileClasspath,testRuntimeClasspath
2525
org.junit.jupiter:junit-jupiter-engine:5.7.0=testRuntimeClasspath
2626
org.junit.platform:junit-platform-commons:1.7.0=testCompileClasspath,testRuntimeClasspath

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
group = dev.architectury
22
og_group = org.cadixdev
33
name = Mercury
4-
base_version = 0.1.4
4+
base_version = 0.4.3
55
description = A source transformation and -remapping framework for Java.
66
url = https://github.com/architectury/Mercury
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- a/org/eclipse/jdt/core/dom/CompilationUnitResolver.java
2+
+++ b/org/eclipse/jdt/core/dom/CompilationUnitResolver.java
3+
@@ -1073,6 +1073,8 @@
4+
// remove at the end so that we don't resolve twice if a source and a key for the same file name have been requested
5+
this.requestedKeys.put(fileName, null); // mark it as removed
6+
}
7+
+ } catch (Exception e) {
8+
+ throw new RuntimeException("Failed to process " + new String(unit.compilationResult.getFileName()) + " " + e.getMessage(), e);
9+
} finally {
10+
// cleanup compilation unit result
11+
unit.cleanUp();

patches/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java.patch

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
--- a/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java
22
+++ b/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java
3-
@@ -61,6 +61,7 @@
4-
import org.eclipse.jdt.core.dom.Modifier;
5-
import org.eclipse.jdt.core.dom.Name;
6-
import org.eclipse.jdt.core.dom.NormalAnnotation;
7-
+import org.eclipse.jdt.core.dom.PackageDeclaration;
8-
import org.eclipse.jdt.core.dom.ParameterizedType;
9-
import org.eclipse.jdt.core.dom.PrimitiveType;
10-
import org.eclipse.jdt.core.dom.SimpleName;
11-
@@ -76,6 +77,7 @@
12-
import org.eclipse.jdt.internal.core.dom.rewrite.imports.ImportRewriteConfiguration.ImportContainerSorting;
13-
import org.eclipse.jdt.internal.core.util.Messages;
14-
import org.eclipse.jdt.internal.core.util.Util;
15-
+import org.eclipse.jface.text.IDocument;
16-
import org.eclipse.text.edits.MultiTextEdit;
17-
import org.eclipse.text.edits.TextEdit;
18-
19-
@@ -323,6 +325,9 @@
3+
@@ -289,6 +289,9 @@
204
private final ICompilationUnit compilationUnit;
215
private final CompilationUnit astRoot;
226

@@ -26,7 +10,7 @@
2610
private final boolean restoreExistingImports;
2711
private final List existingImports;
2812
private final Map importsKindMap;
29-
@@ -384,9 +389,8 @@
13+
@@ -349,9 +352,8 @@
3014
}
3115

3216
/**
@@ -38,7 +22,7 @@
3822
* will be inserted at best matching locations. If <code>restoreExistingImports</code> is <code>false</code>, the
3923
* existing imports will be removed and only the newly added imports will be created.
4024
* <p>
41-
@@ -395,14 +399,14 @@
25+
@@ -360,14 +362,14 @@
4226
* @param astRoot the AST root node to create the imports for
4327
* @param restoreExistingImports specifies if the existing imports should be kept or removed.
4428
* @return the created import rewriter.
@@ -55,7 +39,7 @@
5539
throw new IllegalArgumentException("AST must have been constructed from a Java element"); //$NON-NLS-1$
5640
}
5741
List existingImport= null;
58-
@@ -425,7 +429,7 @@
42+
@@ -390,7 +392,7 @@
5943
}
6044

6145
private ImportRewrite(ICompilationUnit cu, CompilationUnit astRoot, List existingImports) {
@@ -64,7 +48,7 @@
6448
this.astRoot= astRoot; // might be null
6549
if (existingImports != null) {
6650
this.existingImports= existingImports;
67-
@@ -458,8 +462,33 @@
51+
@@ -423,8 +425,33 @@
6852
this.importsKindMap = new HashMap();
6953
}
7054

@@ -98,7 +82,7 @@
9882
* Defines the import groups and order to be used by the {@link ImportRewrite}.
9983
* Imports are added to the group matching their qualified name most. The empty group name groups all imports not matching
10084
* any other group. Static imports are managed in separate groups. Static import group names are prefixed with a '#' character.
101-
@@ -506,7 +535,8 @@
85+
@@ -471,7 +498,8 @@
10286

10387
/**
10488
* The compilation unit for which this import rewrite was created for.
@@ -108,7 +92,7 @@
10892
*/
10993
public ICompilationUnit getCompilationUnit() {
11094
return this.compilationUnit;
111-
@@ -611,15 +641,38 @@
95+
@@ -576,15 +604,38 @@
11296
}
11397
}
11498

@@ -150,7 +134,7 @@
150134

151135
if (this.astRoot != null) {
152136
List<AbstractTypeDeclaration> types = this.astRoot.types();
153-
@@ -1304,7 +1357,28 @@
137+
@@ -1268,7 +1319,28 @@
154138
* @throws CoreException the exception is thrown if the rewrite fails.
155139
*/
156140
public final TextEdit rewriteImports(IProgressMonitor monitor) throws CoreException {
@@ -171,15 +155,15 @@
171155
+ * recorded by this rewriter
172156
+ * @throws CoreException the exception is thrown if the rewrite fails.
173157
+ */
174-
+ public final TextEdit rewriteImports(IDocument document, IProgressMonitor monitor) throws CoreException {
158+
+ public final TextEdit rewriteImports(org.eclipse.jface.text.IDocument document, IProgressMonitor monitor) throws CoreException {
175159
+ if (this.compilationUnit == null && document == null) {
176160
+ throw new IllegalArgumentException("Cannot rewrite imports without compilation unit or document");
177161
+ }
178162
+
179163
SubMonitor subMonitor = SubMonitor.convert(monitor,
180164
Messages.bind(Messages.importRewrite_processDescription), 2);
181165
if (!hasRecordedChanges()) {
182-
@@ -1325,7 +1399,7 @@
166+
@@ -1289,7 +1361,7 @@
183167
ImportRewriteConfiguration config= buildImportRewriteConfiguration();
184168

185169
ImportRewriteAnalyzer computer=
@@ -188,7 +172,7 @@
188172

189173
for (String addedImport : this.addedImports) {
190174
boolean isStatic = STATIC_PREFIX == addedImport.charAt(0);
191-
@@ -1368,11 +1442,17 @@
175+
@@ -1332,11 +1404,17 @@
192176
configBuilder.setTypeOnDemandThreshold(this.importOnDemandThreshold);
193177
configBuilder.setStaticOnDemandThreshold(this.staticImportOnDemandThreshold);
194178

patches/org/eclipse/jdt/internal/core/dom/rewrite/imports/ImportRewriteAnalyzer.java.patch

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,28 @@
11
--- a/org/eclipse/jdt/internal/core/dom/rewrite/imports/ImportRewriteAnalyzer.java
22
+++ b/org/eclipse/jdt/internal/core/dom/rewrite/imports/ImportRewriteAnalyzer.java
3-
@@ -46,8 +46,11 @@
4-
import org.eclipse.jdt.internal.core.JavaProject;
5-
import org.eclipse.jdt.internal.core.dom.rewrite.imports.ConflictIdentifier.Conflicts;
6-
import org.eclipse.jdt.internal.core.util.Util;
7-
+import org.eclipse.jface.text.BadLocationException;
8-
+import org.eclipse.jface.text.IDocument;
9-
import org.eclipse.jface.text.IRegion;
10-
import org.eclipse.jface.text.Region;
11-
+import org.eclipse.jface.text.TextUtilities;
12-
import org.eclipse.text.edits.TextEdit;
13-
14-
/**
15-
@@ -261,10 +264,10 @@
3+
@@ -250,10 +250,10 @@
164
}
175

186
private static RewriteSite determineRewriteSite(
197
- CompilationUnit compilationUnit, List<OriginalImportEntry> originalImports) throws JavaModelException {
20-
+ CompilationUnit compilationUnit, IDocument document, List<OriginalImportEntry> originalImports) throws JavaModelException {
8+
+ CompilationUnit compilationUnit, org.eclipse.jface.text.IDocument document, List<OriginalImportEntry> originalImports) throws JavaModelException {
219
IRegion importsRegion = determineImportsRegion(originalImports);
2210

2311
- IRegion surroundingRegion = determineSurroundingRegion(compilationUnit, importsRegion);
2412
+ IRegion surroundingRegion = determineSurroundingRegion(compilationUnit, document, importsRegion);
2513

2614
boolean hasPrecedingElements = surroundingRegion.getOffset() != 0;
2715

28-
@@ -302,7 +305,7 @@
16+
@@ -291,7 +291,7 @@
2917
* Determines the region to be occupied by imports, their associated comments, and surrounding
3018
* whitespace.
3119
*/
3220
- private static IRegion determineSurroundingRegion(CompilationUnit compilationUnit, IRegion importsRegion) throws JavaModelException {
33-
+ private static IRegion determineSurroundingRegion(CompilationUnit compilationUnit, IDocument document, IRegion importsRegion) throws JavaModelException {
21+
+ private static IRegion determineSurroundingRegion(CompilationUnit compilationUnit, org.eclipse.jface.text.IDocument document, IRegion importsRegion) throws JavaModelException {
3422
NavigableMap<Integer, ASTNode> nodesTreeMap = mapTopLevelNodes(compilationUnit);
3523

3624
int surroundingStart;
37-
@@ -331,12 +334,24 @@
25+
@@ -332,12 +332,24 @@
3826
}
3927

4028
int surroundingEnd = positionAfterImports;
@@ -44,7 +32,7 @@
4432
+ while (surroundingEnd < length && Character.isWhitespace(document.getChar(surroundingEnd))) {
4533
+ surroundingEnd++;
4634
+ }
47-
+ } catch (BadLocationException e) {
35+
+ } catch (org.eclipse.jface.text.BadLocationException e) {
4836
+ throw new RuntimeException(e);
4937
+ }
5038
+ } else {
@@ -59,15 +47,15 @@
5947
return new Region(surroundingStart, surroundingEnd - surroundingStart);
6048
}
6149

62-
@@ -432,6 +447,7 @@
50+
@@ -433,6 +445,7 @@
6351
public ImportRewriteAnalyzer(
6452
ICompilationUnit cu,
6553
CompilationUnit astRoot,
66-
+ IDocument document,
54+
+ org.eclipse.jface.text.IDocument document,
6755
ImportRewriteConfiguration configuration) throws JavaModelException {
6856
this.originalImportEntries = Collections.unmodifiableList(readOriginalImports(astRoot));
6957

70-
@@ -460,7 +476,7 @@
58+
@@ -461,7 +474,7 @@
7159

7260
ImportGroupComparator importGroupComparator = new ImportGroupComparator(configuration.importOrder);
7361

@@ -76,7 +64,7 @@
7664

7765
this.importAdder = configuration.originalImportHandling.createImportAdder(new ImportComparator(
7866
importGroupComparator,
79-
@@ -468,31 +484,39 @@
67+
@@ -469,31 +482,39 @@
8068
configuration.staticContainerSorting.createContainerComparator(javaProject)));
8169

8270
this.implicitImportContainerNames =
@@ -105,7 +93,7 @@
10593
+ if (cu != null) {
10694
this.lineDelimiter = cu.findRecommendedLineSeparator();
10795
+ } else {
108-
+ this.lineDelimiter = TextUtilities.getDefaultLineDelimiter(document);
96+
+ this.lineDelimiter = org.eclipse.jface.text.TextUtilities.getDefaultLineDelimiter(document);
10997
+ }
11098

11199
this.importEditor = new ImportEditor(
@@ -120,7 +108,7 @@
120108
this.importDeclarationWriter);
121109
}
122110

123-
@@ -566,18 +590,18 @@
111+
@@ -567,18 +588,18 @@
124112

125113
Set<ImportName> touchedContainers = determineTouchedContainers();
126114

@@ -133,11 +121,11 @@
133121
- progressMonitor);
134122
+ progressMonitor) : null;
135123

136-
Set<String> allTypeExplicitSimpleNames = new HashSet<String>(this.typeExplicitSimpleNames);
124+
Set<String> allTypeExplicitSimpleNames = new HashSet<>(this.typeExplicitSimpleNames);
137125
- allTypeExplicitSimpleNames.addAll(conflicts.typeConflicts);
138126
+ if (conflicts != null) allTypeExplicitSimpleNames.addAll(conflicts.typeConflicts);
139127

140-
Set<String> allStaticExplicitSimpleNames = new HashSet<String>(this.staticExplicitSimpleNames);
128+
Set<String> allStaticExplicitSimpleNames = new HashSet<>(this.staticExplicitSimpleNames);
141129
- allStaticExplicitSimpleNames.addAll(conflicts.staticConflicts);
142130
+ if (conflicts != null) allStaticExplicitSimpleNames.addAll(conflicts.staticConflicts);
143131

0 commit comments

Comments
 (0)