Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Side by Side Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/analysis/model/ProjectImpl.java

Issue 439933005: first incremental cut at editor without packages directories (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, the Dart project authors. 2 * Copyright (c) 2013, the Dart project authors.
3 * 3 *
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except
5 * in compliance with the License. You may obtain a copy of the License at 5 * in compliance with the License. You may obtain a copy of the License at
6 * 6 *
7 * http://www.eclipse.org/legal/epl-v10.html 7 * http://www.eclipse.org/legal/epl-v10.html
8 * 8 *
9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License 9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 return contexts.toArray(new AnalysisContext[contexts.size()]); 734 return contexts.toArray(new AnalysisContext[contexts.size()]);
735 } 735 }
736 736
737 /** 737 /**
738 * Find the most appropriate package resolver for the given container, based o n presence of 738 * Find the most appropriate package resolver for the given container, based o n presence of
739 * pubspec, package roots etc. 739 * pubspec, package roots etc.
740 * 740 *
741 * @return UriResolver used to resolve package: uris. 741 * @return UriResolver used to resolve package: uris.
742 */ 742 */
743 private UriResolver getPackageUriResolver(IContainer container, DartSdk sdk, b oolean hasPubspec) { 743 private UriResolver getPackageUriResolver(IContainer container, DartSdk sdk, b oolean hasPubspec) {
744
745 UriResolver pkgResolver = null;
746 File[] packageRoots = factory.getPackageRoots(container); 744 File[] packageRoots = factory.getPackageRoots(container);
747 if (packageRoots.length > 0) { 745 if (packageRoots.length > 0) {
748 pkgResolver = new PackageUriResolver(packageRoots); 746 return new PackageUriResolver(packageRoots);
749 return pkgResolver;
750 } 747 }
751 File[] packagesDirs = null; 748 if (hasPubspec && !DartCoreDebug.NO_PUB_PACKAGES) {
752 if (hasPubspec) {
753 IPath location = container.getLocation(); 749 IPath location = container.getLocation();
754 if (location != null) { 750 if (location != null) {
755 packagesDirs = new File[] {new File(location.toFile(), PACKAGES_DIRECTOR Y_NAME)}; 751 File[] packagesDirs = new File[] {new File(location.toFile(), PACKAGES_D IRECTORY_NAME)};
752 return new PackageUriResolver(packagesDirs);
756 } 753 }
757 } 754 }
758 if (packagesDirs != null) { 755 if (sdk instanceof DirectoryBasedDartSdk) {
759 pkgResolver = new PackageUriResolver(packagesDirs);
760 } else if (sdk instanceof DirectoryBasedDartSdk) {
761 IPath location = container.getLocation(); 756 IPath location = container.getLocation();
762 if (location != null) { 757 if (location != null) {
763 pkgResolver = new InstrumentedExplicitPackageUriResolver( 758 return new InstrumentedExplicitPackageUriResolver(
764 (DirectoryBasedDartSdk) sdk, 759 (DirectoryBasedDartSdk) sdk,
765 location.toFile()); 760 location.toFile());
766 } 761 }
767 } 762 }
768 return pkgResolver; 763 return null;
769 } 764 }
770 765
771 /** 766 /**
772 * Find the {@link PubFolder} defined for an ancestor. Must synchronize agains t 767 * Find the {@link PubFolder} defined for an ancestor. Must synchronize agains t
773 * {@link #pubFolders} before calling this method and either call {@link #init ialize()} or check 768 * {@link #pubFolders} before calling this method and either call {@link #init ialize()} or check
774 * that {@link #isInitialized()} returns {@code true}. 769 * that {@link #isInitialized()} returns {@code true}.
775 * 770 *
776 * @param path the resource's full path 771 * @param path the resource's full path
777 * @return the containing pub folder or {@code null} if none 772 * @return the containing pub folder or {@code null} if none
778 */ 773 */
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 sourceFactory.setLocalSourcePredicate(new WorkspaceLocalSourcePredicate(cont ainer)); 860 sourceFactory.setLocalSourcePredicate(new WorkspaceLocalSourcePredicate(cont ainer));
866 861
867 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); 862 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
868 options.setHint(DartCore.getPlugin().isHintsEnabled()); 863 options.setHint(DartCore.getPlugin().isHintsEnabled());
869 options.setDart2jsHint(DartCore.getPlugin().isHintsDart2JSEnabled()); 864 options.setDart2jsHint(DartCore.getPlugin().isHintsDart2JSEnabled());
870 options.setAnalyzeAngular(DartCore.getPlugin().isAngularAnalysisEnabled()); 865 options.setAnalyzeAngular(DartCore.getPlugin().isAngularAnalysisEnabled());
871 options.setIncremental(DartCoreDebug.EXPERIMENTAL); 866 options.setIncremental(DartCoreDebug.EXPERIMENTAL);
872 867
873 context.setSourceFactory(sourceFactory); 868 context.setSourceFactory(sourceFactory);
874 context.setAnalysisOptions(options); 869 context.setAnalysisOptions(options);
870
871 if (DartCoreDebug.NO_PUB_PACKAGES && pkgResolver instanceof ExplicitPackageU riResolver) {
872 //TODO (danrubel): Add package sources to context so that it is properly i ndexed
873 // ChangeSet changeSet = new ChangeSet();
874 // for (File dir : ((ExplicitPackageUriResolver) pkgResolver).getPackageDir ectories()) {
875 // // traverse package directory tree
876 // changeSet.addedSource(new FileBasedSource(file));
877 // }
878 // context.applyChanges(changeSet);
879 }
880
875 return context; 881 return context;
876 } 882 }
877 883
878 /** 884 /**
879 * Initialize {@link #pubFolders} and {@link #defaultContext} if not already b een initialized. 885 * Initialize {@link #pubFolders} and {@link #defaultContext} if not already b een initialized.
880 * Must synchronize against {@link #pubFolders} before calling this method. 886 * Must synchronize against {@link #pubFolders} before calling this method.
881 */ 887 */
882 private void initialize() { 888 private void initialize() {
883 if (isInitialized()) { 889 if (isInitialized()) {
884 return; 890 return;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 * @return {@code true} if initialized, else {@code false} 952 * @return {@code true} if initialized, else {@code false}
947 */ 953 */
948 private boolean isInitialized() { 954 private boolean isInitialized() {
949 return defaultContext != null || defaultContextId != null; 955 return defaultContext != null || defaultContextId != null;
950 } 956 }
951 957
952 private void logNoLocation(IContainer container) { 958 private void logNoLocation(IContainer container) {
953 DartCore.logInformation("No location for " + container); 959 DartCore.logInformation("No location for " + container);
954 } 960 }
955 } 961 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698