Skip to content

Commit

Permalink
Clean up API changes and proposed interface
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Stryker <[email protected]>
  • Loading branch information
Rob Stryker committed Jun 11, 2024
1 parent 2fca795 commit 0223aa7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ private ASTNode internalCreateASTCached(IProgressMonitor monitor) {
break;
case K_COMPILATION_UNIT :
try {
NodeSearcher searcher = null;
boolean useSearcher = false;
org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = null;
WorkingCopyOwner wcOwner = this.workingCopyOwner;
if (this.typeRoot instanceof ClassFileWorkingCopy) {
Expand Down Expand Up @@ -1233,13 +1233,13 @@ private ASTNode internalCreateASTCached(IProgressMonitor monitor) {
throw new IllegalStateException();
}
if ((this.bits & CompilationUnitResolver.PARTIAL) != 0) {
searcher = new NodeSearcher(this.focalPointPosition);
useSearcher = true;
}
int flags = 0;
if ((this.bits & CompilationUnitResolver.STATEMENT_RECOVERY) != 0) {
flags |= ICompilationUnit.ENABLE_STATEMENTS_RECOVERY;
}
if (searcher == null && ((this.bits & CompilationUnitResolver.IGNORE_METHOD_BODIES) != 0)) {
if (!useSearcher && ((this.bits & CompilationUnitResolver.IGNORE_METHOD_BODIES) != 0)) {
flags |= ICompilationUnit.IGNORE_METHOD_BODIES;
}

Expand All @@ -1249,7 +1249,7 @@ private ASTNode internalCreateASTCached(IProgressMonitor monitor) {
}
}

CompilationUnit result2 = this.unitResolver.toCompilationUnit(sourceUnit, needToResolveBindings, this.project, getClasspath(), searcher, this.apiLevel, this.compilerOptions, this.workingCopyOwner, wcOwner, flags, monitor);
CompilationUnit result2 = this.unitResolver.toCompilationUnit(sourceUnit, needToResolveBindings, this.project, getClasspath(), useSearcher ? this.focalPointPosition : -1, this.apiLevel, this.compilerOptions, this.workingCopyOwner, wcOwner, flags, monitor);
result2.setTypeRoot(this.typeRoot);
return result2;
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ public void resolve(ICompilationUnit[] compilationUnits, String[] bindingKeys, A
}

@Override
public CompilationUnit toCompilationUnit(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, final boolean initialNeedsToResolveBinding, IJavaProject project, List<Classpath> classpaths, NodeSearcher nodeSearcher,
public CompilationUnit toCompilationUnit(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, final boolean initialNeedsToResolveBinding, IJavaProject project, List<Classpath> classpaths, int focalPosition,
int apiLevel, Map<String, String> compilerOptions, WorkingCopyOwner parsedUnitWorkingCopyOwner, WorkingCopyOwner typeRootWorkingCopyOwner, int flags, IProgressMonitor monitor) {
return CompilationUnitResolver.toCompilationUnit(sourceUnit, initialNeedsToResolveBinding, project,
classpaths, nodeSearcher, apiLevel, compilerOptions, parsedUnitWorkingCopyOwner, typeRootWorkingCopyOwner, flags, monitor);
classpaths, focalPosition == -1 ? null : new NodeSearcher(focalPosition), apiLevel, compilerOptions, parsedUnitWorkingCopyOwner, typeRootWorkingCopyOwner, flags, monitor);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ void resolve(ICompilationUnit[] compilationUnits, String[] bindingKeys, ASTReque
Map<String, String> compilerOptions, IJavaProject project, WorkingCopyOwner workingCopyOwner, int flags,
IProgressMonitor monitor);

CompilationUnit toCompilationUnit(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, final boolean initialNeedsToResolveBinding, IJavaProject project, List<Classpath> classpaths, NodeSearcher nodeSearcher,
/**
*
* @param sourceUnit
* @param initialNeedsToResolveBinding
* @param project
* @param classpaths
* @param focalPosition a position to focus on, or -1 if N/A
* @param apiLevel
* @param compilerOptions
* @param parsedUnitWorkingCopyOwner
* @param typeRootWorkingCopyOwner
* @param flags
* @param monitor
* @return
*/
CompilationUnit toCompilationUnit(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, final boolean initialNeedsToResolveBinding, IJavaProject project, List<Classpath> classpaths, int focalPosition,
int apiLevel, Map<String, String> compilerOptions, WorkingCopyOwner parsedUnitWorkingCopyOwner, WorkingCopyOwner typeRootWorkingCopyOwner, int flags, IProgressMonitor monitor);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;

/**
* @since 3.38
*/
public class NodeSearcher extends ASTVisitor {
class NodeSearcher extends ASTVisitor {
public org.eclipse.jdt.internal.compiler.ast.ASTNode found;
public TypeDeclaration enclosingType;
public int position;
Expand Down

0 comments on commit 0223aa7

Please sign in to comment.