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

Side by Side Diff: pkg/analysis_server/lib/src/edit/edit_domain.dart

Issue 987663002: Fix for subscribing for notifications for files in packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 edit.domain; 5 library edit.domain;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/collections.dart'; 10 import 'package:analysis_server/src/collections.dart';
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 */ 51 */
52 EditDomainHandler(this.server) { 52 EditDomainHandler(this.server) {
53 searchEngine = server.searchEngine; 53 searchEngine = server.searchEngine;
54 _newRefactoringManager(); 54 _newRefactoringManager();
55 } 55 }
56 56
57 Response format(Request request) { 57 Response format(Request request) {
58 EditFormatParams params = new EditFormatParams.fromRequest(request); 58 EditFormatParams params = new EditFormatParams.fromRequest(request);
59 String file = params.file; 59 String file = params.file;
60 60
61 engine.AnalysisContext context = server.getAnalysisContext(file); 61 ContextSourcePair contextSource = server.getContextSourcePair(file);
62
63 engine.AnalysisContext context = contextSource.context;
62 if (context == null) { 64 if (context == null) {
63 return new Response.formatInvalidFile(request); 65 return new Response.formatInvalidFile(request);
64 } 66 }
65 67
66 Source source = server.getSource(file); 68 Source source = contextSource.source;
67 engine.TimestampedData<String> contents; 69 engine.TimestampedData<String> contents;
68 try { 70 try {
69 contents = context.getContents(source); 71 contents = context.getContents(source);
70 } catch (e) { 72 } catch (e) {
71 return new Response.formatInvalidFile(request); 73 return new Response.formatInvalidFile(request);
72 } 74 }
73 75
74 String unformattedSource = contents.data; 76 String unformattedSource = contents.data;
75 77
76 int start = params.selectionOffset; 78 int start = params.selectionOffset;
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 } 480 }
479 } 481 }
480 if (kind == RefactoringKind.INLINE_METHOD) { 482 if (kind == RefactoringKind.INLINE_METHOD) {
481 List<CompilationUnit> units = server.getResolvedCompilationUnits(file); 483 List<CompilationUnit> units = server.getResolvedCompilationUnits(file);
482 if (units.isNotEmpty) { 484 if (units.isNotEmpty) {
483 refactoring = 485 refactoring =
484 new InlineMethodRefactoring(searchEngine, units[0], offset); 486 new InlineMethodRefactoring(searchEngine, units[0], offset);
485 } 487 }
486 } 488 }
487 if (kind == RefactoringKind.MOVE_FILE) { 489 if (kind == RefactoringKind.MOVE_FILE) {
488 engine.AnalysisContext context = server.getAnalysisContext(file); 490 ContextSourcePair contextSource = server.getContextSourcePair(file);
489 Source source = server.getSource(file); 491 engine.AnalysisContext context = contextSource.context;
492 Source source = contextSource.source;
490 refactoring = new MoveFileRefactoring( 493 refactoring = new MoveFileRefactoring(
491 server.resourceProvider.pathContext, searchEngine, context, source); 494 server.resourceProvider.pathContext, searchEngine, context, source);
492 } 495 }
493 if (kind == RefactoringKind.RENAME) { 496 if (kind == RefactoringKind.RENAME) {
494 List<AstNode> nodes = server.getNodesAtOffset(file, offset); 497 List<AstNode> nodes = server.getNodesAtOffset(file, offset);
495 List<Element> elements = server.getElementsOfNodes(nodes, offset); 498 List<Element> elements = server.getElementsOfNodes(nodes, offset);
496 if (nodes.isNotEmpty && elements.isNotEmpty) { 499 if (nodes.isNotEmpty && elements.isNotEmpty) {
497 AstNode node = nodes[0]; 500 AstNode node = nodes[0];
498 Element element = elements[0]; 501 Element element = elements[0];
499 if (element is FieldFormalParameterElement) { 502 if (element is FieldFormalParameterElement) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 } 625 }
623 if (refactoring is RenameRefactoring) { 626 if (refactoring is RenameRefactoring) {
624 RenameRefactoring renameRefactoring = refactoring; 627 RenameRefactoring renameRefactoring = refactoring;
625 RenameOptions renameOptions = params.options; 628 RenameOptions renameOptions = params.options;
626 renameRefactoring.newName = renameOptions.newName; 629 renameRefactoring.newName = renameOptions.newName;
627 return renameRefactoring.checkNewName(); 630 return renameRefactoring.checkNewName();
628 } 631 }
629 return new RefactoringStatus(); 632 return new RefactoringStatus();
630 } 633 }
631 } 634 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698