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

Unified Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 300553014: Implementation for 'analysis.updateContent' API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/analysis_server.dart
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index e2bd67e2fc640fe0de4bc7925dd2e47918e8f82d..0a4f3c2b94a55145b12177549a17a167d12cfdb4 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -274,7 +274,7 @@ class AnalysisServer {
}
/**
- * Implementation for `server.setAnalysisRoots`.
+ * Implementation for `analysis.setAnalysisRoots`.
*
* TODO(scheglov) implement complete projects/contexts semantics.
*
@@ -330,10 +330,31 @@ class AnalysisServer {
}
/**
+ * Implementation for `analysis.updateContent`.
+ */
+ void updateContent(Map<String, ContentChange> changes) {
+ changes.forEach((file, change) {
+ AnalysisContext analysisContext = _getAnalysisContext(file);
+ if (analysisContext != null) {
+ Source source = _getSource(file);
+ if (change.offset == null) {
+print('setContents: $file');
Brian Wilkerson 2014/05/28 20:38:15 Remove debugging output?
scheglov 2014/05/28 20:44:05 Done.
+ analysisContext.setContents(source, change.content);
+ } else {
+print('setChangedContents: $file');
+ analysisContext.setChangedContents(source, change.content,
+ change.offset, change.oldLength, change.newLength);
+ }
+ addContextToWorkQueue(analysisContext);
+ }
+ });
+ }
+
+ /**
* Return the [AnalysisContext] that is used to analyze the given [path].
* Return `null` if there is no such context.
*/
- AnalysisContext test_getAnalysisContext(String path) {
+ AnalysisContext _getAnalysisContext(String path) {
for (Folder folder in folderMap.keys) {
if (path.startsWith(folder.fullName)) {
return folderMap[folder].context;
@@ -343,18 +364,25 @@ class AnalysisServer {
}
/**
+ * Return the [Source] of the Dart file with the given [path].
+ */
+ Source _getSource(String path) {
+ File file = resourceProvider.getResource(path);
+ return file.createSource(UriKind.FILE_URI);
+ }
+
+ /**
* Return the [CompilationUnit] of the Dart file with the given [path].
* Return `null` if the file is not a part of any context.
*/
CompilationUnit test_getResolvedCompilationUnit(String path) {
// prepare AnalysisContext
- AnalysisContext context = test_getAnalysisContext(path);
+ AnalysisContext context = _getAnalysisContext(path);
if (context == null) {
return null;
}
// prepare sources
- File file = resourceProvider.getResource(path);
- Source unitSource = file.createSource(UriKind.FILE_URI);
+ Source unitSource = _getSource(path);
List<Source> librarySources = context.getLibrariesContaining(unitSource);
if (librarySources.isEmpty) {
return null;
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/domain_analysis.dart » ('j') | pkg/analysis_server/test/domain_analysis_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698