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

Side by Side Diff: pkg/analysis_server/lib/src/services/generated/completion.dart

Issue 677303002: Remove unnecessary List creation (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 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library services.completion; 8 library services.completion;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 } 811 }
812 } 812 }
813 813
814 bool _filterAllows(Element element) => _filter._match(element); 814 bool _filterAllows(Element element) => _filter._match(element);
815 815
816 bool _filterDisallows(Element element) => !_filter._match(element); 816 bool _filterDisallows(Element element) => !_filter._match(element);
817 817
818 bool _filterDisallows2(String name) => !_filter._match2(name); 818 bool _filterDisallows2(String name) => !_filter._match2(name);
819 819
820 List<Element> _findAllNotTypes(List<Element> elements) { 820 List<Element> _findAllNotTypes(List<Element> elements) {
821 elements = []; 821 List<Element> elements = <Element>[];
sra1 2014/10/26 06:31:39 This local is shadowing the parameter. The origina
Brian Wilkerson 2014/10/26 15:15:46 Good catch! The original Java code was mistranslat
822 for (JavaIterator<Element> I = new JavaIterator(elements); I.hasNext;) { 822 for (JavaIterator<Element> I = new JavaIterator(elements); I.hasNext;) {
823 Element element = I.next(); 823 Element element = I.next();
824 ElementKind kind = element.kind; 824 ElementKind kind = element.kind;
825 if (kind == ElementKind.FUNCTION || kind == ElementKind.TOP_LEVEL_VARIABLE || kind == ElementKind.GETTER || kind == ElementKind.SETTER) { 825 if (kind == ElementKind.FUNCTION || kind == ElementKind.TOP_LEVEL_VARIABLE || kind == ElementKind.GETTER || kind == ElementKind.SETTER) {
826 continue; 826 continue;
827 } 827 }
828 I.remove(); 828 I.remove();
829 } 829 }
830 return new List.from(elements); 830 return elements;
831 } 831 }
832 832
833 List<Element> _findAllPrefixes() { 833 List<Element> _findAllPrefixes() {
834 LibraryElement lib = _context.compilationUnitElement.enclosingElement; 834 LibraryElement lib = _context.compilationUnitElement.enclosingElement;
835 return lib.prefixes; 835 return lib.prefixes;
836 } 836 }
837 837
838 List<Element> _findAllTypes(LibraryElement library, TopLevelNamesKind topKind) { 838 List<Element> _findAllTypes(LibraryElement library, TopLevelNamesKind topKind) {
839 List<Element> elements = _findTopLevelElements(library, topKind); 839 List<Element> elements = _findTopLevelElements(library, topKind);
840 return _findAllTypes2(elements); 840 return _findAllTypes2(elements);
841 } 841 }
842 842
843 List<Element> _findAllTypes2(List<Element> elements) { 843 List<Element> _findAllTypes2(List<Element> elements) {
844 elements = []; 844 List<Element> elements = <Element>[];
sra1 2014/10/26 06:31:39 ditto
Brian Wilkerson 2014/10/26 15:15:46 Same problem, same solution.
845 for (JavaIterator<Element> I = new JavaIterator(elements); I.hasNext;) { 845 for (JavaIterator<Element> I = new JavaIterator(elements); I.hasNext;) {
846 Element element = I.next(); 846 Element element = I.next();
847 ElementKind kind = element.kind; 847 ElementKind kind = element.kind;
848 if (kind == ElementKind.CLASS || kind == ElementKind.FUNCTION_TYPE_ALIAS) { 848 if (kind == ElementKind.CLASS || kind == ElementKind.FUNCTION_TYPE_ALIAS) {
849 continue; 849 continue;
850 } 850 }
851 I.remove(); 851 I.remove();
852 } 852 }
853 return new List.from(elements); 853 return elements;
854 } 854 }
855 855
856 List<Element> _findTopLevelElements(LibraryElement library, TopLevelNamesKind topKind) { 856 List<Element> _findTopLevelElements(LibraryElement library, TopLevelNamesKind topKind) {
857 List<Element> elements = []; 857 List<Element> elements = [];
858 if (topKind == TopLevelNamesKind.DECLARED_AND_IMPORTS) { 858 if (topKind == TopLevelNamesKind.DECLARED_AND_IMPORTS) {
859 elements.addAll(CorrectionUtils.getTopLevelElements(library)); 859 elements.addAll(CorrectionUtils.getTopLevelElements(library));
860 for (ImportElement imp in library.imports) { 860 for (ImportElement imp in library.imports) {
861 elements.addAll(CorrectionUtils.getImportNamespace(imp).values); 861 elements.addAll(CorrectionUtils.getImportNamespace(imp).values);
862 } 862 }
863 _removeNotMatchingFilter(elements); 863 _removeNotMatchingFilter(elements);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 bool get hasErrorBeforeCompletionLocation { 933 bool get hasErrorBeforeCompletionLocation {
934 List<AnalysisError> errors = _context.errors; 934 List<AnalysisError> errors = _context.errors;
935 if (errors == null || errors.length == 0) { 935 if (errors == null || errors.length == 0) {
936 return false; 936 return false;
937 } 937 }
938 return errors[0].offset <= _completionLocation(); 938 return errors[0].offset <= _completionLocation();
939 } 939 }
940 940
941 List<ImportElement> _importsWithName(SimpleIdentifier libName) { 941 List<ImportElement> _importsWithName(SimpleIdentifier libName) {
942 String name = libName.name; 942 String name = libName.name;
943 List<ImportElement> imports = []; 943 List<ImportElement> imports = <ImportElement>[];
944 for (ImportElement imp in currentLibrary.imports) { 944 for (ImportElement imp in currentLibrary.imports) {
945 PrefixElement prefix = imp.prefix; 945 PrefixElement prefix = imp.prefix;
946 if (prefix != null) { 946 if (prefix != null) {
947 String impName = prefix.displayName; 947 String impName = prefix.displayName;
948 if (name == impName) { 948 if (name == impName) {
949 imports.add(imp); 949 imports.add(imp);
950 } 950 }
951 } 951 }
952 } 952 }
953 return new List.from(imports); 953 return imports;
954 } 954 }
955 955
956 bool _isCompletingKeyword(Token keyword) { 956 bool _isCompletingKeyword(Token keyword) {
957 if (keyword == null) { 957 if (keyword == null) {
958 return false; 958 return false;
959 } 959 }
960 int completionLoc = _context.selectionOffset; 960 int completionLoc = _context.selectionOffset;
961 if (completionLoc >= keyword.offset && completionLoc <= keyword.end) { 961 if (completionLoc >= keyword.offset && completionLoc <= keyword.end) {
962 return true; 962 return true;
963 } 963 }
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 named = true; 1321 named = true;
1322 } else if (param.parameterKind == ParameterKind.POSITIONAL) { 1322 } else if (param.parameterKind == ParameterKind.POSITIONAL) {
1323 positional = true; 1323 positional = true;
1324 } 1324 }
1325 break; 1325 break;
1326 } 1326 }
1327 params.add(param.displayName); 1327 params.add(param.displayName);
1328 types.add(param.type.toString()); 1328 types.add(param.type.toString());
1329 } 1329 }
1330 } 1330 }
1331 prop.setParameterNames(new List.from(params)); 1331 prop.setParameterNames(params);
1332 prop.setParameterTypes(new List.from(types)); 1332 prop.setParameterTypes(types);
1333 prop.setParameterStyle(posCount, named, positional); 1333 prop.setParameterStyle(posCount, named, positional);
1334 } 1334 }
1335 1335
1336 SimpleIdentifier _typeDeclarationName(AstNode node) { 1336 SimpleIdentifier _typeDeclarationName(AstNode node) {
1337 AstNode parent = node; 1337 AstNode parent = node;
1338 while (parent != null) { 1338 while (parent != null) {
1339 if (parent is ClassDeclaration) { 1339 if (parent is ClassDeclaration) {
1340 return (parent as ClassDeclaration).name; 1340 return (parent as ClassDeclaration).name;
1341 } 1341 }
1342 if (parent is ClassTypeAlias) { 1342 if (parent is ClassTypeAlias) {
(...skipping 2353 matching lines...) Expand 10 before | Expand all | Expand 10 after
3696 3696
3697 class TopLevelNamesKind extends Enum<TopLevelNamesKind> { 3697 class TopLevelNamesKind extends Enum<TopLevelNamesKind> {
3698 static const TopLevelNamesKind DECLARED_AND_IMPORTS = const TopLevelNamesKind( 'DECLARED_AND_IMPORTS', 0); 3698 static const TopLevelNamesKind DECLARED_AND_IMPORTS = const TopLevelNamesKind( 'DECLARED_AND_IMPORTS', 0);
3699 3699
3700 static const TopLevelNamesKind DECLARED_AND_EXPORTS = const TopLevelNamesKind( 'DECLARED_AND_EXPORTS', 1); 3700 static const TopLevelNamesKind DECLARED_AND_EXPORTS = const TopLevelNamesKind( 'DECLARED_AND_EXPORTS', 1);
3701 3701
3702 static const List<TopLevelNamesKind> values = const [DECLARED_AND_IMPORTS, DEC LARED_AND_EXPORTS]; 3702 static const List<TopLevelNamesKind> values = const [DECLARED_AND_IMPORTS, DEC LARED_AND_EXPORTS];
3703 3703
3704 const TopLevelNamesKind(String name, int ordinal) : super(name, ordinal); 3704 const TopLevelNamesKind(String name, int ordinal) : super(name, ordinal);
3705 } 3705 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/ast.dart » ('j') | pkg/analyzer/lib/src/generated/ast.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698