@@ -211,7 +211,7 @@ public void resolve(String[] sourceFilePaths, String[] encodings, String[] bindi
211211
212212 // parse source units
213213 Map <org .eclipse .jdt .internal .compiler .env .ICompilationUnit , CompilationUnit > res =
214- parse (sourceUnitList .toArray (org .eclipse .jdt .internal .compiler .env .ICompilationUnit []::new ), apiLevel , compilerOptions , true , flags , (IJavaProject )null , null , -1 , monitor );
214+ parse (sourceUnitList .toArray (org .eclipse .jdt .internal .compiler .env .ICompilationUnit []::new ), apiLevel , compilerOptions , true , flags , (IJavaProject )null , classpaths , null , -1 , monitor );
215215
216216 for (var entry : res .entrySet ()) {
217217 CompilationUnit cu = entry .getValue ();
@@ -361,7 +361,7 @@ private void resolveRequestedBindingKeys(JavacBindingResolver bindingResolver, S
361361 if (binding == null && arrayCount > 0 ) {
362362 String elementKey = Signature .getElementType (bindingKey );
363363 IBinding elementBinding = bindingMap .get (elementKey );
364- if (elementBinding instanceof ITypeBinding elementTypeBinding ) {
364+ if (elementBinding instanceof ITypeBinding ) {
365365 binding = elementBinding ;
366366 }
367367 }
@@ -434,7 +434,7 @@ private Map<ICompilationUnit, CompilationUnit> parse(ICompilationUnit[] compilat
434434 parse (Arrays .stream (compilationUnits )
435435 .map (org .eclipse .jdt .internal .compiler .env .ICompilationUnit .class ::cast )
436436 .toArray (org .eclipse .jdt .internal .compiler .env .ICompilationUnit []::new ),
437- apiLevel , compilerOptions , resolveBindings , flags , compilationUnits [0 ].getJavaProject (), workingCopyOwner , -1 , monitor )
437+ apiLevel , compilerOptions , resolveBindings , flags , compilationUnits [0 ].getJavaProject (), null , workingCopyOwner , -1 , monitor )
438438 .entrySet ().stream ().collect (Collectors .toMap (entry -> (ICompilationUnit )entry .getKey (), entry -> entry .getValue ()));
439439 for (ICompilationUnit in : compilationUnits ) {
440440 CompilationUnit c = res .get (in );
@@ -448,7 +448,7 @@ private Map<ICompilationUnit, CompilationUnit> parse(ICompilationUnit[] compilat
448448 for (ICompilationUnit in : compilationUnits ) {
449449 if (in instanceof org .eclipse .jdt .internal .compiler .env .ICompilationUnit compilerUnit ) {
450450 res .put (in , parse (new org .eclipse .jdt .internal .compiler .env .ICompilationUnit [] { compilerUnit },
451- apiLevel , compilerOptions , resolveBindings , flags , in .getJavaProject (), workingCopyOwner , -1 , monitor ).get (compilerUnit ));
451+ apiLevel , compilerOptions , resolveBindings , flags , in .getJavaProject (), null , workingCopyOwner , -1 , monitor ).get (compilerUnit ));
452452 res .get (in ).setTypeRoot (in );
453453 }
454454 }
@@ -462,7 +462,7 @@ public void parse(String[] sourceFilePaths, String[] encodings, FileASTRequestor
462462 for ( int i = 0 ; i < sourceFilePaths .length ; i ++ ) {
463463 org .eclipse .jdt .internal .compiler .env .ICompilationUnit ast = createSourceUnit (sourceFilePaths [i ], encodings [i ]);
464464 Map <org .eclipse .jdt .internal .compiler .env .ICompilationUnit , CompilationUnit > res =
465- parse (new org .eclipse .jdt .internal .compiler .env .ICompilationUnit [] {ast }, apiLevel , compilerOptions , false , flags , (IJavaProject )null , null , -1 , monitor );
465+ parse (new org .eclipse .jdt .internal .compiler .env .ICompilationUnit [] {ast }, apiLevel , compilerOptions , false , flags , (IJavaProject )null , null , null , -1 , monitor );
466466 CompilationUnit result = res .get (ast );
467467 requestor .acceptAST (sourceFilePaths [i ], result );
468468 }
@@ -574,7 +574,7 @@ public CompilationUnit toCompilationUnit(org.eclipse.jdt.internal.compiler.env.I
574574
575575 //CompilationUnit res2 = CompilationUnitResolver.getInstance().toCompilationUnit(sourceUnit, resolveBindings, project, classpaths, focalPoint, apiLevel, compilerOptions, typeRootWorkingCopyOwner, typeRootWorkingCopyOwner, flags, monitor);
576576 CompilationUnit res = parse (pathToUnit .values ().toArray (org .eclipse .jdt .internal .compiler .env .ICompilationUnit []::new ),
577- apiLevel , compilerOptions , resolveBindings , flags | (resolveBindings ? AST .RESOLVED_BINDINGS : 0 ), project , typeRootWorkingCopyOwner , focalPoint , monitor ).get (sourceUnit );
577+ apiLevel , compilerOptions , resolveBindings , flags | (resolveBindings ? AST .RESOLVED_BINDINGS : 0 ), project , classpaths , typeRootWorkingCopyOwner , focalPoint , monitor ).get (sourceUnit );
578578 if (resolveBindings && focalPoint == -1 ) {
579579 // force analysis and reports
580580 resolveBindings (res , apiLevel );
@@ -590,7 +590,7 @@ public void dispose() {
590590 };
591591
592592 private Map <org .eclipse .jdt .internal .compiler .env .ICompilationUnit , CompilationUnit > parse (org .eclipse .jdt .internal .compiler .env .ICompilationUnit [] sourceUnits , int apiLevel ,
593- Map <String , String > compilerOptions , boolean resolveBindings , int flags , IJavaProject javaProject , WorkingCopyOwner workingCopyOwner ,
593+ Map <String , String > compilerOptions , boolean resolveBindings , int flags , IJavaProject javaProject , List < Classpath > extraClasspath , WorkingCopyOwner workingCopyOwner ,
594594 int focalPoint , IProgressMonitor monitor ) {
595595 if (sourceUnits .length == 0 ) {
596596 return Collections .emptyMap ();
@@ -715,6 +715,16 @@ public Void visitClass(ClassTree node, Void p) {
715715 // continue as far as possible to get extra warnings about unused
716716 .ifPresent (_ ->javacOptions .put ("should-stop.ifError" , CompileState .GENERATE .toString ()));
717717 JavacFileManager fileManager = (JavacFileManager )context .get (JavaFileManager .class );
718+ if (javaProject == null && extraClasspath != null ) {
719+ try {
720+ fileManager .setLocation (StandardLocation .CLASS_PATH , extraClasspath .stream ()
721+ .map (Classpath ::getPath )
722+ .map (File ::new )
723+ .toList ());
724+ } catch (IOException ex ) {
725+ ILog .get ().error (ex .getMessage (), ex );
726+ }
727+ }
718728 List <JavaFileObject > fileObjects = new ArrayList <>(); // we need an ordered list of them
719729 for (org .eclipse .jdt .internal .compiler .env .ICompilationUnit sourceUnit : sourceUnits ) {
720730 char [] sourceUnitFileName = sourceUnit .getFileName ();
0 commit comments