Java Code Examples for com.github.javaparser.symbolsolver.JavaSymbolSolver

The following examples show how to use com.github.javaparser.symbolsolver.JavaSymbolSolver. These examples are extracted from open source projects. 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 Project: jeddict   Source File: SourceExplorer.java    License: Apache License 2.0 6 votes vote down vote up
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 Project: apigcc   Source File: Apigcc.java    License: MIT License 5 votes vote down vote up
/**
 * 初始化环境配置
 *
 * @param context
 */
private void init(Context context) {
    INSTANCE = this;
    this.context = context;
    this.project.init(this.context);

    ParserStrategy strategy = this.loadParserStrategy();
    strategy.onLoad();
    this.visitorParser.setParserStrategy(strategy);

    this.parserConfiguration.setSymbolResolver(new JavaSymbolSolver(this.context.buildTypeSolver()));
}
 
Example 3
Source Project: Refactoring-Bot   Source File: RemoveMethodParameter.java    License: MIT License 5 votes vote down vote up
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 Project: Refactoring-Bot   Source File: RenameMethod.java    License: MIT License 5 votes vote down vote up
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 Project: Refactoring-Bot   Source File: RefactoringHelperTest.java    License: MIT License 5 votes vote down vote up
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 Project: Recaf   Source File: Workspace.java    License: MIT License 5 votes vote down vote up
/**
 * Creates a source config with a type resolver that can access all types in the workspace.
 */
public void updateSourceConfig() {
	TypeSolver solver = new WorkspaceTypeResolver(this);
	config = new ParserConfiguration()
			.setSymbolResolver(new JavaSymbolSolver(solver))
			.setLanguageLevel(ParserConfiguration.LanguageLevel.JAVA_14);
}
 
Example 7
Source Project: flow   Source File: OpenApiObjectGenerator.java    License: Apache License 2.0 5 votes vote down vote up
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));
}
 
Example 8
Source Project: JRemapper   Source File: Input.java    License: MIT License 4 votes vote down vote up
/**
 * Creates a source config with a type resolver that can access all types in the workspace.
 */
public void updateSourceConfig() {
	config = new ParserConfiguration().setSymbolResolver(new JavaSymbolSolver(this));
}