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

Side by Side Diff: editor/tools/plugins/com.google.dart.command.analyze/src/com/google/dart/command/analyze/AnalyzerImpl.java

Issue 12438007: Updates to the new analyzer to help make the try bot happy. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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) 2012, the Dart project authors. 2 * Copyright (c) 2012, 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 for (AnalysisError error : errors) { 45 for (AnalysisError error : errors) {
46 ErrorSeverity severity = error.getErrorCode().getErrorSeverity(); 46 ErrorSeverity severity = error.getErrorCode().getErrorSeverity();
47 47
48 status = status.max(severity); 48 status = status.max(severity);
49 } 49 }
50 50
51 return status; 51 return status;
52 } 52 }
53 53
54 private AnalyzerOptions options; 54 private AnalyzerOptions options;
55 private DartSdk sdk;
55 56
56 public AnalyzerImpl(AnalyzerOptions options) { 57 public AnalyzerImpl(AnalyzerOptions options) {
57 this.options = options; 58 this.options = options;
59
60 // This sdk is shared between multiple runs of the analyzer.
61 sdk = new DartSdk(options.getDartSdkPath());
58 } 62 }
59 63
60 /** 64 /**
61 * Treats the {@code sourceFile} as the top level library and analyzes the uni t for warnings and 65 * Treats the {@code sourceFile} as the top level library and analyzes the uni t for warnings and
62 * errors. 66 * errors.
63 * 67 *
64 * @param sourceFile file to analyze 68 * @param sourceFile file to analyze
65 * @param options configuration for this analysis pass 69 * @param options configuration for this analysis pass
66 * @param errors the list to add errors to 70 * @param errors the list to add errors to
67 * @return {@code true} on success, {@code false} on failure. 71 * @return {@code true} on success, {@code false} on failure.
68 */ 72 */
69 public ErrorSeverity analyze(File sourceFile, List<AnalysisError> errors) thro ws IOException, 73 public ErrorSeverity analyze(File sourceFile, List<AnalysisError> errors) thro ws IOException,
70 AnalysisException { 74 AnalysisException {
71 if (sourceFile == null) { 75 if (sourceFile == null) {
72 throw new IllegalArgumentException("sourceFile cannot be null"); 76 throw new IllegalArgumentException("sourceFile cannot be null");
73 } 77 }
74 78
75 // TODO(devoncarew): can we share this SDK when running in batch mode?
76 DartSdk sdk = new DartSdk(options.getDartSdkPath());
77
78 AnalysisContext context = AnalysisEngine.getInstance().createAnalysisContext (); 79 AnalysisContext context = AnalysisEngine.getInstance().createAnalysisContext ();
79 80
80 SourceFactory sourceFactory; 81 SourceFactory sourceFactory;
81 82
82 if (options.getPackageRootPath() != null) { 83 if (options.getPackageRootPath() != null) {
83 sourceFactory = new SourceFactory( 84 sourceFactory = new SourceFactory(
84 new DartUriResolver(sdk), 85 new DartUriResolver(sdk),
85 new FileUriResolver(), 86 new FileUriResolver(),
86 new PackageUriResolver(options.getPackageRootPath())); 87 new PackageUriResolver(options.getPackageRootPath()));
87 } else { 88 } else {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 127
127 return true; 128 return true;
128 } catch (IOException ioe) { 129 } catch (IOException ioe) {
129 ioe.printStackTrace(); 130 ioe.printStackTrace();
130 131
131 return false; 132 return false;
132 } 133 }
133 } 134 }
134 135
135 } 136 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698