当前位置: 首页>>代码示例>>Java>>正文


Java JavacElements.getTreeAndTopLevel方法代码示例

本文整理汇总了Java中com.sun.tools.javac.model.JavacElements.getTreeAndTopLevel方法的典型用法代码示例。如果您正苦于以下问题:Java JavacElements.getTreeAndTopLevel方法的具体用法?Java JavacElements.getTreeAndTopLevel怎么用?Java JavacElements.getTreeAndTopLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.tools.javac.model.JavacElements的用法示例。


在下文中一共展示了JavacElements.getTreeAndTopLevel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: printMessage

import com.sun.tools.javac.model.JavacElements; //导入方法依赖的package包/类
/**
 * Prints a message of the specified kind at the location of the
 * annotation value inside the annotation mirror of the annotated
 * element.
 *
 * @param kind the kind of message
 * @param msg  the message, or an empty string if none
 * @param e    the annotated element
 * @param a    the annotation containing the annotaiton value
 * @param v    the annotation value to use as a position hint
 */
public void printMessage(Diagnostic.Kind kind, CharSequence msg,
                  Element e, AnnotationMirror a, AnnotationValue v) {
    JavaFileObject oldSource = null;
    JavaFileObject newSource = null;
    JCDiagnostic.DiagnosticPosition pos = null;
    JavacElements elemUtils = processingEnv.getElementUtils();
    Pair<JCTree, JCCompilationUnit> treeTop = elemUtils.getTreeAndTopLevel(e, a, v);
    if (treeTop != null) {
        newSource = treeTop.snd.sourcefile;
        if (newSource != null) {
            oldSource = log.useSource(newSource);
            pos = treeTop.fst.pos();
        }
    }
    try {
        switch (kind) {
        case ERROR:
            errorCount++;
            boolean prev = log.multipleErrors;
            log.multipleErrors = true;
            try {
                log.error(pos, "proc.messager", msg.toString());
            } finally {
                log.multipleErrors = prev;
            }
            break;

        case WARNING:
            warningCount++;
            log.warning(pos, "proc.messager", msg.toString());
            break;

        case MANDATORY_WARNING:
            warningCount++;
            log.mandatoryWarning(pos, "proc.messager", msg.toString());
            break;

        default:
            log.note(pos, "proc.messager", msg.toString());
            break;
        }
    } finally {
        if (oldSource != null)
            log.useSource(oldSource);
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:58,代码来源:JavacMessager.java

示例2: printMessage

import com.sun.tools.javac.model.JavacElements; //导入方法依赖的package包/类
/**
 * Prints a message of the specified kind at the location of the
 * annotation value inside the annotation mirror of the annotated
 * element.
 *
 * @param kind the kind of message
 * @param msg  the message, or an empty string if none
 * @param e    the annotated element
 * @param a    the annotation containing the annotaiton value
 * @param v    the annotation value to use as a position hint
 */
public void printMessage(Diagnostic.Kind kind, CharSequence msg,
                  Element e, AnnotationMirror a, AnnotationValue v) {
    JavaFileObject oldSource = null;
    JavaFileObject newSource = null;
    JCDiagnostic.DiagnosticPosition pos = null;
    JavacElements elemUtils = processingEnv.getElementUtils();
    Pair<JCTree, JCCompilationUnit> treeTop = elemUtils.getTreeAndTopLevel(e, a, v);
    if (treeTop != null) {
        newSource = treeTop.snd.sourcefile;
        if (newSource != null) {
            // save the old version and reinstate it later
            oldSource = log.useSource(newSource);
            pos = treeTop.fst.pos();
        }
    }
    try {
        switch (kind) {
        case ERROR:
            errorCount++;
            boolean prev = log.multipleErrors;
            log.multipleErrors = true;
            try {
                log.error(pos, "proc.messager", msg.toString());
            } finally {
                log.multipleErrors = prev;
            }
            break;

        case WARNING:
            warningCount++;
            log.warning(pos, "proc.messager", msg.toString());
            break;

        case MANDATORY_WARNING:
            warningCount++;
            log.mandatoryWarning(pos, "proc.messager", msg.toString());
            break;

        default:
            log.note(pos, "proc.messager", msg.toString());
            break;
        }
    } finally {
        // reinstate the saved version, only if it was saved earlier
        if (newSource != null)
            log.useSource(oldSource);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:60,代码来源:JavacMessager.java

示例3: printMessage

import com.sun.tools.javac.model.JavacElements; //导入方法依赖的package包/类
/**
 * Prints a message of the specified kind at the location of the
 * annotation value inside the annotation mirror of the annotated
 * element.
 *
 * @param kind the kind of message
 * @param msg  the message, or an empty string if none
 * @param e    the annotated element
 * @param a    the annotation containing the annotaiton value
 * @param v    the annotation value to use as a position hint
 */
@DefinedBy(Api.ANNOTATION_PROCESSING)
public void printMessage(Diagnostic.Kind kind, CharSequence msg,
                  Element e, AnnotationMirror a, AnnotationValue v) {
    JavaFileObject oldSource = null;
    JavaFileObject newSource = null;
    JCDiagnostic.DiagnosticPosition pos = null;
    JavacElements elemUtils = processingEnv.getElementUtils();
    Pair<JCTree, JCCompilationUnit> treeTop = elemUtils.getTreeAndTopLevel(e, a, v);
    if (treeTop != null) {
        newSource = treeTop.snd.sourcefile;
        if (newSource != null) {
            // save the old version and reinstate it later
            oldSource = log.useSource(newSource);
            pos = treeTop.fst.pos();
        }
    }
    try {
        switch (kind) {
        case ERROR:
            errorCount++;
            log.error(DiagnosticFlag.MULTIPLE, pos, Errors.ProcMessager(msg.toString()));
            break;

        case WARNING:
            warningCount++;
            log.warning(pos, Warnings.ProcMessager(msg.toString()));
            break;

        case MANDATORY_WARNING:
            warningCount++;
            log.mandatoryWarning(pos, Warnings.ProcMessager(msg.toString()));
            break;

        default:
            log.note(pos, Notes.ProcMessager(msg.toString()));
            break;
        }
    } finally {
        // reinstate the saved version, only if it was saved earlier
        if (newSource != null)
            log.useSource(oldSource);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:55,代码来源:JavacMessager.java

示例4: printMessage

import com.sun.tools.javac.model.JavacElements; //导入方法依赖的package包/类
/**
 * Prints a message of the specified kind at the location of the
 * annotation value inside the annotation mirror of the annotated
 * element.
 *
 * @param kind the kind of message
 * @param msg  the message, or an empty string if none
 * @param e    the annotated element
 * @param a    the annotation containing the annotaiton value
 * @param v    the annotation value to use as a position hint
 */
@DefinedBy(Api.ANNOTATION_PROCESSING)
public void printMessage(Diagnostic.Kind kind, CharSequence msg,
                  Element e, AnnotationMirror a, AnnotationValue v) {
    JavaFileObject oldSource = null;
    JavaFileObject newSource = null;
    JCDiagnostic.DiagnosticPosition pos = null;
    JavacElements elemUtils = processingEnv.getElementUtils();
    Pair<JCTree, JCCompilationUnit> treeTop = elemUtils.getTreeAndTopLevel(e, a, v);
    if (treeTop != null) {
        newSource = treeTop.snd.sourcefile;
        if (newSource != null) {
            // save the old version and reinstate it later
            oldSource = log.useSource(newSource);
            pos = treeTop.fst.pos();
        }
    }
    try {
        switch (kind) {
        case ERROR:
            errorCount++;
            log.error(DiagnosticFlag.MULTIPLE, pos, "proc.messager", msg.toString());
            break;

        case WARNING:
            warningCount++;
            log.warning(pos, "proc.messager", msg.toString());
            break;

        case MANDATORY_WARNING:
            warningCount++;
            log.mandatoryWarning(pos, "proc.messager", msg.toString());
            break;

        default:
            log.note(pos, "proc.messager", msg.toString());
            break;
        }
    } finally {
        // reinstate the saved version, only if it was saved earlier
        if (newSource != null)
            log.useSource(oldSource);
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:55,代码来源:JavacMessager.java

示例5: printMessage

import com.sun.tools.javac.model.JavacElements; //导入方法依赖的package包/类
/**
 * Prints a message of the specified kind at the location of the
 * annotation value inside the annotation mirror of the annotated
 * element.
 *
 * @param kind the kind of message
 * @param msg  the message, or an empty string if none
 * @param e    the annotated element
 * @param a    the annotation containing the annotaiton value
 * @param v    the annotation value to use as a position hint
 */
public void printMessage(Diagnostic.Kind kind, CharSequence msg,
                  Element e, AnnotationMirror a, AnnotationValue v) {
    JavaFileObject oldSource = null;
    JavaFileObject newSource = null;
    JCDiagnostic.DiagnosticPosition pos = null;
    JavacElements elemUtils = processingEnv.getElementUtils();
    Pair<JCTree, JCCompilationUnit> treeTop = elemUtils.getTreeAndTopLevel(e, a, v);
    if (treeTop != null) {
        newSource = treeTop.snd.sourcefile;
        if (newSource != null) {
            oldSource = log.useSource(newSource);
            pos = treeTop.fst.pos();
        }
    }
    try {
        switch (kind) {
        case ERROR:
            errorCount++;
            boolean prev = log.multipleErrors;
            log.multipleErrors = true;
            try {
                log.error(pos, "proc.messager", msg.toString());
            } finally {
                log.multipleErrors = prev;
            }
            break;

        case WARNING:
            log.warning(pos, "proc.messager", msg.toString());
            break;

        case MANDATORY_WARNING:
            log.mandatoryWarning(pos, "proc.messager", msg.toString());
            break;

        default:
            log.note(pos, "proc.messager", msg.toString());
            break;
        }
    } finally {
        if (oldSource != null)
            log.useSource(oldSource);
    }
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:56,代码来源:JavacMessager.java


注:本文中的com.sun.tools.javac.model.JavacElements.getTreeAndTopLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。