Search in sources :

Example 1 with JCCompilationUnit

use of com.sun.tools.javac.tree.JCTree.JCCompilationUnit in project lombok by rzwitserloot.

the class CommentCollectingParser method compilationUnit.

@Override
public JCCompilationUnit compilationUnit() {
    JCCompilationUnit result = super.compilationUnit();
    if (lexer instanceof CommentCollectingScanner) {
        List<CommentInfo> comments = ((CommentCollectingScanner) lexer).getComments();
        JCCompilationUnit_comments.set(result, comments);
    }
    return result;
}
Also used : JCCompilationUnit(com.sun.tools.javac.tree.JCTree.JCCompilationUnit) CommentInfo(lombok.javac.CommentInfo)

Example 2 with JCCompilationUnit

use of com.sun.tools.javac.tree.JCTree.JCCompilationUnit in project lombok by rzwitserloot.

the class CommentCollectingParser method parseCompilationUnit.

public JCCompilationUnit parseCompilationUnit() {
    JCCompilationUnit result = super.parseCompilationUnit();
    if (lexer instanceof CommentCollectingScanner) {
        List<CommentInfo> comments = ((CommentCollectingScanner) lexer).getComments();
        JCCompilationUnit_comments.set(result, comments);
    }
    return result;
}
Also used : JCCompilationUnit(com.sun.tools.javac.tree.JCTree.JCCompilationUnit) CommentInfo(lombok.javac.CommentInfo)

Example 3 with JCCompilationUnit

use of com.sun.tools.javac.tree.JCTree.JCCompilationUnit in project lombok by rzwitserloot.

the class CommentCollectingParser method parseCompilationUnit.

public JCCompilationUnit parseCompilationUnit() {
    JCCompilationUnit result = super.parseCompilationUnit();
    if (lexer instanceof CommentCollectingScanner) {
        List<CommentInfo> comments = ((CommentCollectingScanner) lexer).getComments();
        JCCompilationUnit_comments.set(result, comments);
    }
    return result;
}
Also used : JCCompilationUnit(com.sun.tools.javac.tree.JCTree.JCCompilationUnit) CommentInfo(lombok.javac.CommentInfo)

Example 4 with JCCompilationUnit

use of com.sun.tools.javac.tree.JCTree.JCCompilationUnit in project lombok by rzwitserloot.

the class JavacAST method removeFromDeferredDiagnostics.

public void removeFromDeferredDiagnostics(int startPos, int endPos) {
    JCCompilationUnit self = (JCCompilationUnit) top().get();
    new CompilerMessageSuppressor(getContext()).removeAllBetween(self.sourcefile, startPos, endPos);
}
Also used : JCCompilationUnit(com.sun.tools.javac.tree.JCTree.JCCompilationUnit)

Example 5 with JCCompilationUnit

use of com.sun.tools.javac.tree.JCTree.JCCompilationUnit in project lombok by rzwitserloot.

the class JavacAST method printMessage.

/** Supply either a position or a node (in that case, position of the node is used) */
void printMessage(Diagnostic.Kind kind, String message, JavacNode node, DiagnosticPosition pos, boolean attemptToRemoveErrorsInRange) {
    JavaFileObject oldSource = null;
    JavaFileObject newSource = null;
    JCTree astObject = node == null ? null : node.get();
    JCCompilationUnit top = (JCCompilationUnit) top().get();
    newSource = top.sourcefile;
    if (newSource != null) {
        oldSource = log.useSource(newSource);
        if (pos == null)
            pos = astObject.pos();
    }
    if (pos != null && attemptToRemoveErrorsInRange) {
        removeFromDeferredDiagnostics(pos.getStartPosition(), node.getEndPosition(pos));
    }
    try {
        switch(kind) {
            case ERROR:
                increaseErrorCount(messager);
                boolean prev = log.multipleErrors;
                log.multipleErrors = true;
                try {
                    log.error(pos, "proc.messager", message);
                } finally {
                    log.multipleErrors = prev;
                }
                break;
            default:
            case WARNING:
                log.warning(pos, "proc.messager", message);
                break;
        }
    } finally {
        if (oldSource != null)
            log.useSource(oldSource);
    }
}
Also used : JCCompilationUnit(com.sun.tools.javac.tree.JCTree.JCCompilationUnit) JavaFileObject(javax.tools.JavaFileObject) JCTree(com.sun.tools.javac.tree.JCTree)

Aggregations

JCCompilationUnit (com.sun.tools.javac.tree.JCTree.JCCompilationUnit)50 JCTree (com.sun.tools.javac.tree.JCTree)11 JavaFileObject (javax.tools.JavaFileObject)7 Test (org.junit.Test)7 JCClassDecl (com.sun.tools.javac.tree.JCTree.JCClassDecl)6 IOException (java.io.IOException)6 CeylonCompilationUnit (com.redhat.ceylon.compiler.java.codegen.CeylonCompilationUnit)5 TaskEvent (com.sun.source.util.TaskEvent)5 File (java.io.File)5 TaskListener (com.sun.source.util.TaskListener)4 JCExpression (com.sun.tools.javac.tree.JCTree.JCExpression)4 ArrayList (java.util.ArrayList)4 ImmutableList (com.google.common.collect.ImmutableList)3 CeyloncTaskImpl (com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl)3 CompilationUnitTree (com.sun.source.tree.CompilationUnitTree)3 TreePath (com.sun.source.util.TreePath)3 JavacTool (com.sun.tools.javac.api.JavacTool)3 JCAnnotation (com.sun.tools.javac.tree.JCTree.JCAnnotation)3 JCAssign (com.sun.tools.javac.tree.JCTree.JCAssign)3 Context (com.sun.tools.javac.util.Context)3