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


Java Diagnostic.getColumnNumber方法代码示例

本文整理汇总了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());
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:22,代码来源:SpanUtil.java

示例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() + ")");
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:18,代码来源:DrillDiagnosticListener.java

示例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));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:HintTest.java

示例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);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:65,代码来源:JavaCustomIndexer.java


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