本文整理汇总了Java中javax.tools.Diagnostic.getColumnNumber方法的典型用法代码示例。如果您正苦于以下问题:Java Diagnostic.getColumnNumber方法的具体用法?Java Diagnostic.getColumnNumber怎么用?Java Diagnostic.getColumnNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.tools.Diagnostic
的用法示例。
在下文中一共展示了Diagnostic.getColumnNumber方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSrcSpan
import javax.tools.Diagnostic; //导入方法依赖的package包/类
public static Spannable createSrcSpan(Resources resources, @NonNull Diagnostic diagnostic) {
if (diagnostic.getSource() == null) {
return new SpannableString("Unknown");
}
if (!(diagnostic.getSource() instanceof JavaFileObject)) {
return new SpannableString(diagnostic.getSource().toString());
}
try {
JavaFileObject source = (JavaFileObject) diagnostic.getSource();
File file = new File(source.getName());
String name = file.getName();
String line = diagnostic.getLineNumber() + ":" + diagnostic.getColumnNumber();
SpannableString span = new SpannableString(name + ":" + line);
span.setSpan(new ForegroundColorSpan(resources.getColor(R.color.dark_color_diagnostic_file)),
0, span.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
return span;
} catch (Exception e) {
}
return new SpannableString(diagnostic.getSource().toString());
}
示例2: report
import javax.tools.Diagnostic; //导入方法依赖的package包/类
@Override
public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
if (diagnostic.getKind() == javax.tools.Diagnostic.Kind.ERROR) {
String message = diagnostic.toString() + " (" + diagnostic.getCode() + ")";
logger.error(message);
Location loc = new Location( //
diagnostic.getSource().toString(), //
(short) diagnostic.getLineNumber(), //
(short) diagnostic.getColumnNumber() //
);
// Wrap the exception in a RuntimeException, because "report()"
// does not declare checked exceptions.
throw new RuntimeException(new CompileException(message, loc));
} else if (logger.isTraceEnabled()) {
logger.trace(diagnostic.toString() + " (" + diagnostic.getCode() + ")");
}
}
示例3: ensureCompilable
import javax.tools.Diagnostic; //导入方法依赖的package包/类
private void ensureCompilable(FileObject file) throws IOException, AssertionError, IllegalArgumentException {
CompilationInfo info = parse(file);
assertNotNull(info);
for (Diagnostic d : info.getDiagnostics()) {
if (d.getKind() == Diagnostic.Kind.ERROR)
throw new AssertionError(d.getLineNumber() + ":" + d.getColumnNumber() + " " + d.getMessage(null));
}
}
示例4: brokenPlatform
import javax.tools.Diagnostic; //导入方法依赖的package包/类
public static void brokenPlatform(
@NonNull final Context ctx,
@NonNull final Iterable<? extends CompileTuple> files,
@NullAllowed final Diagnostic<JavaFileObject> diagnostic) {
if (diagnostic == null) {
return;
}
final Diagnostic<JavaFileObject> error = new Diagnostic<JavaFileObject>() {
@Override
public Kind getKind() {
return Kind.ERROR;
}
@Override
public JavaFileObject getSource() {
return diagnostic.getSource();
}
@Override
public long getPosition() {
return diagnostic.getPosition();
}
@Override
public long getStartPosition() {
return diagnostic.getStartPosition();
}
@Override
public long getEndPosition() {
return diagnostic.getEndPosition();
}
@Override
public long getLineNumber() {
return diagnostic.getLineNumber();
}
@Override
public long getColumnNumber() {
return diagnostic.getColumnNumber();
}
@Override
public String getCode() {
return diagnostic.getCode();
}
@Override
public String getMessage(Locale locale) {
return diagnostic.getMessage(locale);
}
};
for (CompileTuple file : files) {
if (!file.virtual) {
ErrorsCache.setErrors(
ctx.getRootURI(),
file.indexable,
Collections.<Diagnostic<JavaFileObject>>singleton(error),
ERROR_CONVERTOR);
}
}
}