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

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

Issue 3001733002: Correctly handle adding imports when pasting into part files (Closed)
Patch Set: Created 3 years, 4 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
« no previous file with comments | « no previous file | pkg/analysis_server/test/integration/analysis/get_imported_elements_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/edit/edit_domain.dart
diff --git a/pkg/analysis_server/lib/src/edit/edit_domain.dart b/pkg/analysis_server/lib/src/edit/edit_domain.dart
index f93dd7991d4c79dc26d5392c438a40b172bb2dbf..8007442c2f0fb9a66f150fab3beadf9c116e6129 100644
--- a/pkg/analysis_server/lib/src/edit/edit_domain.dart
+++ b/pkg/analysis_server/lib/src/edit/edit_domain.dart
@@ -397,6 +397,16 @@ class EditDomainHandler extends AbstractRequestHandler {
if (result == null) {
server.sendResponse(new Response.importElementsInvalidFile(request));
}
+ CompilationUnitElement libraryUnit =
+ result.libraryElement.definingCompilationUnit;
+ if (libraryUnit != result.unit.element) {
+ // The file in the request is a part of a library. We need to pass the
devoncarew 2017/08/15 21:59:30 Just so I understand, if you pass a part into `edi
Brian Wilkerson 2017/08/15 23:32:33 No. If the client passes a part into `edit.importE
+ // defining compilation unit to the computer, not the part.
+ result = await server.getAnalysisResult(libraryUnit.source.fullName);
+ if (result == null) {
+ server.sendResponse(new Response.importElementsInvalidFile(request));
+ }
+ }
//
// Compute the edits required to import the required elements.
//
« no previous file with comments | « no previous file | pkg/analysis_server/test/integration/analysis/get_imported_elements_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698