langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java
changeset 29776 984a79b71cfe
parent 28146 adf3a039cb7d
child 30404 952a476681b2
equal deleted inserted replaced
29775:dc7df633fea1 29776:984a79b71cfe
     1 /*
     1 /*
     2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2014, 2015, 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
    88     final Log log;
    88     final Log log;
    89     final Attr attr;
    89     final Attr attr;
    90     final DeferredAttr deferredAttr;
    90     final DeferredAttr deferredAttr;
    91     final TreeMaker make;
    91     final TreeMaker make;
    92     final Names names;
    92     final Names names;
       
    93     private final boolean allowDiamondWithAnonymousClassCreation;
    93 
    94 
    94     final EnumSet<AnalyzerMode> analyzerModes;
    95     final EnumSet<AnalyzerMode> analyzerModes;
    95 
    96 
    96     public static Analyzer instance(Context context) {
    97     public static Analyzer instance(Context context) {
    97         Analyzer instance = context.get(analyzerKey);
    98         Analyzer instance = context.get(analyzerKey);
   110         names = Names.instance(context);
   111         names = Names.instance(context);
   111         Options options = Options.instance(context);
   112         Options options = Options.instance(context);
   112         String findOpt = options.get("find");
   113         String findOpt = options.get("find");
   113         //parse modes
   114         //parse modes
   114         Source source = Source.instance(context);
   115         Source source = Source.instance(context);
       
   116         allowDiamondWithAnonymousClassCreation = source.allowDiamondWithAnonymousClassCreation();
   115         analyzerModes = AnalyzerMode.getAnalyzerModes(findOpt, source);
   117         analyzerModes = AnalyzerMode.getAnalyzerModes(findOpt, source);
   116     }
   118     }
   117 
   119 
   118     /**
   120     /**
   119      * This enum defines supported analyzer modes, as well as defining the logic for decoding
   121      * This enum defines supported analyzer modes, as well as defining the logic for decoding
   208 
   210 
   209         @Override
   211         @Override
   210         boolean match(JCNewClass tree) {
   212         boolean match(JCNewClass tree) {
   211             return tree.clazz.hasTag(TYPEAPPLY) &&
   213             return tree.clazz.hasTag(TYPEAPPLY) &&
   212                     !TreeInfo.isDiamond(tree) &&
   214                     !TreeInfo.isDiamond(tree) &&
   213                     tree.def == null;
   215                     (tree.def == null || allowDiamondWithAnonymousClassCreation);
   214         }
   216         }
   215 
   217 
   216         @Override
   218         @Override
   217         JCNewClass map(JCNewClass oldTree, JCNewClass newTree) {
   219         JCNewClass map(JCNewClass oldTree, JCNewClass newTree) {
   218             if (newTree.clazz.hasTag(TYPEAPPLY)) {
   220             if (newTree.clazz.hasTag(TYPEAPPLY)) {