129 * and class are available |
129 * and class are available |
130 **/ |
130 **/ |
131 public boolean preferSource; |
131 public boolean preferSource; |
132 |
132 |
133 /** |
133 /** |
|
134 * Switch: Search classpath and sourcepath for classes before the |
|
135 * bootclasspath |
|
136 */ |
|
137 public boolean userPathsFirst; |
|
138 |
|
139 /** |
134 * The currently selected profile. |
140 * The currently selected profile. |
135 */ |
141 */ |
136 public final Profile profile; |
142 public final Profile profile; |
137 |
143 |
138 /** The log to use for verbose output |
144 /** The log to use for verbose output |
268 allowSimplifiedVarargs = source.allowSimplifiedVarargs(); |
274 allowSimplifiedVarargs = source.allowSimplifiedVarargs(); |
269 |
275 |
270 saveParameterNames = options.isSet("save-parameter-names"); |
276 saveParameterNames = options.isSet("save-parameter-names"); |
271 cacheCompletionFailure = options.isUnset("dev"); |
277 cacheCompletionFailure = options.isUnset("dev"); |
272 preferSource = "source".equals(options.get("-Xprefer")); |
278 preferSource = "source".equals(options.get("-Xprefer")); |
|
279 userPathsFirst = options.isSet(XXUSERPATHSFIRST); |
273 |
280 |
274 profile = Profile.instance(context); |
281 profile = Profile.instance(context); |
275 |
282 |
276 completionFailureName = |
283 completionFailureName = |
277 options.isSet("failcomplete") |
284 options.isSet("failcomplete") |
2647 p.package_info = c; |
2654 p.package_info = c; |
2648 } else { |
2655 } else { |
2649 if (c.owner == p) // it might be an inner class |
2656 if (c.owner == p) // it might be an inner class |
2650 p.members_field.enter(c); |
2657 p.members_field.enter(c); |
2651 } |
2658 } |
2652 } else if (c.classfile != null && (c.flags_field & seen) == 0) { |
2659 } else if (!preferCurrent && c.classfile != null && (c.flags_field & seen) == 0) { |
2653 // if c.classfile == null, we are currently compiling this class |
2660 // if c.classfile == null, we are currently compiling this class |
2654 // and no further action is necessary. |
2661 // and no further action is necessary. |
2655 // if (c.flags_field & seen) != 0, we have already encountered |
2662 // if (c.flags_field & seen) != 0, we have already encountered |
2656 // a file of the same kind; again no further action is necessary. |
2663 // a file of the same kind; again no further action is necessary. |
2657 if ((c.flags_field & (CLASS_SEEN | SOURCE_SEEN)) != 0) |
2664 if ((c.flags_field & (CLASS_SEEN | SOURCE_SEEN)) != 0) |
2693 |
2700 |
2694 protected Location currentLoc; // FIXME |
2701 protected Location currentLoc; // FIXME |
2695 |
2702 |
2696 private boolean verbosePath = true; |
2703 private boolean verbosePath = true; |
2697 |
2704 |
|
2705 // Set to true when the currently selected file should be kept |
|
2706 private boolean preferCurrent; |
|
2707 |
2698 /** Load directory of package into members scope. |
2708 /** Load directory of package into members scope. |
2699 */ |
2709 */ |
2700 private void fillIn(PackageSymbol p) throws IOException { |
2710 private void fillIn(PackageSymbol p) throws IOException { |
2701 if (p.members_field == null) p.members_field = new Scope(p); |
2711 if (p.members_field == null) |
2702 String packageName = p.fullname.toString(); |
2712 p.members_field = new Scope(p); |
2703 |
2713 |
|
2714 preferCurrent = false; |
|
2715 if (userPathsFirst) { |
|
2716 scanUserPaths(p); |
|
2717 preferCurrent = true; |
|
2718 scanPlatformPath(p); |
|
2719 } else { |
|
2720 scanPlatformPath(p); |
|
2721 scanUserPaths(p); |
|
2722 } |
|
2723 verbosePath = false; |
|
2724 } |
|
2725 |
|
2726 /** |
|
2727 * Scans class path and source path for files in given package. |
|
2728 */ |
|
2729 private void scanUserPaths(PackageSymbol p) throws IOException { |
2704 Set<JavaFileObject.Kind> kinds = getPackageFileKinds(); |
2730 Set<JavaFileObject.Kind> kinds = getPackageFileKinds(); |
2705 |
|
2706 fillIn(p, PLATFORM_CLASS_PATH, |
|
2707 fileManager.list(PLATFORM_CLASS_PATH, |
|
2708 packageName, |
|
2709 EnumSet.of(JavaFileObject.Kind.CLASS), |
|
2710 false)); |
|
2711 |
2731 |
2712 Set<JavaFileObject.Kind> classKinds = EnumSet.copyOf(kinds); |
2732 Set<JavaFileObject.Kind> classKinds = EnumSet.copyOf(kinds); |
2713 classKinds.remove(JavaFileObject.Kind.SOURCE); |
2733 classKinds.remove(JavaFileObject.Kind.SOURCE); |
2714 boolean wantClassFiles = !classKinds.isEmpty(); |
2734 boolean wantClassFiles = !classKinds.isEmpty(); |
2715 |
2735 |
2746 log.printVerbose("classpath", path.reverse().toString()); |
2766 log.printVerbose("classpath", path.reverse().toString()); |
2747 } |
2767 } |
2748 } |
2768 } |
2749 } |
2769 } |
2750 |
2770 |
|
2771 String packageName = p.fullname.toString(); |
2751 if (wantSourceFiles && !haveSourcePath) { |
2772 if (wantSourceFiles && !haveSourcePath) { |
2752 fillIn(p, CLASS_PATH, |
2773 fillIn(p, CLASS_PATH, |
2753 fileManager.list(CLASS_PATH, |
2774 fileManager.list(CLASS_PATH, |
2754 packageName, |
2775 packageName, |
2755 kinds, |
2776 kinds, |
2766 fileManager.list(SOURCE_PATH, |
2787 fileManager.list(SOURCE_PATH, |
2767 packageName, |
2788 packageName, |
2768 sourceKinds, |
2789 sourceKinds, |
2769 false)); |
2790 false)); |
2770 } |
2791 } |
2771 verbosePath = false; |
2792 } |
|
2793 |
|
2794 /** |
|
2795 * Scans platform class path for files in given package. |
|
2796 */ |
|
2797 private void scanPlatformPath(PackageSymbol p) throws IOException { |
|
2798 fillIn(p, PLATFORM_CLASS_PATH, |
|
2799 fileManager.list(PLATFORM_CLASS_PATH, |
|
2800 p.fullname.toString(), |
|
2801 EnumSet.of(JavaFileObject.Kind.CLASS), |
|
2802 false)); |
2772 } |
2803 } |
2773 // where |
2804 // where |
2774 private void fillIn(PackageSymbol p, |
2805 private void fillIn(PackageSymbol p, |
2775 Location location, |
2806 Location location, |
2776 Iterable<JavaFileObject> files) |
2807 Iterable<JavaFileObject> files) |