Search in sources :

Example 6 with ParseProblemException

use of com.github.javaparser.ParseProblemException in project javaparser by javaparser.

the class JavadocExtractorTest method processFile.

private void processFile(File file) throws FileNotFoundException {
    try {
        CompilationUnit cu = JavaParser.parse(file, StandardCharsets.UTF_8);
        new VoidVisitorAdapter<Object>() {

            @Override
            public void visit(JavadocComment n, Object arg) {
                super.visit(n, arg);
                n.parse();
            }
        }.visit(cu, null);
    } catch (ParseProblemException e) {
        System.err.println("ERROR PROCESSING " + file);
    }
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) JavadocComment(com.github.javaparser.ast.comments.JavadocComment) ParseProblemException(com.github.javaparser.ParseProblemException)

Example 7 with ParseProblemException

use of com.github.javaparser.ParseProblemException in project structr by structr.

the class AnalyzeJavaFunction method apply.

@Override
public Object apply(final ActionContext ctx, final Object caller, final Object[] sources) throws FrameworkException {
    try {
        if (!(arrayHasLengthAndAllElementsNotNull(sources, 1) && sources[0] instanceof String)) {
            return null;
        }
        try {
            final SecurityContext securityContext = ctx.getSecurityContext();
            final App app = StructrApp.getInstance(securityContext);
            // Analyze string as Java code
            new JavaParserModule(app).analyzeMethodsInJavaFile((String) sources[0]);
            return "";
        } catch (final ParseProblemException ex) {
            logException(caller, ex, sources);
        }
    } catch (final IllegalArgumentException e) {
        logParameterError(caller, sources, ctx.isJavaScriptContext());
        return usage(ctx.isJavaScriptContext());
    }
    return "";
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) SecurityContext(org.structr.common.SecurityContext) ParseProblemException(com.github.javaparser.ParseProblemException)

Aggregations

ParseProblemException (com.github.javaparser.ParseProblemException)7 CompilationUnit (com.github.javaparser.ast.CompilationUnit)3 SecurityContext (org.structr.common.SecurityContext)2 App (org.structr.core.app.App)2 StructrApp (org.structr.core.app.StructrApp)2 TemplateExpression (com.axellience.vuegwt.processors.component.template.parser.result.TemplateExpression)1 LocalVariableInfo (com.axellience.vuegwt.processors.component.template.parser.variable.LocalVariableInfo)1 VariableInfo (com.axellience.vuegwt.processors.component.template.parser.variable.VariableInfo)1 StubUnit (com.github.javaparser.ast.StubUnit)1 JavadocComment (com.github.javaparser.ast.comments.JavadocComment)1 Expression (com.github.javaparser.ast.expr.Expression)1 GsonBuilder (com.google.gson.GsonBuilder)1 BufferedWriter (java.io.BufferedWriter)1 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 LinkedList (java.util.LinkedList)1 File (org.structr.web.entity.File)1 IndexFileWriter (scenelib.annotations.io.IndexFileWriter)1