com.github.javaparser.ParserConfiguration Java Examples
The following examples show how to use
com.github.javaparser.ParserConfiguration.
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: ModuleName.java From gradle-modules-plugin with MIT License | 6 votes |
private Optional<String> findModuleName(Path moduleInfoJava, String projectPath) { try { JavaParser parser = new JavaParser(); parser.getParserConfiguration().setLanguageLevel(ParserConfiguration.LanguageLevel.JAVA_11); Optional<CompilationUnit> compilationUnit = parser.parse(moduleInfoJava).getResult(); if (compilationUnit.isEmpty()) { LOGGER.debug("Project {} => compilation unit is empty", projectPath); return Optional.empty(); } Optional<ModuleDeclaration> module = compilationUnit.get().getModule(); if (module.isEmpty()) { LOGGER.warn("Project {} => module-info.java found, but module name could not be parsed", projectPath); return Optional.empty(); } String name = module.get().getName().toString(); LOGGER.lifecycle("Project {} => '{}' Java module", projectPath, name); return Optional.of(name); } catch (IOException e) { LOGGER.error("Project {} => error opening module-info.java at {}", projectPath, moduleInfoJava); return Optional.empty(); } }
Example #2
Source File: Workspace.java From Recaf with MIT License | 5 votes |
/** * 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 #3
Source File: OpenApiObjectGenerator.java From flow with Apache License 2.0 | 5 votes |
private void init() { if (javaSourcePaths == null || configuration == null) { throw new IllegalStateException( "Java source path and configuration should not be null"); } openApiModel = createBasicModel(); nonEndpointMap = new HashMap<>(); qualifiedNameToPath = new HashMap<>(); pathItems = new TreeMap<>(); usedTypes = new HashMap<>(); generatedSchema = new HashSet<>(); endpointsJavadoc = new HashMap<>(); schemaResolver = new SchemaResolver(); ParserConfiguration parserConfiguration = createParserConfiguration(); javaSourcePaths.stream() .map(path -> new SourceRoot(path, parserConfiguration)) .forEach(this::parseSourceRoot); for (Map.Entry<String, ResolvedReferenceType> entry : usedTypes .entrySet()) { List<Schema> schemas = createSchemasFromQualifiedNameAndType( entry.getKey(), entry.getValue()); schemas.forEach(schema -> { if (qualifiedNameToPath.get(schema.getName()) != null) { schema.addExtension(EXTENSION_VAADIN_FILE_PATH, qualifiedNameToPath.get(schema.getName())); } openApiModel.getComponents().addSchemas(schema.getName(), schema); }); } addTagsInformation(); }
Example #4
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)); }
Example #5
Source File: Workspace.java From Recaf with MIT License | 4 votes |
/** * @return JavaParser config to assist in resolving symbols. */ public ParserConfiguration getSourceParseConfig() { if (config == null) updateSourceConfig(); return config; }