langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Dependencies.java
changeset 27857 7e913a535736
parent 25874 83c19f00452c
child 30066 d74c06a92bd8
equal deleted inserted replaced
27856:d4711a6931e2 27857:7e913a535736
    71             instance = new DummyDependencies(context);
    71             instance = new DummyDependencies(context);
    72         }
    72         }
    73         return instance;
    73         return instance;
    74     }
    74     }
    75 
    75 
    76     Dependencies(Context context) {
    76     protected Dependencies(Context context) {
    77         context.put(dependenciesKey, this);
    77         context.put(dependenciesKey, this);
    78     }
    78     }
    79 
    79 
    80     /**
    80     /**
    81      * This enum models different kinds of attribution actions triggered during
    81      * This enum models different kinds of attribution actions triggered during
   120     }
   120     }
   121 
   121 
   122     /**
   122     /**
   123      * Push a new completion node on the stack.
   123      * Push a new completion node on the stack.
   124      */
   124      */
   125     abstract public void push(ClassSymbol s);
   125     abstract public void push(ClassSymbol s, CompletionCause phase);
   126 
   126 
   127     /**
   127     /**
   128      * Push a new attribution node on the stack.
   128      * Push a new attribution node on the stack.
   129      */
   129      */
   130     abstract public void push(AttributionKind ak, JCTree t);
   130     abstract public void push(AttributionKind ak, JCTree t);
   131 
   131 
   132     /**
   132     /**
   133      * Remove current dependency node from the stack.
   133      * Remove current dependency node from the stack.
   134      */
   134      */
   135     abstract public void pop();
   135     abstract public void pop();
       
   136 
       
   137     public enum CompletionCause {
       
   138         CLASS_READER,
       
   139         HEADER_PHASE,
       
   140         HIERARCHY_PHASE,
       
   141         IMPORTS_PHASE,
       
   142         MEMBER_ENTER,
       
   143         MEMBERS_PHASE;
       
   144     }
   136 
   145 
   137     /**
   146     /**
   138      * This class creates a graph of all dependencies as symbols are completed;
   147      * This class creates a graph of all dependencies as symbols are completed;
   139      * when compilation finishes, the resulting dependecy graph is then dumped
   148      * when compilation finishes, the resulting dependecy graph is then dumped
   140      * onto a dot file. Several options are provided to customise the output of the graph.
   149      * onto a dot file. Several options are provided to customise the output of the graph.
   389          * map containing all dependency nodes seen so far
   398          * map containing all dependency nodes seen so far
   390          */
   399          */
   391         Map<String, Node> dependencyNodeMap = new LinkedHashMap<>();
   400         Map<String, Node> dependencyNodeMap = new LinkedHashMap<>();
   392 
   401 
   393         @Override
   402         @Override
   394         public void push(ClassSymbol s) {
   403         public void push(ClassSymbol s, CompletionCause phase) {
   395             Node n = new CompletionNode(s);
   404             Node n = new CompletionNode(s);
   396             if (n == push(n)) {
   405             if (n == push(n)) {
   397                 s.completer = this;
   406                 s.completer = this;
   398             }
   407             }
   399         }
   408         }
   452             }
   461             }
   453         }
   462         }
   454 
   463 
   455         @Override
   464         @Override
   456         public void complete(Symbol sym) throws CompletionFailure {
   465         public void complete(Symbol sym) throws CompletionFailure {
   457             push((ClassSymbol) sym);
   466             push((ClassSymbol) sym, null);
   458             pop();
   467             pop();
   459             sym.completer = this;
   468             sym.completer = this;
   460         }
   469         }
   461 
   470 
   462         /**
   471         /**
   540         private DummyDependencies(Context context) {
   549         private DummyDependencies(Context context) {
   541             super(context);
   550             super(context);
   542         }
   551         }
   543 
   552 
   544         @Override
   553         @Override
   545         public void push(ClassSymbol s) {
   554         public void push(ClassSymbol s, CompletionCause phase) {
   546             //do nothing
   555             //do nothing
   547         }
   556         }
   548 
   557 
   549         @Override
   558         @Override
   550         public void push(AttributionKind ak, JCTree t) {
   559         public void push(AttributionKind ak, JCTree t) {