| OLD | NEW |
| 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 analysis.server; | 5 library analysis.server; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 // prepare AnalysisContext | 784 // prepare AnalysisContext |
| 785 AnalysisContext context = getAnalysisContext(path); | 785 AnalysisContext context = getAnalysisContext(path); |
| 786 if (context == null) { | 786 if (context == null) { |
| 787 return units; | 787 return units; |
| 788 } | 788 } |
| 789 // add a unit for each unit/library combination | 789 // add a unit for each unit/library combination |
| 790 Source unitSource = getSource(path); | 790 Source unitSource = getSource(path); |
| 791 List<Source> librarySources = context.getLibrariesContaining(unitSource); | 791 List<Source> librarySources = context.getLibrariesContaining(unitSource); |
| 792 for (Source librarySource in librarySources) { | 792 for (Source librarySource in librarySources) { |
| 793 CompilationUnit unit = | 793 CompilationUnit unit = |
| 794 context.getResolvedCompilationUnit2(unitSource, librarySource); | 794 context.resolveCompilationUnit2(unitSource, librarySource); |
| 795 if (unit != null) { | 795 if (unit != null) { |
| 796 units.add(unit); | 796 units.add(unit); |
| 797 } | 797 } |
| 798 } | 798 } |
| 799 // done | 799 // done |
| 800 return units; | 800 return units; |
| 801 } | 801 } |
| 802 | 802 |
| 803 /** | 803 /** |
| 804 * Returns [AstNode]s at the given [offset] of the given [file]. | 804 * Returns resolved [AstNode]s at the given [offset] of the given [file]. |
| 805 * | 805 * |
| 806 * May be empty, but not `null`. | 806 * May be empty, but not `null`. |
| 807 */ | 807 */ |
| 808 List<AstNode> getNodesAtOffset(String file, int offset) { | 808 List<AstNode> getNodesAtOffset(String file, int offset) { |
| 809 List<CompilationUnit> units = getResolvedCompilationUnits(file); | 809 List<CompilationUnit> units = getResolvedCompilationUnits(file); |
| 810 List<AstNode> nodes = <AstNode>[]; | 810 List<AstNode> nodes = <AstNode>[]; |
| 811 for (CompilationUnit unit in units) { | 811 for (CompilationUnit unit in units) { |
| 812 AstNode node = new NodeLocator.con1(offset).searchWithin(unit); | 812 AstNode node = new NodeLocator.con1(offset).searchWithin(unit); |
| 813 if (node != null) { | 813 if (node != null) { |
| 814 nodes.add(node); | 814 nodes.add(node); |
| 815 } | 815 } |
| 816 } | 816 } |
| 817 return nodes; | 817 return nodes; |
| 818 } | 818 } |
| 819 | 819 |
| 820 /** | 820 /** |
| 821 * Returns [Element]s at the given [offset] of the given [file]. | 821 * Returns [Element]s at the given [offset] of the given [file]. |
| 822 * | 822 * |
| 823 * May be empty if not resolved, but not `null`. | 823 * May be empty if cannot be resolved, but not `null`. |
| 824 */ | 824 */ |
| 825 List<Element> getElementsAtOffset(String file, int offset) { | 825 List<Element> getElementsAtOffset(String file, int offset) { |
| 826 List<AstNode> nodes = getNodesAtOffset(file, offset); | 826 List<AstNode> nodes = getNodesAtOffset(file, offset); |
| 827 return getElementsOfNodes(nodes, offset); | 827 return getElementsOfNodes(nodes, offset); |
| 828 } | 828 } |
| 829 | 829 |
| 830 /** | 830 /** |
| 831 * Returns [Element]s of the given [nodes]. | 831 * Returns [Element]s of the given [nodes]. |
| 832 * | 832 * |
| 833 * May be empty if not resolved, but not `null`. | 833 * May be empty if not resolved, but not `null`. |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 // send the notification | 936 // send the notification |
| 937 channel.sendNotification( | 937 channel.sendNotification( |
| 938 new ServerErrorParams( | 938 new ServerErrorParams( |
| 939 true, | 939 true, |
| 940 exceptionString, | 940 exceptionString, |
| 941 stackTraceString).toNotification()); | 941 stackTraceString).toNotification()); |
| 942 } | 942 } |
| 943 } | 943 } |
| 944 | 944 |
| 945 typedef void OptionUpdater(AnalysisOptionsImpl options); | 945 typedef void OptionUpdater(AnalysisOptionsImpl options); |
| OLD | NEW |