tools/java/src/stx/libjava/tools/parser/Parser.java
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 12 Sep 2013 00:24:05 +0100
branchdevelopment
changeset 2728 658220e93dc9
parent 2723 tools/java/src/stx/libjava/tools/source/JavaSourceParser.java@02802ba0024f
child 2729 ac412f6ea6d4
permissions -rw-r--r--
Java package reorganization. Compiler-related support classes moved to package tools, java package structure reorganized, classes renamed. The goal is to use same INameEnvironment and ICompulationUnit implementation for both compiling and parsing, highlighting and resolving.

package stx.libjava.tools.parser;

import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;


public class Parser extends org.eclipse.jdt.internal.compiler.parser.Parser {
    
    public Parser() {
        this(
                new ProblemReporter(
                        DefaultErrorHandlingPolicies.proceedWithAllProblems(), 
                        new CompilerOptions(), 
                        new DefaultProblemFactory()),
                true);                
    }
    

    public Parser(ProblemReporter problemReporter,
            boolean optimizeStringLiterals) {
        super(problemReporter, optimizeStringLiterals);
        options.docCommentSupport = true;
        javadocParser.checkDocComment = true;
    }

    public CompilationUnitDeclaration parse(ICompilationUnit cu, boolean diet) {
        if (diet) {
            return dietParse(cu, new CompilationResult(cu, 1, 1, 1000));
        } else {
            return parse(cu, new CompilationResult(cu, 1, 1, 1000 ));            
        }
    }

}