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

Unified Diff: pkg/analyzer/lib/src/generated/sdk_io.dart

Issue 725143004: Format and sort analyzer and analysis_server packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk.dart ('k') | pkg/analyzer/lib/src/generated/source.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/sdk_io.dart
diff --git a/pkg/analyzer/lib/src/generated/sdk_io.dart b/pkg/analyzer/lib/src/generated/sdk_io.dart
index 91a189691b6f44a6e7248097e4d4fb465fcc8747..4e92f029ed65d5da1d7c9f693a2e46efd7eb4597 100644
--- a/pkg/analyzer/lib/src/generated/sdk_io.dart
+++ b/pkg/analyzer/lib/src/generated/sdk_io.dart
@@ -9,16 +9,16 @@ library engine.sdk.io;
import 'package:analyzer/src/generated/java_engine.dart';
+import 'ast.dart';
+import 'engine.dart';
+import 'error.dart';
import 'java_core.dart';
-import 'java_io.dart';
import 'java_engine_io.dart';
-import 'source_io.dart';
-import 'error.dart';
-import 'scanner.dart';
-import 'ast.dart';
+import 'java_io.dart';
import 'parser.dart';
+import 'scanner.dart';
import 'sdk.dart';
-import 'engine.dart';
+import 'source_io.dart';
/**
* Instances of the class `DirectoryBasedDartSdk` represent a Dart SDK installed in a
@@ -40,51 +40,6 @@ import 'engine.dart';
*/
class DirectoryBasedDartSdk implements DartSdk {
/**
- * The [AnalysisContext] which is used for all of the sources in this [DartSdk].
- */
- InternalAnalysisContext _analysisContext;
-
- /**
- * The directory containing the SDK.
- */
- JavaFile _sdkDirectory;
-
- /**
- * The revision number of this SDK, or `"0"` if the revision number cannot be discovered.
- */
- String _sdkVersion;
-
- /**
- * The file containing the dart2js executable.
- */
- JavaFile _dart2jsExecutable;
-
- /**
- * The file containing the dart formatter executable.
- */
- JavaFile _dartFmtExecutable;
-
- /**
- * The file containing the Dartium executable.
- */
- JavaFile _dartiumExecutable;
-
- /**
- * The file containing the pub executable.
- */
- JavaFile _pubExecutable;
-
- /**
- * The file containing the VM executable.
- */
- JavaFile _vmExecutable;
-
- /**
- * A mapping from Dart library URI's to the library represented by that URI.
- */
- LibraryMap _libraryMap;
-
- /**
* The default SDK, or `null` if the default SDK either has not yet been created or cannot
* be created for some reason.
*/
@@ -128,7 +83,8 @@ class DirectoryBasedDartSdk implements DartSdk {
/**
* The name of the file containing the Dartium executable on Macintosh.
*/
- static String _DARTIUM_EXECUTABLE_NAME_MAC = "Chromium.app/Contents/MacOS/Chromium";
+ static String _DARTIUM_EXECUTABLE_NAME_MAC =
+ "Chromium.app/Contents/MacOS/Chromium";
/**
* The name of the file containing the Dartium executable on Windows.
@@ -218,7 +174,8 @@ class DirectoryBasedDartSdk implements DartSdk {
* @return the default directory for the Dart SDK
*/
static JavaFile get defaultSdkDirectory {
- String sdkProperty = JavaSystemIO.getProperty(_DEFAULT_DIRECTORY_PROPERTY_NAME);
+ String sdkProperty =
+ JavaSystemIO.getProperty(_DEFAULT_DIRECTORY_PROPERTY_NAME);
if (sdkProperty == null) {
return null;
}
@@ -230,6 +187,51 @@ class DirectoryBasedDartSdk implements DartSdk {
}
/**
+ * The [AnalysisContext] which is used for all of the sources in this [DartSdk].
+ */
+ InternalAnalysisContext _analysisContext;
+
+ /**
+ * The directory containing the SDK.
+ */
+ JavaFile _sdkDirectory;
+
+ /**
+ * The revision number of this SDK, or `"0"` if the revision number cannot be discovered.
+ */
+ String _sdkVersion;
+
+ /**
+ * The file containing the dart2js executable.
+ */
+ JavaFile _dart2jsExecutable;
+
+ /**
+ * The file containing the dart formatter executable.
+ */
+ JavaFile _dartFmtExecutable;
+
+ /**
+ * The file containing the Dartium executable.
+ */
+ JavaFile _dartiumExecutable;
+
+ /**
+ * The file containing the pub executable.
+ */
+ JavaFile _pubExecutable;
+
+ /**
+ * The file containing the VM executable.
+ */
+ JavaFile _vmExecutable;
+
+ /**
+ * A mapping from Dart library URI's to the library represented by that URI.
+ */
+ LibraryMap _libraryMap;
+
+ /**
* Initialize a newly created SDK to represent the Dart SDK installed in the given directory.
*
* @param sdkDirectory the directory containing the SDK
@@ -241,44 +243,6 @@ class DirectoryBasedDartSdk implements DartSdk {
}
@override
- Source fromFileUri(Uri uri) {
- JavaFile file = new JavaFile.fromUri(uri);
- String filePath = file.getAbsolutePath();
- String libPath = libraryDirectory.getAbsolutePath();
- if (!filePath.startsWith("$libPath${JavaFile.separator}")) {
- return null;
- }
- filePath = filePath.substring(libPath.length + 1);
- for (SdkLibrary library in _libraryMap.sdkLibraries) {
- String libraryPath = library.path;
- if (filePath.replaceAll('\\', '/') == libraryPath) {
- String path = library.shortName;
- try {
- return new FileBasedSource.con2(parseUriWithException(path), file);
- } on URISyntaxException catch (exception, stackTrace) {
- AnalysisEngine.instance.logger.logInformation(
- "Failed to create URI: $path",
- new CaughtException(exception, stackTrace));
- return null;
- }
- }
- libraryPath = new JavaFile(libraryPath).getParent();
- if (filePath.startsWith("$libraryPath${JavaFile.separator}")) {
- String path = "${library.shortName}/${filePath.substring(libraryPath.length + 1)}";
- try {
- return new FileBasedSource.con2(parseUriWithException(path), file);
- } on URISyntaxException catch (exception, stackTrace) {
- AnalysisEngine.instance.logger.logInformation(
- "Failed to create URI: $path",
- new CaughtException(exception, stackTrace));
- return null;
- }
- }
- }
- return null;
- }
-
- @override
AnalysisContext get context {
if (_analysisContext == null) {
_analysisContext = new SdkAnalysisContext();
@@ -301,7 +265,12 @@ class DirectoryBasedDartSdk implements DartSdk {
*/
JavaFile get dart2JsExecutable {
if (_dart2jsExecutable == null) {
- _dart2jsExecutable = _verifyExecutable(new JavaFile.relative(new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME), OSUtilities.isWindows() ? _DART2JS_EXECUTABLE_NAME_WIN : _DART2JS_EXECUTABLE_NAME));
+ _dart2jsExecutable = _verifyExecutable(
+ new JavaFile.relative(
+ new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME),
+ OSUtilities.isWindows() ?
+ _DART2JS_EXECUTABLE_NAME_WIN :
+ _DART2JS_EXECUTABLE_NAME));
}
return _dart2jsExecutable;
}
@@ -313,19 +282,40 @@ class DirectoryBasedDartSdk implements DartSdk {
*/
JavaFile get dartFmtExecutable {
if (_dartFmtExecutable == null) {
- _dartFmtExecutable = _verifyExecutable(new JavaFile.relative(new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME), OSUtilities.isWindows() ? _DARTFMT_EXECUTABLE_NAME_WIN : _DARTFMT_EXECUTABLE_NAME));
+ _dartFmtExecutable = _verifyExecutable(
+ new JavaFile.relative(
+ new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME),
+ OSUtilities.isWindows() ?
+ _DARTFMT_EXECUTABLE_NAME_WIN :
+ _DARTFMT_EXECUTABLE_NAME));
}
return _dartFmtExecutable;
}
/**
+ * Return the name of the file containing the Dartium executable.
+ *
+ * @return the name of the file containing the Dartium executable
+ */
+ String get dartiumBinaryName {
+ if (OSUtilities.isWindows()) {
+ return _DARTIUM_EXECUTABLE_NAME_WIN;
+ } else if (OSUtilities.isMac()) {
+ return _DARTIUM_EXECUTABLE_NAME_MAC;
+ } else {
+ return _DARTIUM_EXECUTABLE_NAME_LINUX;
+ }
+ }
+
+ /**
* Return the file containing the Dartium executable, or `null` if it does not exist.
*
* @return the file containing the Dartium executable
*/
JavaFile get dartiumExecutable {
if (_dartiumExecutable == null) {
- _dartiumExecutable = _verifyExecutable(new JavaFile.relative(dartiumWorkingDirectory, dartiumBinaryName));
+ _dartiumExecutable = _verifyExecutable(
+ new JavaFile.relative(dartiumWorkingDirectory, dartiumBinaryName));
}
return _dartiumExecutable;
}
@@ -336,16 +326,8 @@ class DirectoryBasedDartSdk implements DartSdk {
*
* @return the directory where dartium can be found
*/
- JavaFile get dartiumWorkingDirectory => getDartiumWorkingDirectory(_sdkDirectory.getParentFile());
-
- /**
- * Return the directory where dartium can be found (the directory that will be the working
- * directory is Dartium is invoked without changing the default).
- *
- * @param installDir the installation directory
- * @return the directory where dartium can be found
- */
- JavaFile getDartiumWorkingDirectory(JavaFile installDir) => new JavaFile.relative(installDir, _DARTIUM_DIRECTORY_NAME);
+ JavaFile get dartiumWorkingDirectory =>
+ getDartiumWorkingDirectory(_sdkDirectory.getParentFile());
/**
* Return the directory containing the SDK.
@@ -359,35 +341,30 @@ class DirectoryBasedDartSdk implements DartSdk {
*
* @return the SDK's documentation directory
*/
- JavaFile get docDirectory => new JavaFile.relative(_sdkDirectory, _DOCS_DIRECTORY_NAME);
+ JavaFile get docDirectory =>
+ new JavaFile.relative(_sdkDirectory, _DOCS_DIRECTORY_NAME);
/**
- * Return the auxiliary documentation file for the given library, or `null` if no such file
- * exists.
+ * Return `true` if this SDK includes documentation.
*
- * @param libraryName the name of the library associated with the documentation file to be
- * returned
- * @return the auxiliary documentation file for the library
+ * @return `true` if this installation of the SDK has documentation
*/
- JavaFile getDocFileFor(String libraryName) {
- JavaFile dir = docDirectory;
- if (!dir.exists()) {
- return null;
- }
- JavaFile libDir = new JavaFile.relative(dir, libraryName);
- JavaFile docFile = new JavaFile.relative(libDir, "$libraryName$_DOC_FILE_SUFFIX");
- if (docFile.exists()) {
- return docFile;
- }
- return null;
- }
+ bool get hasDocumentation => docDirectory.exists();
+
+ /**
+ * Return `true` if the Dartium binary is available.
+ *
+ * @return `true` if the Dartium binary is available
+ */
+ bool get isDartiumInstalled => dartiumExecutable != null;
/**
* Return the directory within the SDK directory that contains the libraries.
*
* @return the directory that contains the libraries
*/
- JavaFile get libraryDirectory => new JavaFile.relative(_sdkDirectory, _LIB_DIRECTORY_NAME);
+ JavaFile get libraryDirectory =>
+ new JavaFile.relative(_sdkDirectory, _LIB_DIRECTORY_NAME);
/**
* Return the file containing the Pub executable, or `null` if it does not exist.
@@ -396,7 +373,10 @@ class DirectoryBasedDartSdk implements DartSdk {
*/
JavaFile get pubExecutable {
if (_pubExecutable == null) {
- _pubExecutable = _verifyExecutable(new JavaFile.relative(new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME), OSUtilities.isWindows() ? _PUB_EXECUTABLE_NAME_WIN : _PUB_EXECUTABLE_NAME));
+ _pubExecutable = _verifyExecutable(
+ new JavaFile.relative(
+ new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME),
+ OSUtilities.isWindows() ? _PUB_EXECUTABLE_NAME_WIN : _PUB_EXECUTABLE_NAME));
}
return _pubExecutable;
}
@@ -404,9 +384,6 @@ class DirectoryBasedDartSdk implements DartSdk {
@override
List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries;
- @override
- SdkLibrary getSdkLibrary(String dartUri) => _libraryMap.getLibrary(dartUri);
-
/**
* Return the revision number of this SDK, or `"0"` if the revision number cannot be
* discovered.
@@ -417,7 +394,8 @@ class DirectoryBasedDartSdk implements DartSdk {
String get sdkVersion {
if (_sdkVersion == null) {
_sdkVersion = DartSdk.DEFAULT_VERSION;
- JavaFile revisionFile = new JavaFile.relative(_sdkDirectory, _VERSION_FILE_NAME);
+ JavaFile revisionFile =
+ new JavaFile.relative(_sdkDirectory, _VERSION_FILE_NAME);
try {
String revision = revisionFile.readAsStringSync();
if (revision != null) {
@@ -439,30 +417,128 @@ class DirectoryBasedDartSdk implements DartSdk {
List<String> get uris => _libraryMap.uris;
/**
+ * Return the name of the file containing the VM executable.
+ *
+ * @return the name of the file containing the VM executable
+ */
+ String get vmBinaryName {
+ if (OSUtilities.isWindows()) {
+ return _VM_EXECUTABLE_NAME_WIN;
+ } else {
+ return _VM_EXECUTABLE_NAME;
+ }
+ }
+
+ /**
* Return the file containing the VM executable, or `null` if it does not exist.
*
* @return the file containing the VM executable
*/
JavaFile get vmExecutable {
if (_vmExecutable == null) {
- _vmExecutable = _verifyExecutable(new JavaFile.relative(new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME), vmBinaryName));
+ _vmExecutable = _verifyExecutable(
+ new JavaFile.relative(
+ new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME),
+ vmBinaryName));
}
return _vmExecutable;
}
+ @override
+ Source fromFileUri(Uri uri) {
+ JavaFile file = new JavaFile.fromUri(uri);
+ String filePath = file.getAbsolutePath();
+ String libPath = libraryDirectory.getAbsolutePath();
+ if (!filePath.startsWith("$libPath${JavaFile.separator}")) {
+ return null;
+ }
+ filePath = filePath.substring(libPath.length + 1);
+ for (SdkLibrary library in _libraryMap.sdkLibraries) {
+ String libraryPath = library.path;
+ if (filePath.replaceAll('\\', '/') == libraryPath) {
+ String path = library.shortName;
+ try {
+ return new FileBasedSource.con2(parseUriWithException(path), file);
+ } on URISyntaxException catch (exception, stackTrace) {
+ AnalysisEngine.instance.logger.logInformation(
+ "Failed to create URI: $path",
+ new CaughtException(exception, stackTrace));
+ return null;
+ }
+ }
+ libraryPath = new JavaFile(libraryPath).getParent();
+ if (filePath.startsWith("$libraryPath${JavaFile.separator}")) {
+ String path =
+ "${library.shortName}/${filePath.substring(libraryPath.length + 1)}";
+ try {
+ return new FileBasedSource.con2(parseUriWithException(path), file);
+ } on URISyntaxException catch (exception, stackTrace) {
+ AnalysisEngine.instance.logger.logInformation(
+ "Failed to create URI: $path",
+ new CaughtException(exception, stackTrace));
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
/**
- * Return `true` if this SDK includes documentation.
+ * Return the directory where dartium can be found (the directory that will be the working
+ * directory is Dartium is invoked without changing the default).
*
- * @return `true` if this installation of the SDK has documentation
+ * @param installDir the installation directory
+ * @return the directory where dartium can be found
*/
- bool get hasDocumentation => docDirectory.exists();
+ JavaFile getDartiumWorkingDirectory(JavaFile installDir) =>
+ new JavaFile.relative(installDir, _DARTIUM_DIRECTORY_NAME);
/**
- * Return `true` if the Dartium binary is available.
+ * Return the auxiliary documentation file for the given library, or `null` if no such file
+ * exists.
*
- * @return `true` if the Dartium binary is available
+ * @param libraryName the name of the library associated with the documentation file to be
+ * returned
+ * @return the auxiliary documentation file for the library
*/
- bool get isDartiumInstalled => dartiumExecutable != null;
+ JavaFile getDocFileFor(String libraryName) {
+ JavaFile dir = docDirectory;
+ if (!dir.exists()) {
+ return null;
+ }
+ JavaFile libDir = new JavaFile.relative(dir, libraryName);
+ JavaFile docFile =
+ new JavaFile.relative(libDir, "$libraryName$_DOC_FILE_SUFFIX");
+ if (docFile.exists()) {
+ return docFile;
+ }
+ return null;
+ }
+
+ @override
+ SdkLibrary getSdkLibrary(String dartUri) => _libraryMap.getLibrary(dartUri);
+
+ /**
+ * Read all of the configuration files to initialize the library maps.
+ *
+ * @param useDart2jsPaths `true` if the dart2js path should be used when it is available
+ * @return the initialized library map
+ */
+ LibraryMap initialLibraryMap(bool useDart2jsPaths) {
+ JavaFile librariesFile = new JavaFile.relative(
+ new JavaFile.relative(libraryDirectory, _INTERNAL_DIR),
+ _LIBRARIES_FILE);
+ try {
+ String contents = librariesFile.readAsStringSync();
+ return new SdkLibrariesReader(
+ useDart2jsPaths).readFromFile(librariesFile, contents);
+ } catch (exception, stackTrace) {
+ AnalysisEngine.instance.logger.logError(
+ "Could not initialize the library map from ${librariesFile.getAbsolutePath()}",
+ new CaughtException(exception, stackTrace));
+ return new LibraryMap();
+ }
+ }
@override
Source mapDartUri(String dartUri) {
@@ -493,59 +569,13 @@ class DirectoryBasedDartSdk implements DartSdk {
}
/**
- * Read all of the configuration files to initialize the library maps.
- *
- * @param useDart2jsPaths `true` if the dart2js path should be used when it is available
- * @return the initialized library map
- */
- LibraryMap initialLibraryMap(bool useDart2jsPaths) {
- JavaFile librariesFile = new JavaFile.relative(new JavaFile.relative(libraryDirectory, _INTERNAL_DIR), _LIBRARIES_FILE);
- try {
- String contents = librariesFile.readAsStringSync();
- return new SdkLibrariesReader(useDart2jsPaths).readFromFile(librariesFile, contents);
- } catch (exception, stackTrace) {
- AnalysisEngine.instance.logger.logError(
- "Could not initialize the library map from ${librariesFile.getAbsolutePath()}",
- new CaughtException(exception, stackTrace));
- return new LibraryMap();
- }
- }
-
- /**
- * Return the name of the file containing the Dartium executable.
- *
- * @return the name of the file containing the Dartium executable
- */
- String get dartiumBinaryName {
- if (OSUtilities.isWindows()) {
- return _DARTIUM_EXECUTABLE_NAME_WIN;
- } else if (OSUtilities.isMac()) {
- return _DARTIUM_EXECUTABLE_NAME_MAC;
- } else {
- return _DARTIUM_EXECUTABLE_NAME_LINUX;
- }
- }
-
- /**
- * Return the name of the file containing the VM executable.
- *
- * @return the name of the file containing the VM executable
- */
- String get vmBinaryName {
- if (OSUtilities.isWindows()) {
- return _VM_EXECUTABLE_NAME_WIN;
- } else {
- return _VM_EXECUTABLE_NAME;
- }
- }
-
- /**
* Verify that the given executable file exists and is executable.
*
* @param file the binary file
* @return the file if it exists and is executable, else `null`
*/
- JavaFile _verifyExecutable(JavaFile file) => file.isExecutable() ? file : null;
+ JavaFile _verifyExecutable(JavaFile file) =>
+ file.isExecutable() ? file : null;
}
/**
@@ -592,7 +622,8 @@ class SdkLibrariesReader {
* @param libraryFileContents the contents from the library file
* @return the library map read from the given source
*/
- LibraryMap readFromFile(JavaFile file, String libraryFileContents) => readFromSource(new FileBasedSource.con1(file), libraryFileContents);
+ LibraryMap readFromFile(JavaFile file, String libraryFileContents) =>
+ readFromSource(new FileBasedSource.con1(file), libraryFileContents);
/**
* Return the library map read from the given source.
@@ -603,14 +634,19 @@ class SdkLibrariesReader {
*/
LibraryMap readFromSource(Source source, String libraryFileContents) {
BooleanErrorListener errorListener = new BooleanErrorListener();
- Scanner scanner = new Scanner(source, new CharSequenceReader(libraryFileContents), errorListener);
+ Scanner scanner = new Scanner(
+ source,
+ new CharSequenceReader(libraryFileContents),
+ errorListener);
Parser parser = new Parser(source, errorListener);
CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize());
- SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_LibraryBuilder(_useDart2jsPaths);
- // If any syntactic errors were found then don't try to visit the AST structure.
+ SdkLibrariesReader_LibraryBuilder libraryBuilder =
+ new SdkLibrariesReader_LibraryBuilder(_useDart2jsPaths);
+ // If any syntactic errors were found then don't try to visit the AST
+ // structure.
if (!errorListener.errorReported) {
unit.accept(libraryBuilder);
}
return libraryBuilder.librariesMap;
}
-}
+}
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk.dart ('k') | pkg/analyzer/lib/src/generated/source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698