Skip to content

Commit

Permalink
Implement the extension point
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Stryker <[email protected]>

Javadoc for added interface

Signed-off-by: Rob Stryker <[email protected]>

More docs
  • Loading branch information
Rob Stryker committed Jun 12, 2024
1 parent 119abcd commit d58ca48
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 16 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.jdt.core.javac/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Javac
Bundle-SymbolicName: org.eclipse.jdt.core.javac
Bundle-SymbolicName: org.eclipse.jdt.core.javac;singleton:=true
Bundle-Version: 1.0.0.qualifier
Fragment-Host: org.eclipse.jdt.core
Automatic-Module-Name: org.eclipse.jdt.core.javac
Expand Down
3 changes: 2 additions & 1 deletion org.eclipse.jdt.core.javac/build.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
.,\
fragment.xml
12 changes: 12 additions & 0 deletions org.eclipse.jdt.core.javac/fragment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<fragment>
<extension
point="org.eclipse.jdt.core.compilationUnitResolver">
<resolver
class="org.eclipse.jdt.core.dom.JavacCompilationUnitResolver"
id="org.eclipse.jdt.core.dom.JavacCompilationUnitResolver">
</resolver>
</extension>

</fragment>
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@
* Allows to create and resolve DOM ASTs using Javac
* @implNote Cannot move to another package because parent class is package visible only
*/
class JavacCompilationUnitResolver implements ICompilationUnitResolver {
public class JavacCompilationUnitResolver implements ICompilationUnitResolver {
public JavacCompilationUnitResolver() {
// 0-arg constructor
}
private interface GenericRequestor {
public void acceptBinding(String bindingKey, IBinding binding);
}
Expand Down Expand Up @@ -337,7 +340,7 @@ private void resolveBindings(CompilationUnit unit, String[] bindingKeys, ASTRequ
@Override
public CompilationUnit toCompilationUnit(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit,
boolean initialNeedsToResolveBinding, IJavaProject project, List<Classpath> classpaths,
NodeSearcher nodeSearcher, int apiLevel, Map<String, String> compilerOptions,
int focalPoint, int apiLevel, Map<String, String> compilerOptions,
WorkingCopyOwner workingCopyOwner, WorkingCopyOwner typeRootWorkingCopyOwner, int flags, IProgressMonitor monitor) {
// TODO currently only parse
CompilationUnit res = parse(new org.eclipse.jdt.internal.compiler.env.ICompilationUnit[] { sourceUnit},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,88 @@
import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;

/**
* This interface is used to resolve a jdt dom tree from source files.
* It is contributed via the compilationUnitResolver extension point.
*
* @since 3.38
*/
public interface ICompilationUnitResolver {
/**
* Resolve the given source paths with the following options.
*
* @param sourceFilePaths the compilation units to create ASTs for
* @param encodings the given encoding for the source units
* @param bindingKeys the binding keys to create bindings for
* @param requestor the AST requestor that collects abstract syntax trees and bindings
* @param apiLevel Level of AST API desired.
* @param compilerOptions Compiler options. Defaults to JavaCore.getOptions().
* @param classpathList A list of classpaths to use during this operation
* @param flags Flags to to be used during this operation
* @param monitor A progress monitor
*/
void resolve(String[] sourceFilePaths, String[] encodings, String[] bindingKeys, FileASTRequestor requestor,
int apiLevel, Map<String, String> compilerOptions, List<Classpath> list, int flags,
int apiLevel, Map<String, String> compilerOptions, List<Classpath> classpathList, int flags,
IProgressMonitor monitor);

/**
* Parse the given source paths with the following options.
*
* @param compilationUnits the compilation units to create ASTs for
* @param requestor the AST requestor that collects abstract syntax trees and bindings
* @param apiLevel Level of AST API desired.
* @param compilerOptions Compiler options. Defaults to JavaCore.getOptions().
* @param flags Flags to to be used during this operation
* @param monitor A progress monitor
*/
void parse(ICompilationUnit[] compilationUnits, ASTRequestor requestor, int apiLevel,
Map<String, String> compilerOptions, int flags, IProgressMonitor monitor);

/**
*
* @param sourceFilePaths the compilation units to create ASTs for
* @param encodings the given encoding for the source units
* @param requestor the AST requester that collects abstract syntax trees and bindings
* @param apiLevel Level of AST API desired.
* @param compilerOptions Compiler options. Defaults to JavaCore.getOptions().
* @param flags Flags to to be used during this operation
* @param monitor A progress monitor
*/
void parse(String[] sourceFilePaths, String[] encodings, FileASTRequestor requestor, int apiLevel,
Map<String, String> compilerOptions, int flags, IProgressMonitor monitor);

/**
*
* @param compilationUnits the compilation units to create ASTs for
* @param bindingKeys the binding keys to create bindings for
* @param requestor the AST requester that collects abstract syntax trees and bindings
* @param apiLevel Level of AST API desired.
* @param compilerOptions Compiler options. Defaults to JavaCore.getOptions().
* @param project The project providing the context of the resolution
* @param workingCopyOwner The owner of the working copy
* @param flags Flags to to be used during this operation
* @param monitor A progress monitor
*/
void resolve(ICompilationUnit[] compilationUnits, String[] bindingKeys, ASTRequestor requestor, int apiLevel,
Map<String, String> compilerOptions, IJavaProject project, WorkingCopyOwner workingCopyOwner, int flags,
IProgressMonitor monitor);



/**
* Convert the given source unit into a CompilationUnit using the following options.
*
* @param sourceUnit
* @param initialNeedsToResolveBinding
* @param project
* @param classpaths
* @param sourceUnit A source unit
* @param initialNeedsToResolveBinding Initial guess as to whether we need to resolve bindings
* @param project The project providing the context of the conversion
* @param classpaths A list of classpaths to use during this operation
* @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
* @param apiLevel Level of AST API desired.
* @param compilerOptions Compiler options. Defaults to JavaCore.getOptions().
* @param parsedUnitWorkingCopyOwner The working copy owner of the unit
* @param typeRootWorkingCopyOwner The working copy owner of the type
* @param flags Flags to to be used during this operation
* @param monitor A progress monitor
* @return A CompilationUnit
*/
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);
Expand Down

0 comments on commit d58ca48

Please sign in to comment.