equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2001, 2014, 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 |
24 */ |
24 */ |
25 |
25 |
26 package com.sun.tools.javac.comp; |
26 package com.sun.tools.javac.comp; |
27 |
27 |
28 import java.util.AbstractQueue; |
28 import java.util.AbstractQueue; |
29 import com.sun.tools.javac.util.Context; |
29 import java.util.Collection; |
30 import java.util.HashMap; |
30 import java.util.HashMap; |
31 import java.util.Iterator; |
31 import java.util.Iterator; |
32 import java.util.LinkedList; |
32 import java.util.LinkedList; |
33 import java.util.Map; |
33 import java.util.Map; |
34 import java.util.Queue; |
34 import java.util.Queue; |
35 import javax.tools.JavaFileObject; |
35 import javax.tools.JavaFileObject; |
|
36 |
|
37 import com.sun.tools.javac.util.Context; |
36 |
38 |
37 /** A queue of all as yet unattributed classes. |
39 /** A queue of all as yet unattributed classes. |
38 * |
40 * |
39 * <p><b>This is NOT part of any supported API. |
41 * <p><b>This is NOT part of any supported API. |
40 * If you write code that depends on this, you do so at your own risk. |
42 * If you write code that depends on this, you do so at your own risk. |
77 if (contentsByFile != null) |
79 if (contentsByFile != null) |
78 addByFile(e); |
80 addByFile(e); |
79 return true; |
81 return true; |
80 } else { |
82 } else { |
81 return false; |
83 return false; |
|
84 } |
|
85 } |
|
86 |
|
87 /** |
|
88 * Removes all unattributed classes except those belonging to the given |
|
89 * collection of files. |
|
90 * |
|
91 * @param sourceFiles The source files of the classes to keep. |
|
92 */ |
|
93 public void retainFiles(Collection<? extends JavaFileObject> sourceFiles) { |
|
94 for (Iterator<Env<AttrContext>> it = contents.iterator(); it.hasNext(); ) { |
|
95 Env<AttrContext> env = it.next(); |
|
96 if (!sourceFiles.contains(env.toplevel.sourcefile)) { |
|
97 if (contentsByFile != null) removeByFile(env); |
|
98 it.remove(); |
|
99 } |
82 } |
100 } |
83 } |
101 } |
84 |
102 |
85 public Env<AttrContext> poll() { |
103 public Env<AttrContext> poll() { |
86 if (size() == 0) |
104 if (size() == 0) |