Java Code Examples for com.sun.tools.javac.model.JavacElements#instance()

The following examples show how to use com.sun.tools.javac.model.JavacElements#instance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JNIWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void lazyInit() {
    if (mangler == null) {
        elements = JavacElements.instance(context);
        types = JavacTypes.instance(context);
        mangler = new Mangle(elements, types);
    }
}
 
Example 2
Source File: AbstractCodingRulesAnalyzer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public AbstractCodingRulesAnalyzer(JavacTask task) {
    BasicJavacTask impl = (BasicJavacTask)task;
    Context context = impl.getContext();
    log = Log.instance(context);
    options = Options.instance(context);
    rawDiagnostics = options.isSet("rawDiagnostics");
    diags = JCDiagnostic.Factory.instance(context);
    messages = new Messages();
    syms = Symtab.instance(context);
    elements = JavacElements.instance(context);
    types = JavacTypes.instance(context);
}
 
Example 3
Source File: JavacTrees.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void init(Context 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);

    JavacTask t = context.get(JavacTask.class);
    if (t instanceof JavacTaskImpl)
        javacTaskImpl = (JavacTaskImpl) t;
}
 
Example 4
Source File: JavacFiler.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
JavacFiler(Context context) {
    this.context = context;
    fileManager = context.get(JavaFileManager.class);
    elementUtils = JavacElements.instance(context);

    log = Log.instance(context);
    modules = Modules.instance(context);
    names = Names.instance(context);
    syms = Symtab.instance(context);

    initialInputs = synchronizedSet(new LinkedHashSet<>());
    fileObjectHistory = synchronizedSet(new LinkedHashSet<>());
    generatedSourceNames = synchronizedSet(new LinkedHashSet<>());
    generatedSourceFileObjects = synchronizedSet(new LinkedHashSet<>());

    generatedClasses = synchronizedMap(new LinkedHashMap<>());

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

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

    lint = (Lint.instance(context)).isEnabled(PROCESSING);

    Options options = Options.instance(context);

    defaultTargetModule = options.get(Option.DEFAULT_MODULE_FOR_CREATED_FILES);
}
 
Example 5
Source File: JavacProcessingEnvironment.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected JavacProcessingEnvironment(Context context) {
    this.context = context;
    context.put(JavacProcessingEnvironment.class, this);
    log = Log.instance(context);
    source = Source.instance(context);
    diags = JCDiagnostic.Factory.instance(context);
    options = Options.instance(context);
    printProcessorInfo = options.isSet(XPRINTPROCESSORINFO);
    printRounds = options.isSet(XPRINTROUNDS);
    verbose = options.isSet(VERBOSE);
    lint = Lint.instance(context).isEnabled(PROCESSING);
    if (options.isSet(PROC, "only") || options.isSet(XPRINT)) {
        JavaCompiler compiler = JavaCompiler.instance(context);
        compiler.shouldStopPolicyIfNoError = CompileState.PROCESS;
    }
    fatalErrors = options.isSet("fatalEnterError");
    showResolveErrors = options.isSet("showResolveErrors");
    werror = options.isSet(WERROR);
    platformAnnotations = initPlatformAnnotations();

    // Initialize services before any processors are initialized
    // in case processors use them.
    filer = new JavacFiler(context);
    messager = new JavacMessager(context, this);
    elementUtils = JavacElements.instance(context);
    typeUtils = JavacTypes.instance(context);
    processorOptions = initProcessorOptions(context);
    unmatchedProcessorOptions = initUnmatchedProcessorOptions();
    messages = JavacMessages.instance(context);
    taskListener = MultiTaskListener.instance(context);
    initProcessorClassLoader();
}
 
Example 6
Source File: JavacFiler.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
JavacFiler(Context context) {
    this.context = context;
    fileManager = context.get(JavaFileManager.class);
    elementUtils = JavacElements.instance(context);

    log = Log.instance(context);
    modules = Modules.instance(context);
    names = Names.instance(context);
    syms = Symtab.instance(context);

    initialInputs = synchronizedSet(new LinkedHashSet<>());
    fileObjectHistory = synchronizedSet(new LinkedHashSet<>());
    generatedSourceNames = synchronizedSet(new LinkedHashSet<>());
    generatedSourceFileObjects = synchronizedSet(new LinkedHashSet<>());

    generatedClasses = synchronizedMap(new LinkedHashMap<>());

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

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

    lint = (Lint.instance(context)).isEnabled(PROCESSING);

    Options options = Options.instance(context);

    defaultTargetModule = options.get(Option.DEFAULT_MODULE_FOR_CREATED_FILES);
}
 
Example 7
Source File: JavacProcessingEnvironment.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected JavacProcessingEnvironment(Context context) {
    this.context = context;
    context.put(JavacProcessingEnvironment.class, this);
    log = Log.instance(context);
    source = Source.instance(context);
    diags = JCDiagnostic.Factory.instance(context);
    options = Options.instance(context);
    printProcessorInfo = options.isSet(XPRINTPROCESSORINFO);
    printRounds = options.isSet(XPRINTROUNDS);
    verbose = options.isSet(VERBOSE);
    lint = Lint.instance(context).isEnabled(PROCESSING);
    if (options.isSet(PROC, "only") || options.isSet(XPRINT)) {
        JavaCompiler compiler = JavaCompiler.instance(context);
        compiler.shouldStopPolicyIfNoError = CompileState.PROCESS;
    }
    fatalErrors = options.isSet("fatalEnterError");
    showResolveErrors = options.isSet("showResolveErrors");
    werror = options.isSet(WERROR);
    platformAnnotations = initPlatformAnnotations();

    // Initialize services before any processors are initialized
    // in case processors use them.
    filer = new JavacFiler(context);
    messager = new JavacMessager(context, this);
    elementUtils = JavacElements.instance(context);
    typeUtils = JavacTypes.instance(context);
    processorOptions = initProcessorOptions(context);
    unmatchedProcessorOptions = initUnmatchedProcessorOptions();
    messages = JavacMessages.instance(context);
    taskListener = MultiTaskListener.instance(context);
    initProcessorClassLoader();
}
 
Example 8
Source File: JavacProcessingEnvironment.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected JavacProcessingEnvironment(Context context) {
    this.context = context;
    context.put(JavacProcessingEnvironment.class, this);
    log = Log.instance(context);
    source = Source.instance(context);
    diags = JCDiagnostic.Factory.instance(context);
    options = Options.instance(context);
    printProcessorInfo = options.isSet(XPRINTPROCESSORINFO);
    printRounds = options.isSet(XPRINTROUNDS);
    verbose = options.isSet(VERBOSE);
    lint = Lint.instance(context).isEnabled(PROCESSING);
    if (options.isSet(PROC, "only") || options.isSet(XPRINT)) {
        JavaCompiler compiler = JavaCompiler.instance(context);
        compiler.shouldStopPolicyIfNoError = CompileState.PROCESS;
    }
    fatalErrors = options.isSet("fatalEnterError");
    showResolveErrors = options.isSet("showResolveErrors");
    werror = options.isSet(WERROR);
    platformAnnotations = initPlatformAnnotations();

    // Initialize services before any processors are initialized
    // in case processors use them.
    filer = new JavacFiler(context);
    messager = new JavacMessager(context, this);
    elementUtils = JavacElements.instance(context);
    typeUtils = JavacTypes.instance(context);
    processorOptions = initProcessorOptions(context);
    unmatchedProcessorOptions = initUnmatchedProcessorOptions();
    messages = JavacMessages.instance(context);
    taskListener = MultiTaskListener.instance(context);
    initProcessorClassLoader();
}
 
Example 9
Source File: JavacProcessingEnvironment.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected JavacProcessingEnvironment(Context context) {
    this.context = context;
    context.put(JavacProcessingEnvironment.class, this);
    log = Log.instance(context);
    source = Source.instance(context);
    diags = JCDiagnostic.Factory.instance(context);
    options = Options.instance(context);
    printProcessorInfo = options.isSet(XPRINTPROCESSORINFO);
    printRounds = options.isSet(XPRINTROUNDS);
    verbose = options.isSet(VERBOSE);
    lint = Lint.instance(context).isEnabled(PROCESSING);
    if (options.isSet(PROC, "only") || options.isSet(XPRINT)) {
        JavaCompiler compiler = JavaCompiler.instance(context);
        compiler.shouldStopPolicyIfNoError = CompileState.PROCESS;
    }
    fatalErrors = options.isSet("fatalEnterError");
    showResolveErrors = options.isSet("showResolveErrors");
    werror = options.isSet(WERROR);
    platformAnnotations = initPlatformAnnotations();

    // Initialize services before any processors are initialized
    // in case processors use them.
    filer = new JavacFiler(context);
    messager = new JavacMessager(context, this);
    elementUtils = JavacElements.instance(context);
    typeUtils = JavacTypes.instance(context);
    processorOptions = initProcessorOptions(context);
    unmatchedProcessorOptions = initUnmatchedProcessorOptions();
    messages = JavacMessages.instance(context);
    taskListener = MultiTaskListener.instance(context);
    initProcessorClassLoader();
}
 
Example 10
Source File: JavacAST.java    From EasyMPermission with MIT License 5 votes vote down vote up
/**
 * Creates a new JavacAST of the provided Compilation Unit.
 * 
 * @param messager A Messager for warning and error reporting.
 * @param context A Context object for interfacing with the compiler.
 * @param top The compilation unit, which serves as the top level node in the tree to be built.
 */
public JavacAST(Messager messager, Context context, JCCompilationUnit top) {
	super(sourceName(top), packageDeclaration(top), new JavacImportList(top));
	setTop(buildCompilationUnit(top));
	this.context = context;
	this.messager = messager;
	this.log = Log.instance(context);
	this.elements = JavacElements.instance(context);
	this.treeMaker = new JavacTreeMaker(TreeMaker.instance(context));
	this.symtab = Symtab.instance(context);
	this.javacTypes = JavacTypes.instance(context);
	clearChanged();
}
 
Example 11
Source File: JavacTrees.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void init(Context 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);

    JavacTask t = context.get(JavacTask.class);
    if (t instanceof JavacTaskImpl)
        javacTaskImpl = (JavacTaskImpl) t;
}
 
Example 12
Source File: JavacProcessingEnvironment.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public JavacProcessingEnvironment(Context context, Iterable<? extends Processor> processors) {
    this.context = context;
    log = Log.instance(context);
    source = Source.instance(context);
    diags = JCDiagnostic.Factory.instance(context);
    options = Options.instance(context);
    printProcessorInfo = options.isSet(XPRINTPROCESSORINFO);
    printRounds = options.isSet(XPRINTROUNDS);
    verbose = options.isSet(VERBOSE);
    lint = Lint.instance(context).isEnabled(PROCESSING);
    procOnly = options.isSet(PROC, "only") || options.isSet(XPRINT);
    fatalErrors = options.isSet("fatalEnterError");
    showResolveErrors = options.isSet("showResolveErrors");
    werror = options.isSet(WERROR);
    platformAnnotations = initPlatformAnnotations();
    foundTypeProcessors = false;

    // Initialize services before any processors are initialized
    // in case processors use them.
    filer = new JavacFiler(context);
    messager = new JavacMessager(context, this);
    elementUtils = JavacElements.instance(context);
    typeUtils = JavacTypes.instance(context);
    processorOptions = initProcessorOptions(context);
    unmatchedProcessorOptions = initUnmatchedProcessorOptions();
    messages = JavacMessages.instance(context);
    initProcessorIterator(context, processors);
}
 
Example 13
Source File: JavacTrees.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void init(Context 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);

    JavacTask t = context.get(JavacTask.class);
    if (t instanceof JavacTaskImpl)
        javacTaskImpl = (JavacTaskImpl) t;
}
 
Example 14
Source File: JavacProcessingEnvironment.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected JavacProcessingEnvironment(Context context) {
    this.context = context;
    context.put(JavacProcessingEnvironment.class, this);
    log = Log.instance(context);
    source = Source.instance(context);
    diags = JCDiagnostic.Factory.instance(context);
    options = Options.instance(context);
    printProcessorInfo = options.isSet(XPRINTPROCESSORINFO);
    printRounds = options.isSet(XPRINTROUNDS);
    verbose = options.isSet(VERBOSE);
    lint = Lint.instance(context).isEnabled(PROCESSING);
    if (options.isSet(PROC, "only") || options.isSet(XPRINT)) {
        JavaCompiler compiler = JavaCompiler.instance(context);
        compiler.shouldStopPolicyIfNoError = CompileState.PROCESS;
    }
    fatalErrors = options.isSet("fatalEnterError");
    showResolveErrors = options.isSet("showResolveErrors");
    werror = options.isSet(WERROR);
    platformAnnotations = initPlatformAnnotations();

    // Initialize services before any processors are initialized
    // in case processors use them.
    filer = new JavacFiler(context);
    messager = new JavacMessager(context, this);
    elementUtils = JavacElements.instance(context);
    typeUtils = JavacTypes.instance(context);
    processorOptions = initProcessorOptions(context);
    unmatchedProcessorOptions = initUnmatchedProcessorOptions();
    messages = JavacMessages.instance(context);
    taskListener = MultiTaskListener.instance(context);
    initProcessorClassLoader();
}
 
Example 15
Source File: JNIWriter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void lazyInit() {
    if (mangler == null) {
        elements = JavacElements.instance(context);
        types = JavacTypes.instance(context);
        mangler = new Mangle(elements, types);
    }
}
 
Example 16
Source File: JNIWriter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void lazyInit() {
    if (mangler == null) {
        elements = JavacElements.instance(context);
        types = JavacTypes.instance(context);
        mangler = new Mangle(elements, types);
    }
}
 
Example 17
Source File: JavacProcessingEnvironment.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public JavacProcessingEnvironment(Context context, Iterable<? extends Processor> processors) {
    this.context = context;
    log = Log.instance(context);
    source = Source.instance(context);
    diags = JCDiagnostic.Factory.instance(context);
    options = Options.instance(context);
    printProcessorInfo = options.isSet(XPRINTPROCESSORINFO);
    printRounds = options.isSet(XPRINTROUNDS);
    verbose = options.isSet(VERBOSE);
    lint = Lint.instance(context).isEnabled(PROCESSING);
    procOnly = options.isSet(PROC, "only") || options.isSet(XPRINT);
    fatalErrors = options.isSet("fatalEnterError");
    showResolveErrors = options.isSet("showResolveErrors");
    werror = options.isSet(WERROR);
    platformAnnotations = initPlatformAnnotations();
    foundTypeProcessors = false;

    // Initialize services before any processors are initialized
    // in case processors use them.
    filer = new JavacFiler(context);
    messager = new JavacMessager(context, this);
    elementUtils = JavacElements.instance(context);
    typeUtils = JavacTypes.instance(context);
    processorOptions = initProcessorOptions(context);
    unmatchedProcessorOptions = initUnmatchedProcessorOptions();
    messages = JavacMessages.instance(context);
    initProcessorIterator(context, processors);
}
 
Example 18
Source File: JavacProcessingEnvironment.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected JavacProcessingEnvironment(Context context) {
    this.context = context;
    context.put(JavacProcessingEnvironment.class, this);
    log = Log.instance(context);
    source = Source.instance(context);
    diags = JCDiagnostic.Factory.instance(context);
    options = Options.instance(context);
    printProcessorInfo = options.isSet(XPRINTPROCESSORINFO);
    printRounds = options.isSet(XPRINTROUNDS);
    verbose = options.isSet(VERBOSE);
    lint = Lint.instance(context).isEnabled(PROCESSING);
    if (options.isSet(PROC, "only") || options.isSet(XPRINT)) {
        JavaCompiler compiler = JavaCompiler.instance(context);
        compiler.shouldStopPolicyIfNoError = CompileState.PROCESS;
    }
    fatalErrors = options.isSet("fatalEnterError");
    showResolveErrors = options.isSet("showResolveErrors");
    werror = options.isSet(WERROR);
    platformAnnotations = initPlatformAnnotations();

    // Initialize services before any processors are initialized
    // in case processors use them.
    filer = new JavacFiler(context);
    messager = new JavacMessager(context, this);
    elementUtils = JavacElements.instance(context);
    typeUtils = JavacTypes.instance(context);
    processorOptions = initProcessorOptions(context);
    unmatchedProcessorOptions = initUnmatchedProcessorOptions();
    messages = JavacMessages.instance(context);
    taskListener = MultiTaskListener.instance(context);
    initProcessorClassLoader();
}
 
Example 19
Source File: BasicJavacTask.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Elements getElements() {
    return JavacElements.instance(context);
}
 
Example 20
Source File: JavacProcessingEnvironment.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected JavacProcessingEnvironment(Context context) {
    this.context = context;
    context.put(JavacProcessingEnvironment.class, this);
    log = Log.instance(context);
    source = Source.instance(context);
    diags = JCDiagnostic.Factory.instance(context);
    options = Options.instance(context);
    printProcessorInfo = options.isSet(Option.XPRINTPROCESSORINFO);
    printRounds = options.isSet(Option.XPRINTROUNDS);
    verbose = options.isSet(Option.VERBOSE);
    lint = Lint.instance(context).isEnabled(PROCESSING);
    compiler = JavaCompiler.instance(context);
    if (options.isSet(Option.PROC, "only") || options.isSet(Option.XPRINT)) {
        compiler.shouldStopPolicyIfNoError = CompileState.PROCESS;
    }
    fatalErrors = options.isSet("fatalEnterError");
    showResolveErrors = options.isSet("showResolveErrors");
    werror = options.isSet(Option.WERROR);
    fileManager = context.get(JavaFileManager.class);
    platformAnnotations = initPlatformAnnotations();

    // Initialize services before any processors are initialized
    // in case processors use them.
    filer = new JavacFiler(context);
    messager = new JavacMessager(context, this);
    elementUtils = JavacElements.instance(context);
    typeUtils = JavacTypes.instance(context);
    modules = Modules.instance(context);
    types = Types.instance(context);
    annotate = Annotate.instance(context);
    processorOptions = initProcessorOptions();
    unmatchedProcessorOptions = initUnmatchedProcessorOptions();
    messages = JavacMessages.instance(context);
    taskListener = MultiTaskListener.instance(context);
    symtab = Symtab.instance(context);
    names = Names.instance(context);
    enter = Enter.instance(context);
    initialCompleter = ClassFinder.instance(context).getCompleter();
    chk = Check.instance(context);
    initProcessorLoader();

    allowModules = source.allowModules();
}