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

Side by Side Diff: pkg/analyzer_cli/lib/src/package_analyzer.dart

Issue 1762363002: Fix path handling when creating summaries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer_cli.src.package_analyzer; 5 library analyzer_cli.src.package_analyzer;
6 6
7 import 'dart:core' hide Resource; 7 import 'dart:core' hide Resource;
8 import 'dart:io' as io; 8 import 'dart:io' as io;
9 9
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 27 matching lines...) Expand all
38 final ResourceProvider resourceProvider = PhysicalResourceProvider.INSTANCE; 38 final ResourceProvider resourceProvider = PhysicalResourceProvider.INSTANCE;
39 InternalAnalysisContext context; 39 InternalAnalysisContext context;
40 final List<Source> explicitSources = <Source>[]; 40 final List<Source> explicitSources = <Source>[];
41 41
42 PackageAnalyzer(this.options); 42 PackageAnalyzer(this.options);
43 43
44 /** 44 /**
45 * Perform package analysis according to the given [options]. 45 * Perform package analysis according to the given [options].
46 */ 46 */
47 ErrorSeverity analyze() { 47 ErrorSeverity analyze() {
48 packagePath = options.packageModePath; 48 packagePath = resourceProvider.pathContext
49 .join(io.Directory.current.absolute.path, options.packageModePath);
scheglov 2016/03/04 19:15:22 Should we use both absolute() and normalize()?
Paul Berry 2016/03/04 22:11:23 Using normalize() seems like a good idea. Done.
49 packageLibPath = resourceProvider.pathContext.join(packagePath, 'lib'); 50 packageLibPath = resourceProvider.pathContext.join(packagePath, 'lib');
50 if (packageLibPath == null) { 51 if (packageLibPath == null) {
51 errorSink.writeln('--package-mode-path must be set to the root ' 52 errorSink.writeln('--package-mode-path must be set to the root '
52 'folder of the package to analyze.'); 53 'folder of the package to analyze.');
53 io.exitCode = ErrorSeverity.ERROR.ordinal; 54 io.exitCode = ErrorSeverity.ERROR.ordinal;
54 return ErrorSeverity.ERROR; 55 return ErrorSeverity.ERROR;
55 } 56 }
56 57
57 // Write the progress message. 58 // Write the progress message.
58 if (!options.machineFormat) { 59 if (!options.machineFormat) {
59 outSink.writeln("Analyzing sources ${options.sourceFiles}..."); 60 outSink.writeln("Analyzing sources ${options.sourceFiles}...");
60 } 61 }
61 62
62 // Prepare the analysis context. 63 // Prepare the analysis context.
63 _createContext(); 64 _createContext();
64 65
65 // Add sources. 66 // Add sources.
66 ChangeSet changeSet = new ChangeSet(); 67 ChangeSet changeSet = new ChangeSet();
67 for (String path in options.sourceFiles) { 68 for (String path in options.sourceFiles) {
68 if (AnalysisEngine.isDartFileName(path)) { 69 if (AnalysisEngine.isDartFileName(path)) {
69 path = resourceProvider.pathContext.absolute(path);
70 File file = resourceProvider.getFile(path); 70 File file = resourceProvider.getFile(path);
71 if (!file.exists) { 71 if (!file.exists) {
72 errorSink.writeln('File not found: $path'); 72 errorSink.writeln('File not found: $path');
73 io.exitCode = ErrorSeverity.ERROR.ordinal; 73 io.exitCode = ErrorSeverity.ERROR.ordinal;
74 return ErrorSeverity.ERROR; 74 return ErrorSeverity.ERROR;
75 } 75 }
76 Source source = _createSourceInContext(file); 76 Source source = _createSourceInContext(file);
77 explicitSources.add(source); 77 explicitSources.add(source);
78 changeSet.addedSource(source); 78 changeSet.addedSource(source);
79 } 79 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 sink, 174 sink,
175 options, 175 options,
176 (AnalysisError error) => 176 (AnalysisError error) =>
177 AnalyzerImpl.processError(error, options, context)); 177 AnalyzerImpl.processError(error, options, context));
178 for (Source source in explicitSources) { 178 for (Source source in explicitSources) {
179 AnalysisErrorInfo errorInfo = context.getErrors(source); 179 AnalysisErrorInfo errorInfo = context.getErrors(source);
180 formatter.formatErrors([errorInfo]); 180 formatter.formatErrors([errorInfo]);
181 } 181 }
182 } 182 }
183 } 183 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698