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


Java BaseFileObject类代码示例

本文整理汇总了Java中com.sun.tools.javac.file.BaseFileObject的典型用法代码示例。如果您正苦于以下问题:Java BaseFileObject类的具体用法?Java BaseFileObject怎么用?Java BaseFileObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: formatArgument

import com.sun.tools.javac.file.BaseFileObject; //导入依赖的package包/类
@Override
protected String formatArgument(JCDiagnostic diag, Object arg, Locale l) {
    String s;
    if (arg instanceof Formattable)
        s = arg.toString();
    else if (arg instanceof BaseFileObject)
        s = ((BaseFileObject) arg).getShortName();
    else
        s = super.formatArgument(diag, arg, null);
    if (arg instanceof JCDiagnostic)
        return "(" + s + ")";
    else
        return s;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:15,代码来源:RawDiagnosticFormatter.java

示例2: formatSource

import com.sun.tools.javac.file.BaseFileObject; //导入依赖的package包/类
public String formatSource(JCDiagnostic d, boolean fullname, Locale l) {
    JavaFileObject fo = d.getSource();
    if (fo == null)
        throw new IllegalArgumentException(); // d should have source set
    if (fullname)
        return fo.getName();
    else if (fo instanceof BaseFileObject)
        return ((BaseFileObject) fo).getShortName();
    else
        return BaseFileObject.getSimpleName(fo);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:12,代码来源:AbstractDiagnosticFormatter.java

示例3: formatArgument

import com.sun.tools.javac.file.BaseFileObject; //导入依赖的package包/类
@Override
protected String formatArgument(JCDiagnostic diag, Object arg, Locale l) {
    String s;
    if (arg instanceof Formattable) {
        s = arg.toString();
    } else if (arg instanceof JCExpression) {
        JCExpression tree = (JCExpression)arg;
        s = "@" + tree.getStartPosition();
    } else if (arg instanceof BaseFileObject) {
        s = ((BaseFileObject) arg).getShortName();
    } else {
        s = super.formatArgument(diag, arg, null);
    }
    return (arg instanceof JCDiagnostic) ? "(" + s + ")" : s;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:RawDiagnosticFormatter.java

示例4: format_raw

import com.sun.tools.javac.file.BaseFileObject; //导入依赖的package包/类
private String format_raw(JCDiagnostic d) {
    DiagnosticSource source = d.getDiagnosticSource();
    int position = d.getIntPosition();

    StringBuilder sb = new StringBuilder();
    if (position == Position.NOPOS)
        sb.append("-");
    else {
        sb.append(source.getName() + ":" + source.getLineNumber(position) + ":" + source.getColumnNumber(position) + ":");
    }
    sb.append(" ");
    sb.append(d.getCode());
    String sep = ": ";
    for (Object arg: d.getArgs()) {
        sb.append(sep);
        if (arg instanceof JCDiagnostic) {
            sb.append('(');
            sb.append(format_raw((JCDiagnostic) arg));
            sb.append(')');
        }
        else if (arg instanceof BaseFileObject)
            sb.append(((BaseFileObject) arg).getShortName());
        else if (arg instanceof JavaFileObject)
            sb.append(BaseFileObject.getSimpleName((JavaFileObject) arg));
        else
            sb.append(arg);
        sep = ", ";
    }
    return sb.toString();
}
 
开发者ID:lucasicf,项目名称:metricgenerator-jdk-compiler,代码行数:31,代码来源:DiagnosticFormatter.java

示例5: useSource

import com.sun.tools.javac.file.BaseFileObject; //导入依赖的package包/类
/** Re-assign source, returning previous setting.
 */
public JavaFileObject useSource(final JavaFileObject name) {
    JavaFileObject prev = currentSource();
    if (name != prev) {
        source = new JCDiagnostic.DiagnosticSource() {
                public JavaFileObject getFile() {
                    return name;
                }
                public CharSequence getName() {
                    if (name instanceof BaseFileObject)
                        return ((BaseFileObject) name).getShortName();
                    else
                        return BaseFileObject.getSimpleName(name);
                }
                public int getLineNumber(int pos) {
                    return Log.this.getLineNumber(pos);
                }
                public int getColumnNumber(int pos) {
                    return Log.this.getColumnNumber(pos);
                }
                public Map<JCTree, Integer> getEndPosTable() {
                    return (endPosTables == null ? null : endPosTables.get(name));
                }
            };
        buf = null;
    }
    return prev;
}
 
开发者ID:lucasicf,项目名称:metricgenerator-jdk-compiler,代码行数:30,代码来源:Log.java


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