Skip to content

Commit

Permalink
Eclipse 4.23 (RC2) JDT Patch for Groovy-Eclipse
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Mar 4, 2022
1 parent ddca14b commit 3585798
Show file tree
Hide file tree
Showing 24 changed files with 124 additions and 88 deletions.
2 changes: 1 addition & 1 deletion groovy-eclipse.setup
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@
<repository
url="https://download.eclipse.org/eclipse/updates/4.23"/>
<repository
url="https://download.eclipse.org/eclipse/updates/4.23-I-builds/I20220223-1800"/>
url="https://download.eclipse.org/eclipse/updates/4.23-I-builds/I20220302-1800"/>
</repositoryList>
<repositoryList
name="2021-12">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,9 @@ public CompletionEngine(
this.lookupEnvironment =
new LookupEnvironment(this, this.compilerOptions, this.problemReporter, nameEnvironment);
this.parser =
// GROOVY edit
//new CompletionParser(this.problemReporter, this.requestor.isExtendedContextRequired(), monitor);
/* GROOVY edit
new CompletionParser(this.problemReporter, this.requestor.isExtendedContextRequired(), monitor);
*/
LanguageSupportFactory.getCompletionParser(this.compilerOptions, this.problemReporter, this.requestor.isExtendedContextRequired(), monitor);
// GROOVY end
this.owner = owner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,8 +810,9 @@ protected void handleInternalException(
}

public void initializeParser() {
// GROOVY edit
//this.parser = new Parser(this.problemReporter, this.options.parseLiteralExpressionsAsConstants);
/* GROOVY edit
this.parser = new Parser(this.problemReporter, this.options.parseLiteralExpressionsAsConstants);
*/
this.parser = LanguageSupportFactory.getParser(this, this.options, this.problemReporter, this.options.parseLiteralExpressionsAsConstants, 1);
// GROOVY end
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ protected BlockScope(int kind, Scope parent) {
/* Create the class scope & binding for the anonymous type.
*/
public final void addAnonymousType(TypeDeclaration anonymousType, ReferenceBinding superBinding) {
// GROOVY edit
//ClassScope anonymousClassScope = new ClassScope(this, anonymousType);
/* GROOVY edit
ClassScope anonymousClassScope = new ClassScope(this, anonymousType);
*/
ClassScope anonymousClassScope = anonymousType.newClassScope(this);
// GROOVY end
anonymousClassScope.buildAnonymousTypeBinding(
Expand All @@ -124,8 +125,9 @@ public final void addAnonymousType(TypeDeclaration anonymousType, ReferenceBindi
/* Create the class scope & binding for the local type.
*/
public final void addLocalType(TypeDeclaration localType) {
// GROOVY edit
//ClassScope localTypeScope = new ClassScope(this, localType);
/* GROOVY edit
ClassScope localTypeScope = new ClassScope(this, localType);
*/
ClassScope localTypeScope = localType.newClassScope(this);
// GROOVY end
addSubscope(localTypeScope);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,9 @@ private LocalTypeBinding buildLocalType(SourceTypeBinding enclosingType, Package
continue nextMember;
}
}
// GROOVY edit
//ClassScope memberScope = new ClassScope(this, this.referenceContext.memberTypes[i]);
/* GROOVY edit
ClassScope memberScope = new ClassScope(this, this.referenceContext.memberTypes[i]);
*/
ClassScope memberScope = this.referenceContext.memberTypes[i].newClassScope(this);
// GROOVY end
LocalTypeBinding memberBinding = memberScope.buildLocalType(localType, packageBinding);
Expand Down Expand Up @@ -424,8 +425,9 @@ private void buildMemberTypes(AccessRestriction accessRestriction) {
continue nextMember;
}
}
// GROOVY edit
//ClassScope memberScope = new ClassScope(this, memberContext);
/* GROOVY edit
ClassScope memberScope = new ClassScope(this, memberContext);
*/
ClassScope memberScope = memberContext.newClassScope(this);
// GROOVY end
memberTypeBindings[count++] = memberScope.buildType(sourceType, sourceType.fPackage, accessRestriction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ void buildTypeBindings(AccessRestriction accessRestriction) {
if (this.referenceContext.currentPackage != null
|| this.referenceContext.types != null
|| this.referenceContext.imports != null) {
// GROOVY edit
//problemReporter().packageIsNotExpectedPackage(this.referenceContext);
/* GROOVY edit
problemReporter().packageIsNotExpectedPackage(this.referenceContext);
*/
errorReported = reportPackageIsNotExpectedPackage(this.referenceContext);
// GROOVY end
}
Expand Down Expand Up @@ -207,8 +208,9 @@ void buildTypeBindings(AccessRestriction accessRestriction) {
checkPublicTypeNameMatchesFilename(typeDecl);
// GROOVY end

// GROOVY edit
//ClassScope child = new ClassScope(this, typeDecl);
/* GROOVY edit
ClassScope child = new ClassScope(this, typeDecl);
*/
ClassScope child = buildClassScope(this, typeDecl);
// GROOVY end
SourceTypeBinding type = child.buildType(null, this.fPackage, accessRestriction);
Expand Down Expand Up @@ -277,10 +279,11 @@ void checkAndSetImports() {
break;
}
}
// GROOVY edit
//ImportBinding[] resolvedImports = new ImportBinding[numberOfImports];
//resolvedImports[0] = getDefaultImports()[0];
//int index = 1;
/* GROOVY edit
ImportBinding[] resolvedImports = new ImportBinding[numberOfImports];
resolvedImports[0] = getDefaultImports()[0];
int index = 1;
*/
ImportBinding[] defaultImports = getDefaultImports();
int index = defaultImports.length;
ImportBinding[] resolvedImports = new ImportBinding[numberOfImports + defaultImports.length-1];
Expand All @@ -289,17 +292,19 @@ void checkAndSetImports() {

nextImport : for (int i = 0; i < numberOfStatements; i++) {
ImportReference importReference = this.referenceContext.imports[i];
// GROOVY edit
//char[][] compoundName = importReference.tokens;
/* GROOVY edit
char[][] compoundName = importReference.tokens;
*/
char[][] compoundName = importReference.getImportName();
// GROOVY end

// skip duplicates or imports of the current package
for (int j = 0; j < index; j++) {
ImportBinding resolved = resolvedImports[j];
if (resolved.onDemand == ((importReference.bits & ASTNode.OnDemand) != 0) && resolved.isStatic() == importReference.isStatic())
// GROOVY edit
//if (CharOperation.equals(compoundName, resolvedImports[j].compoundName))
/* GROOVY edit
if (CharOperation.equals(compoundName, resolvedImports[j].compoundName))
*/
if (CharOperation.equals(compoundName, resolvedImports[j].compoundName) && CharOperation.equals(importReference.getSimpleName(), resolvedImports[j].getSimpleName()))
// GROOVY end
continue nextImport;
Expand Down Expand Up @@ -459,10 +464,11 @@ void faultInImports() {
break;
}
}
// GROOVY edit
//this.tempImports = new ImportBinding[numberOfImports];
//this.tempImports[0] = getDefaultImports()[0];
//this.importPtr = 1;
/* GROOVY edit
this.tempImports = new ImportBinding[numberOfImports];
this.tempImports[0] = getDefaultImports()[0];
this.importPtr = 1;
*/
ImportBinding[] defaultImports = getDefaultImports();
this.importPtr = defaultImports.length;
this.tempImports = new ImportBinding[numberOfImports + this.importPtr-1];
Expand Down Expand Up @@ -492,8 +498,9 @@ void faultInImports() {
if ((importReference.bits & ASTNode.OnDemand) != 0) {
Binding importBinding = findImport(compoundName, compoundName.length);
if (!importBinding.isValidBinding()) {
// GROOVY edit
//problemReporter().importProblem(importReference, importBinding);
/* GROOVY edit
problemReporter().importProblem(importReference, importBinding);
*/
reportImportProblem(importReference, importBinding);
// GROOVY end
continue nextImport;
Expand Down Expand Up @@ -525,8 +532,9 @@ void faultInImports() {
} else {
unresolvedFound = true;
if (reportUnresolved) {
// GROOVY edit
//problemReporter().importProblem(importReference, importBinding);
/* GROOVY edit
problemReporter().importProblem(importReference, importBinding);
*/
reportImportProblem(importReference, importBinding);
// GROOVY end
}
Expand Down Expand Up @@ -668,8 +676,9 @@ private Binding findImport(char[][] compoundName, int length) {
if (type == null)
return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, i), null, ProblemReasons.NotFound);
}
// GROOVY edit
//if (!type.canBeSeenBy(this.fPackage))
/* GROOVY edit
if (!type.canBeSeenBy(this.fPackage))
*/
if (!canBeSeenBy(type, this.fPackage))
// GROOVY end
return new ProblemReferenceBinding(compoundName, type, ProblemReasons.NotVisible);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,9 @@ public void buildTypeBindings(CompilationUnitDeclaration unit, AccessRestriction
if (this.globalOptions.sourceLevel >= ClassFileConstants.JDK9) {
unitModule = unit.module(this);
}
// GROOVY edit
//scope = new CompilationUnitScope(unit, unitModule != null ? unitModule.environment : this);
/* GROOVY edit
scope = new CompilationUnitScope(unit, unitModule != null ? unitModule.environment : this);
*/
scope = unit.buildCompilationUnitScope(unitModule != null ? unitModule.environment : this);
// GROOVY end
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1545,8 +1545,9 @@ public CompilationUnit convert(org.eclipse.jdt.internal.compiler.ast.Compilation
this.compilationUnitSource = source;
this.compilationUnitSourceLength = source.length;
this.scanner.setSource(source, unit.compilationResult);
// GROOVY edit
//CompilationUnit compilationUnit = new CompilationUnit(this.ast);
/* GROOVY edit
CompilationUnit compilationUnit = new CompilationUnit(this.ast);
*/
CompilationUnit compilationUnit = unit.getSpecialDomCompilationUnit(this.ast);
if (compilationUnit == null) compilationUnit = new CompilationUnit(this.ast);
// GROOVY end
Expand Down Expand Up @@ -4430,8 +4431,9 @@ public Type convertType(TypeReference typeReference) {
type2 = convertType(arguments[i]);
parameterizedType.typeArguments().add(type2);
}
// GROOVY edit -- avoid IllegalArgumentException in setSourceRange below
//end = type2 != null ? type2.getStartPosition() + type2.getLength() - 1 : end;
/* GROOVY edit -- avoid IllegalArgumentException in setSourceRange below
end = type2 != null ? type2.getStartPosition() + type2.getLength() - 1 : end;
*/
if (type2 != null) {
if (start == -1) {
end = -3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,9 @@ public void acceptResult(CompilationResult compilationResult) {

@Override
public void initializeParser() {
// GROOVY edit
//this.parser = new CommentRecorderParser(this.problemReporter, false);
/* GROOVY edit
this.parser = new CommentRecorderParser(this.problemReporter, false);
*/
this.parser = LanguageSupportFactory.getParser(this, this.lookupEnvironment == null ? null : this.lookupEnvironment.globalOptions, this.problemReporter, false, LanguageSupportFactory.CommentRecorderParserVariant + 1);
// GROOVY end
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ public static CompilationUnitDeclaration buildModularCompilationUnit(
* at least contain one type.
*/
private CompilationUnitDeclaration convert(ISourceType[] sourceTypes, CompilationResult compilationResult) throws JavaModelException {
// GROOVY edit
//this.unit = new CompilationUnitDeclaration(this.problemReporter, compilationResult, 0);
/* GROOVY edit
this.unit = new CompilationUnitDeclaration(this.problemReporter, compilationResult, 0);
*/
this.unit = LanguageSupportFactory.newCompilationUnitDeclaration((ICompilationUnit) ((SourceTypeElementInfo) sourceTypes[0]).getHandle().getCompilationUnit(), this.problemReporter, compilationResult, 0);
// GROOVY end
// not filled at this point
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,9 @@ public IJavaElement findSharedWorkingCopy(IBufferFactory factory) {
*/
@Override
public ICompilationUnit findWorkingCopy(WorkingCopyOwner workingCopyOwner) {
// GROOVY edit
//CompilationUnit cu = new CompilationUnit((PackageFragment)this.getParent(), getElementName(), workingCopyOwner);
/* GROOVY edit
CompilationUnit cu = new CompilationUnit((PackageFragment)this.getParent(), getElementName(), workingCopyOwner);
*/
CompilationUnit cu = LanguageSupportFactory.newCompilationUnit((PackageFragment) this.getParent(), getElementName(), workingCopyOwner);
// GROOVY end
if (workingCopyOwner == DefaultWorkingCopyOwner.PRIMARY) {
Expand Down Expand Up @@ -936,8 +937,9 @@ public ICompilationUnit getPrimary() {
@Override
public JavaElement getPrimaryElement(boolean checkOwner) {
if (checkOwner && isPrimary()) return this;
// GROOVY edit
//return new CompilationUnit((PackageFragment)getParent(), getElementName(), DefaultWorkingCopyOwner.PRIMARY);
/* GROOVY edit
return new CompilationUnit((PackageFragment)getParent(), getElementName(), DefaultWorkingCopyOwner.PRIMARY);
*/
return LanguageSupportFactory.newCompilationUnit((PackageFragment) getParent(), getElementName(), DefaultWorkingCopyOwner.PRIMARY);
// GROOVY end
}
Expand Down Expand Up @@ -1040,8 +1042,9 @@ public ICompilationUnit getWorkingCopy(WorkingCopyOwner workingCopyOwner, IProbl

JavaModelManager manager = JavaModelManager.getJavaModelManager();

// GROOVY edit
//CompilationUnit workingCopy = new CompilationUnit((PackageFragment)getParent(), getElementName(), workingCopyOwner);
/* GROOVY edit
CompilationUnit workingCopy = new CompilationUnit((PackageFragment)getParent(), getElementName(), workingCopyOwner);
*/
CompilationUnit workingCopy = LanguageSupportFactory.newCompilationUnit((PackageFragment) getParent(), getElementName(), workingCopyOwner);
// GROOVY end
JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,9 @@ public static CompilationUnitDeclaration process(
*/
@Override
public void initializeParser() {
// GROOVY edit
//this.parser = new CommentRecorderParser(this.problemReporter, this.options.parseLiteralExpressionsAsConstants);
/* GROOVY edit
this.parser = new CommentRecorderParser(this.problemReporter, this.options.parseLiteralExpressionsAsConstants);
*/
this.parser = LanguageSupportFactory.getParser(this, this.lookupEnvironment == null ? null : this.lookupEnvironment.globalOptions, this.problemReporter, this.options.parseLiteralExpressionsAsConstants, LanguageSupportFactory.CommentRecorderParserVariant);
// GROOVY end
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,9 @@ private void processCompilationUnitResource(ICompilationUnit source, PackageFrag
// copy resource
IContainer destFolder = (IContainer)dest.getResource(); // can be an IFolder or an IProject
IFile destFile = destFolder.getFile(new Path(destName));
// GROOVY edit
//org.eclipse.jdt.internal.core.CompilationUnit destCU = new org.eclipse.jdt.internal.core.CompilationUnit(dest, destName, DefaultWorkingCopyOwner.PRIMARY);
/* GROOVY edit
org.eclipse.jdt.internal.core.CompilationUnit destCU = new org.eclipse.jdt.internal.core.CompilationUnit(dest, destName, DefaultWorkingCopyOwner.PRIMARY);
*/
org.eclipse.jdt.internal.core.CompilationUnit destCU = LanguageSupportFactory.newCompilationUnit(dest, destName, DefaultWorkingCopyOwner.PRIMARY);
// GROOVY end
if (!destFile.equals(sourceResource)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ private Object[] computeNonJavaResources(ArrayList entryNames) {
for (int i = 0; i < length; i++) {
String resName = (String) entryNames.get(i);
// consider that a .java file is not a non-java resource (see bug 12246 Packages view shows .class and .java files when JAR has source)
// GROOVY edit
//if (!Util.isJavaLikeFileName(resName)) {
/* GROOVY edit
if (!Util.isJavaLikeFileName(resName)) {
*/
if (!Util.isJavaLikeFileName(resName) || (isInteresting && LanguageSupportFactory.isInterestingSourceFile(resName))) {
// GROOVY end
IPath filePath = new Path(resName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,9 @@ protected IJavaElement getSourceElementAt(int position) throws JavaModelExceptio
return candidate == null ? child.getSourceElementAt(position) : candidate.getSourceElementAt(position);
}
child = --i>=0 ? (SourceRefElement) children[i] : null;
// GROOVY edit
//} while (child != null && child.getSourceRange().getOffset() == declarationStart);
/* GROOVY edit
} while (child != null && child.getSourceRange().getOffset() == declarationStart);
*/
} while (child instanceof IField && child.getSourceRange().getOffset() == declarationStart);
// GROOVY end
// position in field's type: use first field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2808,8 +2808,9 @@ public ICompilationUnit[] getWorkingCopies(WorkingCopyOwner owner, boolean addPr
if (primaryWCs != null) {
for (int i = 0; i < primaryLength; i++) {
ICompilationUnit primaryWorkingCopy = primaryWCs[i];
// GROOVY edit
//ICompilationUnit workingCopy = new CompilationUnit((PackageFragment) primaryWorkingCopy.getParent(), primaryWorkingCopy.getElementName(), owner);
/* GROOVY edit
ICompilationUnit workingCopy = new CompilationUnit((PackageFragment) primaryWorkingCopy.getParent(), primaryWorkingCopy.getElementName(), owner);
*/
ICompilationUnit workingCopy = LanguageSupportFactory.newCompilationUnit((PackageFragment) primaryWorkingCopy.getParent(), primaryWorkingCopy.getElementName(), owner);
// GROOVY end
if (!workingCopyToInfos.containsKey(workingCopy))
Expand Down
Loading

0 comments on commit 3585798

Please sign in to comment.