當前位置: 首頁>>代碼示例>>Java>>正文


Java CompilationUnitTree.getSourceFile方法代碼示例

本文整理匯總了Java中com.sun.source.tree.CompilationUnitTree.getSourceFile方法的典型用法代碼示例。如果您正苦於以下問題:Java CompilationUnitTree.getSourceFile方法的具體用法?Java CompilationUnitTree.getSourceFile怎麽用?Java CompilationUnitTree.getSourceFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.sun.source.tree.CompilationUnitTree的用法示例。


在下文中一共展示了CompilationUnitTree.getSourceFile方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: TaskEvent

import com.sun.source.tree.CompilationUnitTree; //導入方法依賴的package包/類
public TaskEvent(Kind kind, CompilationUnitTree unit) {
    this(kind, unit.getSourceFile(), unit, null);
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:4,代碼來源:TaskEvent.java

示例2: printMessage

import com.sun.source.tree.CompilationUnitTree; //導入方法依賴的package包/類
/**
 * Prints a message of the specified kind at the location of the
 * tree within the provided compilation unit
 *
 * @param kind the kind of message
 * @param msg  the message, or an empty string if none
 * @param t    the tree to use as a position hint
 * @param root the compilation unit that contains tree
 */
public void printMessage(Diagnostic.Kind kind, CharSequence msg,
        Tree t,
        CompilationUnitTree root) {
    JavaFileObject oldSource = null;
    JavaFileObject newSource = null;
    JCDiagnostic.DiagnosticPosition pos = null;

    newSource = root.getSourceFile();
    if (newSource != null) {
        oldSource = log.useSource(newSource);
        pos = ((JCTree) t).pos();
    }

    try {
        switch (kind) {
        case ERROR:
            boolean prev = log.multipleErrors;
            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());
        }
    } finally {
        if (oldSource != null)
            log.useSource(oldSource);
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:50,代碼來源:JavacTrees.java

示例3: TaskEvent

import com.sun.source.tree.CompilationUnitTree; //導入方法依賴的package包/類
/**
 * Creates a task event for a given kind and compilation unit.
 * The source file is set from the compilation unit,
 * and the type element is set to {@code null}.
 * @param kind the kind of the event
 * @param unit the compilation unit
 */
public TaskEvent(Kind kind, CompilationUnitTree unit) {
    this(kind, unit.getSourceFile(), unit, null);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:TaskEvent.java


注:本文中的com.sun.source.tree.CompilationUnitTree.getSourceFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。