< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/api/BasicJavacTask.java

Print this page


   1 /*
   2  * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  26 package com.sun.tools.javac.api;
  27 
  28 import java.util.Collection;
  29 import java.util.LinkedHashSet;
  30 import java.util.Locale;
  31 import java.util.Objects;
  32 import java.util.ServiceLoader;
  33 import java.util.Set;
  34 import java.util.stream.Collectors;
  35 
  36 import javax.annotation.processing.Processor;
  37 import javax.lang.model.element.Element;
  38 import javax.lang.model.type.TypeMirror;
  39 import javax.lang.model.util.Elements;
  40 import javax.lang.model.util.Types;
  41 import javax.tools.JavaFileObject;
  42 
  43 import com.sun.source.tree.CompilationUnitTree;
  44 import com.sun.source.tree.Tree;
  45 import com.sun.source.util.JavacTask;
  46 import com.sun.source.util.ParameterNameProvider;
  47 import com.sun.source.util.Plugin;
  48 import com.sun.source.util.TaskListener;
  49 import com.sun.tools.doclint.DocLint;
  50 import com.sun.tools.javac.code.MissingInfoHandler;
  51 import com.sun.tools.javac.main.JavaCompiler;
  52 import com.sun.tools.javac.model.JavacElements;
  53 import com.sun.tools.javac.model.JavacTypes;
  54 import com.sun.tools.javac.platform.PlatformDescription;
  55 import com.sun.tools.javac.platform.PlatformDescription.PluginInfo;
  56 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
  57 import com.sun.tools.javac.resources.CompilerProperties.Errors;
  58 import com.sun.tools.javac.tree.JCTree;
  59 import com.sun.tools.javac.util.Context;
  60 import com.sun.tools.javac.util.DefinedBy;
  61 import com.sun.tools.javac.util.DefinedBy.Api;
  62 import com.sun.tools.javac.util.List;
  63 import com.sun.tools.javac.util.Log;
  64 import com.sun.tools.javac.util.PropagatedException;
  65 
  66 /**
  67  * Provides basic functionality for implementations of JavacTask.
  68  *
  69  * <p><b>This is NOT part of any supported API.
  70  * If you write code that depends on this, you do so at your own


 106     @Override @DefinedBy(Api.COMPILER_TREE)
 107     public void setTaskListener(TaskListener tl) {
 108         MultiTaskListener mtl = MultiTaskListener.instance(context);
 109         if (taskListener != null)
 110             mtl.remove(taskListener);
 111         if (tl != null)
 112             mtl.add(tl);
 113         taskListener = tl;
 114     }
 115 
 116     @Override @DefinedBy(Api.COMPILER_TREE)
 117     public void addTaskListener(TaskListener taskListener) {
 118         MultiTaskListener mtl = MultiTaskListener.instance(context);
 119         mtl.add(taskListener);
 120     }
 121 
 122     @Override @DefinedBy(Api.COMPILER_TREE)
 123     public void removeTaskListener(TaskListener taskListener) {
 124         MultiTaskListener mtl = MultiTaskListener.instance(context);
 125         mtl.remove(taskListener);
 126     }
 127 
 128     @Override
 129     public void setParameterNameProvider(ParameterNameProvider handler) {
 130         MissingInfoHandler.instance(context).setDelegate(handler);
 131     }
 132 
 133     public Collection<TaskListener> getTaskListeners() {
 134         MultiTaskListener mtl = MultiTaskListener.instance(context);
 135         return mtl.getTaskListeners();
 136     }
 137 
 138     @Override @DefinedBy(Api.COMPILER_TREE)
 139     public TypeMirror getTypeMirror(Iterable<? extends Tree> path) {
 140         // TODO: Should complete attribution if necessary
 141         Tree last = null;
 142         for (Tree node : path) {
 143             last = Objects.requireNonNull(node);
 144         }
 145         if (last == null) {
 146             throw new IllegalArgumentException("empty path");
 147         }
 148         return ((JCTree) last).type;
 149     }
 150 


   1 /*
   2  * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  26 package com.sun.tools.javac.api;
  27 
  28 import java.util.Collection;
  29 import java.util.LinkedHashSet;
  30 import java.util.Locale;
  31 import java.util.Objects;
  32 import java.util.ServiceLoader;
  33 import java.util.Set;
  34 import java.util.stream.Collectors;
  35 
  36 import javax.annotation.processing.Processor;
  37 import javax.lang.model.element.Element;
  38 import javax.lang.model.type.TypeMirror;
  39 import javax.lang.model.util.Elements;
  40 import javax.lang.model.util.Types;
  41 import javax.tools.JavaFileObject;
  42 
  43 import com.sun.source.tree.CompilationUnitTree;
  44 import com.sun.source.tree.Tree;
  45 import com.sun.source.util.JavacTask;

  46 import com.sun.source.util.Plugin;
  47 import com.sun.source.util.TaskListener;
  48 import com.sun.tools.doclint.DocLint;

  49 import com.sun.tools.javac.main.JavaCompiler;
  50 import com.sun.tools.javac.model.JavacElements;
  51 import com.sun.tools.javac.model.JavacTypes;
  52 import com.sun.tools.javac.platform.PlatformDescription;
  53 import com.sun.tools.javac.platform.PlatformDescription.PluginInfo;
  54 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
  55 import com.sun.tools.javac.resources.CompilerProperties.Errors;
  56 import com.sun.tools.javac.tree.JCTree;
  57 import com.sun.tools.javac.util.Context;
  58 import com.sun.tools.javac.util.DefinedBy;
  59 import com.sun.tools.javac.util.DefinedBy.Api;
  60 import com.sun.tools.javac.util.List;
  61 import com.sun.tools.javac.util.Log;
  62 import com.sun.tools.javac.util.PropagatedException;
  63 
  64 /**
  65  * Provides basic functionality for implementations of JavacTask.
  66  *
  67  * <p><b>This is NOT part of any supported API.
  68  * If you write code that depends on this, you do so at your own


 104     @Override @DefinedBy(Api.COMPILER_TREE)
 105     public void setTaskListener(TaskListener tl) {
 106         MultiTaskListener mtl = MultiTaskListener.instance(context);
 107         if (taskListener != null)
 108             mtl.remove(taskListener);
 109         if (tl != null)
 110             mtl.add(tl);
 111         taskListener = tl;
 112     }
 113 
 114     @Override @DefinedBy(Api.COMPILER_TREE)
 115     public void addTaskListener(TaskListener taskListener) {
 116         MultiTaskListener mtl = MultiTaskListener.instance(context);
 117         mtl.add(taskListener);
 118     }
 119 
 120     @Override @DefinedBy(Api.COMPILER_TREE)
 121     public void removeTaskListener(TaskListener taskListener) {
 122         MultiTaskListener mtl = MultiTaskListener.instance(context);
 123         mtl.remove(taskListener);





 124     }
 125 
 126     public Collection<TaskListener> getTaskListeners() {
 127         MultiTaskListener mtl = MultiTaskListener.instance(context);
 128         return mtl.getTaskListeners();
 129     }
 130 
 131     @Override @DefinedBy(Api.COMPILER_TREE)
 132     public TypeMirror getTypeMirror(Iterable<? extends Tree> path) {
 133         // TODO: Should complete attribution if necessary
 134         Tree last = null;
 135         for (Tree node : path) {
 136             last = Objects.requireNonNull(node);
 137         }
 138         if (last == null) {
 139             throw new IllegalArgumentException("empty path");
 140         }
 141         return ((JCTree) last).type;
 142     }
 143 


< prev index next >