本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}