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

Side by Side Diff: editor/tools/plugins/com.google.dart.command.analyze/src/com/google/dart/command/analyze/AnalyzerMain.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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 showVersion(options, System.out); 63 showVersion(options, System.out);
64 System.exit(0); 64 System.exit(0);
65 } 65 }
66 66
67 if (options.getDartSdkPath() == null) { 67 if (options.getDartSdkPath() == null) {
68 System.out.println(PROGRAM_NAME + ": no Dart SDK found."); 68 System.out.println(PROGRAM_NAME + ": no Dart SDK found.");
69 showUsage(options, System.out); 69 showUsage(options, System.out);
70 System.exit(1); 70 System.exit(1);
71 } 71 }
72 72
73 if (!options.getDartSdkPath().exists()) {
74 System.out.println(PROGRAM_NAME + ": invalid Dart SDK path: " + options.ge tDartSdkPath());
75 showUsage(options, System.out);
76 System.exit(1);
77 }
78
73 if (options.getSdkIndexLocation() != null) { 79 if (options.getSdkIndexLocation() != null) {
74 AnalyzerImpl analyzer = new AnalyzerImpl(options); 80 AnalyzerImpl analyzer = new AnalyzerImpl(options);
75 if (analyzer.createSdkIndex()) { 81 if (analyzer.createSdkIndex()) {
76 System.exit(0); 82 System.exit(0);
77 } else { 83 } else {
78 System.exit(1); 84 System.exit(1);
79 } 85 }
80 } 86 }
81 87
82 if (options.getRunTests()) { 88 if (options.getRunTests()) {
83 runTests(options); 89 runTests(options);
84 System.exit(0); 90 System.exit(0);
85 } 91 }
86 92
87 String sourceFilePath = options.getSourceFile(); 93 try {
94 final AnalyzerImpl analyzer = new AnalyzerImpl(options);
88 95
89 if (sourceFilePath == null) {
90 System.out.println(PROGRAM_NAME + ": no source files were specified.");
91 showUsage(options, System.out);
92 System.exit(1);
93 }
94
95 try {
96 if (options.shouldBatch()) { 96 if (options.shouldBatch()) {
97 BatchRunner.runAsBatch(args, new BatchRunnerInvocation() { 97 BatchRunner.runAsBatch(args, new BatchRunnerInvocation() {
98 @Override 98 @Override
99 public ErrorSeverity invoke(String[] lineArgs) throws Throwable { 99 public ErrorSeverity invoke(String[] lineArgs) throws Throwable {
100 AnalyzerOptions compilerOptions = AnalyzerOptions.createFromArgs(lin eArgs); 100 AnalyzerOptions compilerOptions = AnalyzerOptions.createFromArgs(lin eArgs);
101 101
102 if (compilerOptions.getDartSdkPath() == null) { 102 if (compilerOptions.getDartSdkPath() == null) {
103 compilerOptions.setDartSdkPath(options.getDartSdkPath()); 103 compilerOptions.setDartSdkPath(options.getDartSdkPath());
104 } 104 }
105 105
106 return runAnalyzer(compilerOptions); 106 return runAnalyzer(analyzer, compilerOptions);
107 } 107 }
108 }); 108 });
109 } else { 109 } else {
110 ErrorSeverity result = runAnalyzer(options); 110 String sourceFilePath = options.getSourceFile();
111
112 if (sourceFilePath == null) {
113 System.out.println(PROGRAM_NAME + ": no source files were specified.") ;
114 showUsage(options, System.out);
115 System.exit(1);
116 }
117
118 ErrorSeverity result = runAnalyzer(analyzer, options);
111 119
112 if (result != ErrorSeverity.NONE) { 120 if (result != ErrorSeverity.NONE) {
113 System.exit(result.ordinal()); 121 System.exit(result.ordinal());
114 } 122 }
115 } 123 }
116 } catch (Throwable t) { 124 } catch (Throwable t) {
117 t.printStackTrace(); 125 t.printStackTrace();
118 crashAndExit(); 126 crashAndExit();
119 } 127 }
120 } 128 }
121 129
122 protected static void crashAndExit() { 130 protected static void crashAndExit() {
123 // Our test scripts look for 253 to signal a "crash". 131 // Our test scripts look for 253 to signal a "crash".
124 132
125 System.exit(253); 133 System.exit(253);
126 } 134 }
127 135
128 /** 136 /**
129 * Invoke the compiler to build all of the files passed on the command line 137 * Invoke the compiler to build all of the files passed on the command line
130 * 138 *
131 * @param analyzerOptions parsed command line arguments 139 * @param analyzerOptions parsed command line arguments
132 * @return {@code true} on success, {@code false} on failure. 140 * @return {@code true} on success, {@code false} on failure.
133 */ 141 */
134 protected static ErrorSeverity runAnalyzer(AnalyzerOptions options) throws IOE xception, 142 protected static ErrorSeverity runAnalyzer(AnalyzerImpl analyzer, AnalyzerOpti ons options)
135 AnalysisException { 143 throws IOException, AnalysisException {
136 AnalyzerImpl analyzer = new AnalyzerImpl(options);
137
138 File sourceFile = new File(options.getSourceFile()); 144 File sourceFile = new File(options.getSourceFile());
139 145
140 if (!sourceFile.exists()) { 146 if (!sourceFile.exists()) {
141 System.out.println(PROGRAM_NAME + ": file not found: " + sourceFile); 147 System.out.println(PROGRAM_NAME + ": file not found: " + sourceFile);
142 System.out.println(); 148 System.out.println();
143 showUsage(options, System.out); 149 showUsage(options, System.out);
144 return ErrorSeverity.ERROR; 150 return ErrorSeverity.ERROR;
145 } 151 }
146 152
147 ErrorFormatter formatter = new ErrorFormatter(System.out, options); 153 ErrorFormatter formatter = new ErrorFormatter(System.out, options);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 out.println(" 1: Analysis warnings encountered"); 213 out.println(" 1: Analysis warnings encountered");
208 out.println(" 2: Analysis errors encountered"); 214 out.println(" 2: Analysis errors encountered");
209 out.println(); 215 out.println();
210 } 216 }
211 217
212 private static void showVersion(AnalyzerOptions options, PrintStream out) { 218 private static void showVersion(AnalyzerOptions options, PrintStream out) {
213 out.println(PROGRAM_NAME + " version " + getBuildVersion()); 219 out.println(PROGRAM_NAME + " version " + getBuildVersion());
214 } 220 }
215 221
216 } 222 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698