Search in sources :

Example 16 with CompilationUnitDeclaration

use of org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration in project lombok by rzwitserloot.

the class PatchExtensionMethod method getTypeNode.

public static EclipseNode getTypeNode(TypeDeclaration decl) {
    CompilationUnitDeclaration cud = decl.scope.compilationUnitScope().referenceContext;
    EclipseAST astNode = TransformEclipseAST.getAST(cud, false);
    EclipseNode node = astNode.get(decl);
    if (node == null) {
        astNode = TransformEclipseAST.getAST(cud, true);
        node = astNode.get(decl);
    }
    return node;
}
Also used : CompilationUnitDeclaration(org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration) EclipseNode(lombok.eclipse.EclipseNode) EclipseAST(lombok.eclipse.EclipseAST) TransformEclipseAST(lombok.eclipse.TransformEclipseAST)

Example 17 with CompilationUnitDeclaration

use of org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration in project webpieces by deanhiller.

the class CompilerWrapper method compile.

/**
     * Please compile this className
     */
@SuppressWarnings("deprecation")
public void compile(String[] classNames, ClassDefinitionLoader loader) {
    ICompilationUnit[] compilationUnits = new CompilationUnit[classNames.length];
    for (int i = 0; i < classNames.length; i++) {
        compilationUnits[i] = new CompilationUnit(classNames[i]);
    }
    IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitOnFirstError();
    IProblemFactory problemFactory = new DefaultProblemFactory(Locale.ENGLISH);
    /**
         * To find types ...
         */
    INameEnvironment nameEnvironment = new INameEnvironmentImpl(loader);
    /**
         * Compilation result
         */
    ICompilerRequestor compilerRequestor = new ICompilerRequestorImpl();
    /**
         * The JDT compiler
         */
    Compiler jdtCompiler = new Compiler(nameEnvironment, policy, settings, compilerRequestor, problemFactory) {

        @Override
        protected void handleInternalException(Throwable e, CompilationUnitDeclaration ud, CompilationResult result) {
        }
    };
    // Go !
    jdtCompiler.compile(compilationUnits);
}
Also used : ICompilationUnit(org.eclipse.jdt.internal.compiler.env.ICompilationUnit) IErrorHandlingPolicy(org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy) ICompilationUnit(org.eclipse.jdt.internal.compiler.env.ICompilationUnit) Compiler(org.eclipse.jdt.internal.compiler.Compiler) ICompilerRequestor(org.eclipse.jdt.internal.compiler.ICompilerRequestor) CompilationUnitDeclaration(org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration) INameEnvironment(org.eclipse.jdt.internal.compiler.env.INameEnvironment) DefaultProblemFactory(org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory) CompilationResult(org.eclipse.jdt.internal.compiler.CompilationResult) IProblemFactory(org.eclipse.jdt.internal.compiler.IProblemFactory)

Aggregations

CompilationUnitDeclaration (org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration)17 CompilationResult (org.eclipse.jdt.internal.compiler.CompilationResult)4 DefaultProblemFactory (org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory)4 CategorizedProblem (org.eclipse.jdt.core.compiler.CategorizedProblem)3 Compiler (org.eclipse.jdt.internal.compiler.Compiler)3 ICompilerRequestor (org.eclipse.jdt.internal.compiler.ICompilerRequestor)3 AbstractMethodDeclaration (org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration)3 ICompilationUnit (org.eclipse.jdt.internal.compiler.env.ICompilationUnit)3 CompilerOptions (org.eclipse.jdt.internal.compiler.impl.CompilerOptions)3 ArrayList (java.util.ArrayList)2 EclipseAST (lombok.eclipse.EclipseAST)2 EclipseNode (lombok.eclipse.EclipseNode)2 TransformEclipseAST (lombok.eclipse.TransformEclipseAST)2 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)2 JavaModelException (org.eclipse.jdt.core.JavaModelException)2 IErrorHandlingPolicy (org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy)2 IProblemFactory (org.eclipse.jdt.internal.compiler.IProblemFactory)2 TypeDeclaration (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration)2 INameEnvironment (org.eclipse.jdt.internal.compiler.env.INameEnvironment)2 Parser (org.eclipse.jdt.internal.compiler.parser.Parser)2