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


Java Context.get方法代码示例

本文整理汇总了Java中com.sun.tools.javac.util.Context.get方法的典型用法代码示例。如果您正苦于以下问题:Java Context.get方法的具体用法?Java Context.get怎么用?Java Context.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.tools.javac.util.Context的用法示例。


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

示例1: ToolEnvironment

import com.sun.tools.javac.util.Context; //导入方法依赖的package包/类
/**
 * Constructor
 *
 * @param context      Context for this javadoc instance.
 */
protected ToolEnvironment(Context context) {
    context.put(ToolEnvKey, this);
    this.context = context;

    messager = Messager.instance0(context);
    syms = Symtab.instance(context);
    finder = JavadocClassFinder.instance(context);
    enter = JavadocEnter.instance(context);
    names = Names.instance(context);
    externalizableSym = syms.enterClass(syms.java_base, names.fromString("java.io.Externalizable"));
    chk = Check.instance(context);
    types = com.sun.tools.javac.code.Types.instance(context);
    fileManager = context.get(JavaFileManager.class);
    if (fileManager instanceof JavacFileManager) {
        ((JavacFileManager)fileManager).setSymbolFileEnabled(false);
    }
    docTrees = JavacTrees.instance(context);
    source = Source.instance(context);
    elements =  JavacElements.instance(context);
    typeutils = JavacTypes.instance(context);
    elementToTreePath = new HashMap<>();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:ToolEnvironment.java

示例2: init

import com.sun.tools.javac.util.Context; //导入方法依赖的package包/类
private void init(Context context) {
    modules = Modules.instance(context);
    attr = Attr.instance(context);
    enter = Enter.instance(context);
    elements = JavacElements.instance(context);
    log = Log.instance(context);
    resolve = Resolve.instance(context);
    treeMaker = TreeMaker.instance(context);
    memberEnter = MemberEnter.instance(context);
    names = Names.instance(context);
    types = Types.instance(context);
    docTreeMaker = DocTreeMaker.instance(context);
    parser = ParserFactory.instance(context);
    syms = Symtab.instance(context);
    fileManager = context.get(JavaFileManager.class);
    JavacTask t = context.get(JavacTask.class);
    if (t instanceof JavacTaskImpl)
        javacTaskImpl = (JavacTaskImpl) t;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:JavacTrees.java

示例3: process

import com.sun.tools.javac.util.Context; //导入方法依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
    FSInfo fsInfo = context.get(FSInfo.class);

    round++;
    if (round == 1) {
        boolean expect = Boolean.valueOf(options.get("expect"));
        checkEqual("cache result", fsInfo.isDirectory(testDir.toPath()), expect);
        initialFSInfo = fsInfo;
    } else {
        checkEqual("fsInfo", fsInfo, initialFSInfo);
    }

    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:T7018098.java

示例4: DocEnv

import com.sun.tools.javac.util.Context; //导入方法依赖的package包/类
/**
 * Constructor
 *
 * @param context      Context for this javadoc instance.
 */
protected DocEnv(Context context) {
    context.put(docEnvKey, this);
    this.context = context;

    messager = Messager.instance0(context);
    syms = Symtab.instance(context);
    finder = JavadocClassFinder.instance(context);
    enter = JavadocEnter.instance(context);
    names = Names.instance(context);
    externalizableSym = syms.enterClass(syms.java_base, names.fromString("java.io.Externalizable"));
    chk = Check.instance(context);
    types = Types.instance(context);
    fileManager = context.get(JavaFileManager.class);
    if (fileManager instanceof JavacFileManager) {
        ((JavacFileManager)fileManager).setSymbolFileEnabled(false);
    }

    // Default.  Should normally be reset with setLocale.
    this.doclocale = new DocLocale(this, "", breakiterator);
    source = Source.instance(context);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:DocEnv.java

示例5: attach

import com.sun.tools.javac.util.Context; //导入方法依赖的package包/类
public void attach(Context context, ImportAnalysis2 importAnalysis, Map<Tree, Object> tree2Tag) {
    make = TreeFactory.instance(context);
    elements = JavacElements.instance(context);
    comments = CommentHandlerService.instance(context);
    model = ASTService.instance(context);
    overlay = context.get(ElementOverlay.class);
    this.importAnalysis = importAnalysis;
    this.tree2Tag = tree2Tag;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ImmutableTreeTranslator.java

示例6: Modules

import com.sun.tools.javac.util.Context; //导入方法依赖的package包/类
protected Modules(Context context) {
    context.put(Modules.class, this);
    log = Log.instance(context);
    names = Names.instance(context);
    syms = Symtab.instance(context);
    attr = Attr.instance(context);
    chk = Check.instance(context);
    deferredLintHandler = DeferredLintHandler.instance(context);
    typeEnvs = TypeEnvs.instance(context);
    moduleFinder = ModuleFinder.instance(context);
    types = Types.instance(context);
    fileManager = context.get(JavaFileManager.class);
    source = Source.instance(context);
    allowModules = source.allowModules();
    Options options = Options.instance(context);

    allowAccessIntoSystem = options.isUnset(Option.RELEASE);
    lintOptions = options.isUnset(Option.XLINT_CUSTOM, "-" + LintCategory.OPTIONS.option);

    multiModuleMode = fileManager.hasLocation(StandardLocation.MODULE_SOURCE_PATH);
    ClassWriter classWriter = ClassWriter.instance(context);
    classWriter.multiModuleMode = multiModuleMode;
    JNIWriter jniWriter = JNIWriter.instance(context);
    jniWriter.multiModuleMode = multiModuleMode;

    java_se = names.fromString("java.se");
    java_ = names.fromString("java.");

    addExportsOpt = options.get(Option.ADD_EXPORTS);
    addReadsOpt = options.get(Option.ADD_READS);
    addModsOpt = options.get(Option.ADD_MODULES);
    limitModsOpt = options.get(Option.LIMIT_MODULES);
    moduleVersionOpt = options.get(Option.MODULE_VERSION);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:Modules.java

示例7: instance0

import com.sun.tools.javac.util.Context; //导入方法依赖的package包/类
/** Get the current messager, which is also the compiler log. */
public static Messager instance0(Context context) {
    Log instance = context.get(logKey);
    if (instance == null || !(instance instanceof Messager))
        throw new InternalError("no messager instance!");
    return (Messager)instance;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:Messager.java

示例8: ModuleFinder

import com.sun.tools.javac.util.Context; //导入方法依赖的package包/类
/** Construct a new module finder. */
protected ModuleFinder(Context context) {
    context.put(moduleFinderKey, this);
    names = Names.instance(context);
    syms = Symtab.instance(context);
    fileManager = context.get(JavaFileManager.class);
    log = Log.instance(context);
    classFinder = ClassFinder.instance(context);

    diags = JCDiagnostic.Factory.instance(context);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:ModuleFinder.java

示例9: Start

import com.sun.tools.javac.util.Context; //导入方法依赖的package包/类
public Start(Context context) {
    this.context = Objects.requireNonNull(context);
    apiMode = true;
    defaultDocletClassName = standardDocletClassName;
    docletParentClassLoader = null;

    Log log = context.get(Log.logKey);
    if (log instanceof Messager)
        messager = (Messager) log;
    else {
        PrintWriter out = context.get(Log.errKey);
        messager = (out == null) ? new Messager(context, javadocName)
                : new Messager(context, javadocName, out, out, out);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:Start.java

示例10: process

import com.sun.tools.javac.util.Context; //导入方法依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
    Log log = Log.instance(context);
    PrintWriter noteOut = log.getWriter(Log.WriterKind.NOTICE);
    PrintWriter warnOut = log.getWriter(Log.WriterKind.WARNING);
    PrintWriter errOut  = log.getWriter(Log.WriterKind.ERROR);
    Locale locale = context.get(Locale.class);
    JavacMessages messages = context.get(JavacMessages.messagesKey);

    round++;
    if (round == 1) {
        initialLocale = locale;
        initialMessages = messages;
        initialNoteWriter = noteOut;
        initialWarnWriter = warnOut;
        initialErrWriter  = errOut;

        String writerStringOpt = options.get("WriterString").intern();
        checkEqual("noteWriterString", noteOut.toString().intern(), writerStringOpt);
        checkEqual("warnWriterString", warnOut.toString().intern(), writerStringOpt);
        checkEqual("errWriterString",  errOut.toString().intern(),  writerStringOpt);
    } else {
        checkEqual("locale", locale, initialLocale);
        checkEqual("messages", messages, initialMessages);
        checkEqual("noteWriter", noteOut, initialNoteWriter);
        checkEqual("warnWriter", warnOut, initialWarnWriter);
        checkEqual("errWriter",  errOut,  initialErrWriter);
    }

    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:T6597678.java

示例11: instance

import com.sun.tools.javac.util.Context; //导入方法依赖的package包/类
public static JavacFlowListener instance (final Context context) {
    final JavacFlowListener flowListener = context.get(flowListenerKey);
    return flowListener != null ? flowListener : null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:JavacFlowListener.java

示例12: instance0

import com.sun.tools.javac.util.Context; //导入方法依赖的package包/类
public static JavadocMemberEnter instance0(Context context) {
    MemberEnter instance = context.get(memberEnterKey);
    if (instance == null)
        instance = new JavadocMemberEnter(context);
    return (JavadocMemberEnter)instance;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:JavadocMemberEnter.java

示例13: initProcessorIterator

import com.sun.tools.javac.util.Context; //导入方法依赖的package包/类
private void initProcessorIterator(Context context, Iterable<? extends Processor> processors) {
    Log   log   = Log.instance(context);
    Iterator<? extends Processor> processorIterator;

    if (options.isSet(XPRINT)) {
        try {
            Processor processor = PrintingProcessor.class.newInstance();
            processorIterator = List.of(processor).iterator();
        } catch (Throwable t) {
            AssertionError assertError =
                new AssertionError("Problem instantiating PrintingProcessor.");
            assertError.initCause(t);
            throw assertError;
        }
    } else if (processors != null) {
        processorIterator = processors.iterator();
    } else {
        String processorNames = options.get(PROCESSOR);
        JavaFileManager fileManager = context.get(JavaFileManager.class);
        try {
            // If processorpath is not explicitly set, use the classpath.
            processorClassLoader = fileManager.hasLocation(ANNOTATION_PROCESSOR_PATH)
                ? fileManager.getClassLoader(ANNOTATION_PROCESSOR_PATH)
                : fileManager.getClassLoader(CLASS_PATH);

            /*
             * If the "-processor" option is used, search the appropriate
             * path for the named class.  Otherwise, use a service
             * provider mechanism to create the processor iterator.
             */
            if (processorNames != null) {
                processorIterator = new NameProcessIterator(processorNames, processorClassLoader, log);
            } else {
                processorIterator = new ServiceIterator(processorClassLoader, log);
            }
        } catch (SecurityException e) {
            /*
             * A security exception will occur if we can't create a classloader.
             * Ignore the exception if, with hindsight, we didn't need it anyway
             * (i.e. no processor was specified either explicitly, or implicitly,
             * in service configuration file.) Otherwise, we cannot continue.
             */
            processorIterator = handleServiceLoaderUnavailability("proc.cant.create.loader", e);
        }
    }
    discoveredProcs = new DiscoveredProcessors(processorIterator);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:48,代码来源:JavacProcessingEnvironment.java

示例14: JavacFiler

import com.sun.tools.javac.util.Context; //导入方法依赖的package包/类
JavacFiler(Context context) {
    this.context = context;
    fileManager = context.get(JavaFileManager.class);

    log = Log.instance(context);

    fileObjectHistory = synchronizedSet(new LinkedHashSet<FileObject>());
    generatedSourceNames = synchronizedSet(new LinkedHashSet<String>());
    generatedSourceFileObjects = synchronizedSet(new LinkedHashSet<JavaFileObject>());

    generatedClasses = synchronizedMap(new LinkedHashMap<String, JavaFileObject>());

    openTypeNames  = synchronizedSet(new LinkedHashSet<String>());

    aggregateGeneratedSourceNames = new LinkedHashSet<String>();
    aggregateGeneratedClassNames  = new LinkedHashSet<String>();

    lint = (Lint.instance(context)).isEnabled(PROCESSING);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:20,代码来源:JavacFiler.java

示例15: getTask

import com.sun.tools.javac.util.Context; //导入方法依赖的package包/类
public JavacTask getTask(Writer out,
                         JavaFileManager fileManager,
                         DiagnosticListener<? super JavaFileObject> diagnosticListener,
                         Iterable<String> options,
                         Iterable<String> classes,
                         Iterable<? extends JavaFileObject> compilationUnits)
{
    try {
        Context context = new Context();
        ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);

        final String kindMsg = "All compilation units must be of SOURCE kind";
        if (options != null)
            for (String option : options)
                option.getClass(); // null check
        if (classes != null) {
            for (String cls : classes)
                if (!SourceVersion.isName(cls)) // implicit null check
                    throw new IllegalArgumentException("Not a valid class name: " + cls);
        }
        if (compilationUnits != null) {
            compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
            for (JavaFileObject cu : compilationUnits) {
                if (cu.getKind() != JavaFileObject.Kind.SOURCE)
                    throw new IllegalArgumentException(kindMsg);
            }
        }

        if (diagnosticListener != null)
            context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));

        if (out == null)
            context.put(Log.outKey, new PrintWriter(System.err, true));
        else
            context.put(Log.outKey, new PrintWriter(out, true));

        if (fileManager == null)
            fileManager = getStandardFileManager(diagnosticListener, null, null);
        fileManager = ccw.wrap(fileManager);
        context.put(JavaFileManager.class, fileManager);
        processOptions(context, fileManager, options);
        Main compiler = new Main("javacTask", context.get(Log.outKey));
        return new JavacTaskImpl(compiler, options, context, classes, compilationUnits);
    } catch (ClientCodeException ex) {
        throw new RuntimeException(ex.getCause());
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:48,代码来源:JavacTool.java


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