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


Java DiagnosticListener类代码示例

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


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

示例1: createJavacTask

import javax.tools.DiagnosticListener; //导入依赖的package包/类
public static JavacTaskImpl createJavacTask (
        @NonNull final ClasspathInfo cpInfo,
        @NullAllowed final DiagnosticListener<? super JavaFileObject> diagnosticListener,
        @NullAllowed final String sourceLevel,
        @NullAllowed final SourceLevelQuery.Profile sourceProfile,
        @NullAllowed FQN2Files fqn2Files,
        @NullAllowed final CancelService cancelService,
        @NullAllowed final APTUtils aptUtils,
        @NullAllowed final CompilerOptionsQuery.Result compilerOptions,
        @NonNull Iterable<? extends JavaFileObject> files) {
    return createJavacTask(
            cpInfo,
            diagnosticListener,
            sourceLevel,
            sourceProfile,
            EnumSet.of(ConfigFlags.BACKGROUND_COMPILATION, ConfigFlags.MULTI_SOURCE),
            fqn2Files,
            cancelService,
            aptUtils,
            compilerOptions,
            Collections.emptySet(),
            files);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:JavacParser.java

示例2: CompilationInfoImpl

import javax.tools.DiagnosticListener; //导入依赖的package包/类
/**
 * Creates a new CompilationInfoImpl for given source file
 * @param parser used to parse the file
 * @param file to be parsed
 * @param root the owner of the parsed file
 * @param javacTask used javac or null if new one should be created
 * @param snapshot rendered content of the file
 * @param detached true if the CompilationInfoImpl is detached from parsing infrastructure.
 * @throws java.io.IOException
 */
CompilationInfoImpl (final JavacParser parser,
                     final FileObject file,
                     final FileObject root,
                     final JavacTaskImpl javacTask,
                     final DiagnosticListener<JavaFileObject> diagnosticListener,
                     final Snapshot snapshot,
                     final boolean detached) throws IOException {
    assert parser != null;
    this.parser = parser;
    this.cpInfo = parser.getClasspathInfo();
    assert cpInfo != null;
    this.file = file;
    this.root = root;
    this.snapshot = snapshot;
    assert file == null || snapshot != null;
    this.jfo = file != null ?
        FileObjects.sourceFileObject(file, root, JavaFileFilterQuery.getFilter(file), snapshot.getText()) :
        null;
    this.javacTask = javacTask;
    this.diagnosticListener = diagnosticListener;
    this.isClassFile = false;
    this.isDetached = detached;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:CompilationInfoImpl.java

示例3: getSourceFileForInput

import javax.tools.DiagnosticListener; //导入依赖的package包/类
public JavaFileObject getSourceFileForInput( Location location, String fqn, JavaFileObject.Kind kind, DiagnosticListener<JavaFileObject> errorHandler )
{
  try
  {
    JavaFileObject file = super.getJavaFileForInput( location, fqn, kind );
    if( file != null )
    {
      return file;
    }
  }
  catch( IOException ignore )
  {
  }

  return findGeneratedFile( fqn.replace( '$', '.' ), ManifoldHost.getCurrentModule(), errorHandler );
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:17,代码来源:ManifoldJavaFileManager.java

示例4: compileJava

import javax.tools.DiagnosticListener; //导入依赖的package包/类
public static int compileJava(Context context, JavaProjectFolder projectFile, @Nullable DiagnosticListener listener) {
    try {

        String[] args = new String[]{
                "-verbose",
                "-cp", projectFile.getJavaClassPath(context),
                "-sourcepath", projectFile.getSourcePath(), //sourcepath
                "-d", projectFile.getDirBuildClasses().getPath(), //output dir
                projectFile.getMainClass().getPath(projectFile) //main class
        };
        DLog.d(TAG, "compileJava args = " + Arrays.toString(args));
        int compileStatus;
        compileStatus = Javac.compile(args, listener);
        return compileStatus;
    } catch (Throwable e) {
        e.printStackTrace();
    }
    return Main.EXIT_ERROR;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:20,代码来源:CompileHelper.java

示例5: JavapTask

import javax.tools.DiagnosticListener; //导入依赖的package包/类
public JavapTask(Writer out,
        JavaFileManager fileManager,
        DiagnosticListener<? super JavaFileObject> diagnosticListener,
        Iterable<String> options,
        Iterable<String> classes) {
    this(out, fileManager, diagnosticListener);

    this.classes = new ArrayList<String>();
    for (String classname: classes) {
        classname.getClass(); // null-check
        this.classes.add(classname);
    }

    try {
        if (options != null)
            handleOptions(options, false);
    } catch (BadArgs e) {
        throw new IllegalArgumentException(e.getMessage());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:JavapTask.java

示例6: getDiagnosticListenerForWriter

import javax.tools.DiagnosticListener; //导入依赖的package包/类
private DiagnosticListener<JavaFileObject> getDiagnosticListenerForWriter(Writer w) {
    final PrintWriter pw = getPrintWriterForWriter(w);
    return new DiagnosticListener<JavaFileObject> () {
        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
            switch (diagnostic.getKind()) {
                case ERROR:
                    pw.print(getMessage("err.prefix"));
                    break;
                case WARNING:
                    pw.print(getMessage("warn.prefix"));
                    break;
                case NOTE:
                    pw.print(getMessage("note.prefix"));
                    break;
            }
            pw.print(" ");
            pw.println(diagnostic.getMessage(null));
        }
    };
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:JavapTask.java

示例7: JavahTask

import javax.tools.DiagnosticListener; //导入依赖的package包/类
JavahTask(Writer out,
        JavaFileManager fileManager,
        DiagnosticListener<? super JavaFileObject> diagnosticListener,
        Iterable<String> options,
        Iterable<String> classes) {
    this();
    this.log = getPrintWriterForWriter(out);
    this.fileManager = fileManager;
    this.diagnosticListener = diagnosticListener;

    try {
        handleOptions(options, false);
    } catch (BadArgs e) {
        throw new IllegalArgumentException(e.getMessage());
    }

    this.classes = new ArrayList<String>();
    if (classes != null) {
        for (String classname: classes) {
            classname.getClass(); // null-check
            this.classes.add(classname);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:JavahTask.java

示例8: Log

import javax.tools.DiagnosticListener; //导入依赖的package包/类
/** Construct a log with given I/O redirections.
 */
protected Log(Context context, PrintWriter errWriter, PrintWriter warnWriter, PrintWriter noticeWriter) {
    super(JCDiagnostic.Factory.instance(context));
    context.put(logKey, this);
    this.errWriter = errWriter;
    this.warnWriter = warnWriter;
    this.noticeWriter = noticeWriter;

    @SuppressWarnings("unchecked") // FIXME
    DiagnosticListener<? super JavaFileObject> dl =
        context.get(DiagnosticListener.class);
    this.diagListener = dl;

    diagnosticHandler = new DefaultDiagnosticHandler();

    messages = JavacMessages.instance(context);
    messages.add(Main.javacBundleName);

    final Options options = Options.instance(context);
    initOptions(options);
    options.addListener(new Runnable() {
        public void run() {
            initOptions(options);
        }
    });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:Log.java

示例9: JavapTask

import javax.tools.DiagnosticListener; //导入依赖的package包/类
public JavapTask(Writer out,
        JavaFileManager fileManager,
        DiagnosticListener<? super JavaFileObject> diagnosticListener,
        Iterable<String> options,
        Iterable<String> classes) {
    this(out, fileManager, diagnosticListener);

    this.classes = new ArrayList<>();
    for (String classname: classes) {
        Objects.requireNonNull(classname);
        this.classes.add(classname);
    }

    try {
        if (options != null)
            handleOptions(options, false);
    } catch (BadArgs e) {
        throw new IllegalArgumentException(e.getMessage());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:JavapTask.java

示例10: getDiagnosticListenerForWriter

import javax.tools.DiagnosticListener; //导入依赖的package包/类
private DiagnosticListener<JavaFileObject> getDiagnosticListenerForWriter(Writer w) {
    final PrintWriter pw = getPrintWriterForWriter(w);
    return diagnostic -> {
        switch (diagnostic.getKind()) {
            case ERROR:
                pw.print(getMessage("err.prefix"));
                break;
            case WARNING:
                pw.print(getMessage("warn.prefix"));
                break;
            case NOTE:
                pw.print(getMessage("note.prefix"));
                break;
        }
        pw.print(" ");
        pw.println(diagnostic.getMessage(null));
    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:JavapTask.java

示例11: report

import javax.tools.DiagnosticListener; //导入依赖的package包/类
void report( DiagnosticListener<JavaFileObject> errorHandler )
{
  if( errorHandler == null )
  {
    return;
  }

  List<IIssue> issues = getIssues();
  if( issues.isEmpty() )
  {
    return;
  }

  JavaFileObject file = new SourceJavaFileObject( getFile().toURI() );
  for( IIssue issue : issues )
  {
    Diagnostic.Kind kind = issue.getKind() == IIssue.Kind.Error ? Diagnostic.Kind.ERROR : Diagnostic.Kind.WARNING;
    errorHandler.report( new JavacDiagnostic( file, kind, issue.getStartOffset(), issue.getLine(), issue.getColumn(), issue.getMessage() ) );
  }
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:21,代码来源:JsonModel.java

示例12: JavahTask

import javax.tools.DiagnosticListener; //导入依赖的package包/类
JavahTask(Writer out,
        JavaFileManager fileManager,
        DiagnosticListener<? super JavaFileObject> diagnosticListener,
        Iterable<String> options,
        Iterable<String> classes) {
    this();
    this.log = getPrintWriterForWriter(out);
    this.fileManager = fileManager;
    this.diagnosticListener = diagnosticListener;

    try {
        handleOptions(options, false);
    } catch (BadArgs e) {
        throw new IllegalArgumentException(e.getMessage());
    }

    this.classes = new ArrayList<>();
    if (classes != null) {
        for (String classname: classes) {
            Objects.requireNonNull(classname);
            this.classes.add(classname);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:JavahTask.java

示例13: Log

import javax.tools.DiagnosticListener; //导入依赖的package包/类
/**
 * Creates a log.
 * @param context the context in which the log should be registered
 * @param writers a map of writers that can be accessed by the kind of writer required
 */
private Log(Context context, Map<WriterKind, PrintWriter> writers) {
    super(JCDiagnostic.Factory.instance(context));
    context.put(logKey, this);
    this.writers = writers;

    @SuppressWarnings("unchecked") // FIXME
    DiagnosticListener<? super JavaFileObject> dl =
        context.get(DiagnosticListener.class);
    this.diagListener = dl;

    diagnosticHandler = new DefaultDiagnosticHandler();

    messages = JavacMessages.instance(context);
    messages.add(Main.javacBundleName);

    final Options options = Options.instance(context);
    initOptions(options);
    options.addListener(() -> initOptions(options));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:Log.java

示例14: clear

import javax.tools.DiagnosticListener; //导入依赖的package包/类
void clear() {
    drop(Arguments.argsKey);
    drop(DiagnosticListener.class);
    drop(Log.outKey);
    drop(Log.errKey);
    drop(JavaFileManager.class);
    drop(JavacTask.class);

    if (ht.get(Log.logKey) instanceof ReusableLog) {
        //log already inited - not first round
        ((ReusableLog)Log.instance(this)).clear();
        Enter.instance(this).newRound();
        ((ReusableJavaCompiler)ReusableJavaCompiler.instance(this)).clear();
        Types.instance(this).newRound();
        Check.instance(this).newRound();
        Modules.instance(this).newRound();
        Annotate.instance(this).newRound();
        CompileStates.instance(this).clear();
        MultiTaskListener.instance(this).clear();

        //find if any of the roots have redefined java.* classes
        Symtab syms = Symtab.instance(this);
        pollutionScanner.scan(roots, syms);
        roots.clear();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ReusableContext.java

示例15: getTask

import javax.tools.DiagnosticListener; //导入依赖的package包/类
@Override
public JavaCompiler.CompilationTask getTask(Writer out, JavaFileManager fileManager,
        DiagnosticListener<? super JavaFileObject> diagnosticListener,
        Iterable<String> options, Iterable<String> classes,
        Iterable<? extends JavaFileObject> compilationUnits) {
    return compiler.getTask(out, fileManager, diagnosticListener, options, classes, compilationUnits);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:SimpleCompiler.java


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