Java Code Examples for com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver#add()
The following examples show how to use
com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SourceExplorer.java From jeddict with Apache License 2.0 | 7 votes |
private void configureJavaParser(FileObject sourceRoot) { // Set up a minimal type solver that only looks at the classes used to run this sample. CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver(); combinedTypeSolver.add(new JavaParserTypeSolver(FileUtil.toFile(sourceRoot))); combinedTypeSolver.add(new ReflectionTypeSolver()); SourceGroup sourceGroup = getFolderSourceGroup(sourceRoot); Project project = FileOwnerQuery.getOwner(sourceRoot); List<ClassLoader> classLoaders = getClassLoaders(project, sourceGroup); for (ClassLoader classLoader : classLoaders) { combinedTypeSolver.add(new ClassloaderTypeSolver(classLoader)); } // Configure JavaParser to use type resolution JavaSymbolSolver symbolSolver = new JavaSymbolSolver(combinedTypeSolver); javaParser.getParserConfiguration().setSymbolResolver(symbolSolver); }
Example 2
Source File: Context.java From apigcc with MIT License | 6 votes |
/** * 构建TypeSolver * @return */ public TypeSolver buildTypeSolver(){ CombinedTypeSolver typeSolver = new CombinedTypeSolver(); for (Path dependency : dependencies) { typeSolver.add(new JavaParserTypeSolver(dependency)); } for (Path jar : jars) { try { typeSolver.add(new JarTypeSolver(jar)); } catch (IOException e) { log.warn("exception on {} {}", jar, e.getMessage()); } } if (!codeTypeDeclarations.isEmpty()) { for (CodeTypeDeclaration codeTypeDeclaration : codeTypeDeclarations) { Path path = dependencyPath.resolve(codeTypeDeclaration.path()); FileHelper.write(path, codeTypeDeclaration.code()); } typeSolver.add(new JavaParserTypeSolver(dependencyPath)); } typeSolver.add(new ReflectionTypeSolver()); return typeSolver; }
Example 3
Source File: RemoveMethodParameter.java From Refactoring-Bot with MIT License | 5 votes |
private void configureJavaParserForProject(BotIssue issue) { CombinedTypeSolver typeSolver = new CombinedTypeSolver(); for (String javaRoot : issue.getJavaRoots()) { typeSolver.add(new JavaParserTypeSolver(javaRoot)); } typeSolver.add(new ReflectionTypeSolver()); JavaSymbolSolver javaSymbolSolver = new JavaSymbolSolver(typeSolver); StaticJavaParser.getConfiguration().setSymbolResolver(javaSymbolSolver); }
Example 4
Source File: RenameMethod.java From Refactoring-Bot with MIT License | 5 votes |
private void configureJavaParserForProject(BotIssue issue) { CombinedTypeSolver typeSolver = new CombinedTypeSolver(); for (String javaRoot : issue.getJavaRoots()) { typeSolver.add(new JavaParserTypeSolver(javaRoot)); } typeSolver.add(new ReflectionTypeSolver()); JavaSymbolSolver javaSymbolSolver = new JavaSymbolSolver(typeSolver); StaticJavaParser.getConfiguration().setSymbolResolver(javaSymbolSolver); }
Example 5
Source File: RefactoringHelperTest.java From Refactoring-Bot with MIT License | 5 votes |
private void configureStaticJavaParserForResolving() { CombinedTypeSolver typeSolver = new CombinedTypeSolver(); String javaRoot = TestUtils.getAbsolutePathOfTestsFolder(); typeSolver.add(new JavaParserTypeSolver(javaRoot)); typeSolver.add(new ReflectionTypeSolver()); JavaSymbolSolver javaSymbolSolver = new JavaSymbolSolver(typeSolver); StaticJavaParser.getConfiguration().setSymbolResolver(javaSymbolSolver); }
Example 6
Source File: OpenApiObjectGenerator.java From flow with Apache License 2.0 | 5 votes |
private ParserConfiguration createParserConfiguration() { CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver( new ReflectionTypeSolver(false)); if (typeResolverClassLoader != null) { combinedTypeSolver .add(new ClassLoaderTypeSolver(typeResolverClassLoader)); } return new ParserConfiguration() .setSymbolResolver(new JavaSymbolSolver(combinedTypeSolver)); }