src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
changeset 54539 bdbfa0115fc6
parent 53773 454d54d8af1c
child 54650 d9208a660094
equal deleted inserted replaced
54538:ef331769d4ab 54539:bdbfa0115fc6
     1 /*
     1 /*
     2  * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
     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.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   186     private final Completer initialCompleter;
   186     private final Completer initialCompleter;
   187     private final Check chk;
   187     private final Check chk;
   188 
   188 
   189     private final Context context;
   189     private final Context context;
   190 
   190 
       
   191     /**
       
   192      * Support for preview language features.
       
   193      */
       
   194     private final Preview preview;
       
   195 
   191     /** Get the JavacProcessingEnvironment instance for this context. */
   196     /** Get the JavacProcessingEnvironment instance for this context. */
   192     public static JavacProcessingEnvironment instance(Context context) {
   197     public static JavacProcessingEnvironment instance(Context context) {
   193         JavacProcessingEnvironment instance = context.get(JavacProcessingEnvironment.class);
   198         JavacProcessingEnvironment instance = context.get(JavacProcessingEnvironment.class);
   194         if (instance == null)
   199         if (instance == null)
   195             instance = new JavacProcessingEnvironment(context);
   200             instance = new JavacProcessingEnvironment(context);
   234         dcfh = DeferredCompletionFailureHandler.instance(context);
   239         dcfh = DeferredCompletionFailureHandler.instance(context);
   235         names = Names.instance(context);
   240         names = Names.instance(context);
   236         enter = Enter.instance(context);
   241         enter = Enter.instance(context);
   237         initialCompleter = ClassFinder.instance(context).getCompleter();
   242         initialCompleter = ClassFinder.instance(context).getCompleter();
   238         chk = Check.instance(context);
   243         chk = Check.instance(context);
       
   244         preview = Preview.instance(context);
   239         initProcessorLoader();
   245         initProcessorLoader();
   240     }
   246     }
   241 
   247 
   242     public void setProcessors(Iterable<? extends Processor> processors) {
   248     public void setProcessors(Iterable<? extends Processor> processors) {
   243         Assert.checkNull(discoveredProcs);
   249         Assert.checkNull(discoveredProcs);
  1673     @DefinedBy(Api.ANNOTATION_PROCESSING)
  1679     @DefinedBy(Api.ANNOTATION_PROCESSING)
  1674     public Locale getLocale() {
  1680     public Locale getLocale() {
  1675         return messages.getCurrentLocale();
  1681         return messages.getCurrentLocale();
  1676     }
  1682     }
  1677 
  1683 
       
  1684     @DefinedBy(Api.ANNOTATION_PROCESSING)
       
  1685     public boolean isPreviewEnabled() {
       
  1686         return preview.isEnabled();
       
  1687     }
       
  1688 
  1678     public Set<Symbol.PackageSymbol> getSpecifiedPackages() {
  1689     public Set<Symbol.PackageSymbol> getSpecifiedPackages() {
  1679         return specifiedPackages;
  1690         return specifiedPackages;
  1680     }
  1691     }
  1681 
  1692 
  1682     public static final Pattern noMatches  = Pattern.compile("(\\P{all})+");
  1693     public static final Pattern noMatches  = Pattern.compile("(\\P{all})+");