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

Side by Side Diff: pkg/analyzer/lib/src/generated/element.dart

Issue 1313113002: Fix display of parameter lists in servers Element structure (issue 24194) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: formatted Created 5 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 unified diff | Download patch
« no previous file with comments | « pkg/analysis_server/test/services/completion/imported_reference_contributor_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 engine.element; 5 library engine.element;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/generated/utilities_general.dart'; 9 import 'package:analyzer/src/generated/utilities_general.dart';
10 import 'package:analyzer/src/task/dart.dart'; 10 import 'package:analyzer/src/task/dart.dart';
(...skipping 8673 matching lines...) Expand 10 before | Expand all | Expand 10 after
8684 */ 8684 */
8685 List<ParameterElement> get parameters; 8685 List<ParameterElement> get parameters;
8686 8686
8687 /** 8687 /**
8688 * Return a list containing all of the type parameters defined by this 8688 * Return a list containing all of the type parameters defined by this
8689 * parameter. A parameter will only define other parameters if it is a 8689 * parameter. A parameter will only define other parameters if it is a
8690 * function typed parameter. 8690 * function typed parameter.
8691 */ 8691 */
8692 List<TypeParameterElement> get typeParameters; 8692 List<TypeParameterElement> get typeParameters;
8693 8693
8694 /**
8695 * Append the type, name and possibly the default value of this parameter to
8696 * the given [buffer].
8697 */
8698 void appendToWithoutDelimiters(StringBuffer buffer);
8699
8694 @override 8700 @override
8695 FormalParameter computeNode(); 8701 FormalParameter computeNode();
8696 } 8702 }
8697 8703
8698 /** 8704 /**
8699 * A concrete implementation of a [ParameterElement]. 8705 * A concrete implementation of a [ParameterElement].
8700 */ 8706 */
8701 class ParameterElementImpl extends VariableElementImpl 8707 class ParameterElementImpl extends VariableElementImpl
8702 with PotentiallyConstVariableElement 8708 with ParameterElementMixin, PotentiallyConstVariableElement
8703 implements ParameterElement { 8709 implements ParameterElement {
8704 /** 8710 /**
8705 * An empty list of parameter elements. 8711 * An empty list of parameter elements.
8706 */ 8712 */
8707 @deprecated // Use ParameterElement.EMPTY_LIST 8713 @deprecated // Use ParameterElement.EMPTY_LIST
8708 static const List<ParameterElement> EMPTY_ARRAY = const <ParameterElement>[]; 8714 static const List<ParameterElement> EMPTY_ARRAY = const <ParameterElement>[];
8709 8715
8710 /** 8716 /**
8711 * A list containing all of the parameters defined by this parameter element. 8717 * A list containing all of the parameters defined by this parameter element.
8712 * There will only be parameters if this parameter is a function typed 8718 * There will only be parameters if this parameter is a function typed
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
8828 left = "["; 8834 left = "[";
8829 right = "]"; 8835 right = "]";
8830 } else if (parameterKind == ParameterKind.REQUIRED) {} 8836 } else if (parameterKind == ParameterKind.REQUIRED) {}
8831 break; 8837 break;
8832 } 8838 }
8833 buffer.write(left); 8839 buffer.write(left);
8834 appendToWithoutDelimiters(buffer); 8840 appendToWithoutDelimiters(buffer);
8835 buffer.write(right); 8841 buffer.write(right);
8836 } 8842 }
8837 8843
8838 /**
8839 * Append the type and name of this parameter to the given [buffer].
8840 */
8841 void appendToWithoutDelimiters(StringBuffer buffer) {
8842 buffer.write(type);
8843 buffer.write(" ");
8844 buffer.write(displayName);
8845 if (_defaultValueCode != null) {
8846 if (parameterKind == ParameterKind.NAMED) {
8847 buffer.write(": ");
8848 }
8849 if (parameterKind == ParameterKind.POSITIONAL) {
8850 buffer.write(" = ");
8851 }
8852 buffer.write(_defaultValueCode);
8853 }
8854 }
8855
8856 @override 8844 @override
8857 FormalParameter computeNode() => 8845 FormalParameter computeNode() =>
8858 getNodeMatching((node) => node is FormalParameter); 8846 getNodeMatching((node) => node is FormalParameter);
8859 8847
8860 @override 8848 @override
8861 ElementImpl getChild(String identifier) { 8849 ElementImpl getChild(String identifier) {
8862 for (ParameterElement parameter in _parameters) { 8850 for (ParameterElement parameter in _parameters) {
8863 if ((parameter as ParameterElementImpl).identifier == identifier) { 8851 if ((parameter as ParameterElementImpl).identifier == identifier) {
8864 return parameter as ParameterElementImpl; 8852 return parameter as ParameterElementImpl;
8865 } 8853 }
(...skipping 25 matching lines...) Expand all
8891 } 8879 }
8892 8880
8893 @override 8881 @override
8894 void visitChildren(ElementVisitor visitor) { 8882 void visitChildren(ElementVisitor visitor) {
8895 super.visitChildren(visitor); 8883 super.visitChildren(visitor);
8896 safelyVisitChildren(_parameters, visitor); 8884 safelyVisitChildren(_parameters, visitor);
8897 } 8885 }
8898 } 8886 }
8899 8887
8900 /** 8888 /**
8889 * A mixin that provides a common implementation for methods defined in
8890 * [ParameterElement].
8891 */
8892 abstract class ParameterElementMixin implements ParameterElement {
8893 @override
8894 void appendToWithoutDelimiters(StringBuffer buffer) {
8895 buffer.write(type);
8896 buffer.write(" ");
8897 buffer.write(displayName);
8898 if (defaultValueCode != null) {
8899 if (parameterKind == ParameterKind.NAMED) {
8900 buffer.write(": ");
8901 }
8902 if (parameterKind == ParameterKind.POSITIONAL) {
8903 buffer.write(" = ");
8904 }
8905 buffer.write(defaultValueCode);
8906 }
8907 }
8908 }
8909
8910 /**
8901 * A type with type parameters, such as a class or function type alias. 8911 * A type with type parameters, such as a class or function type alias.
8902 */ 8912 */
8903 abstract class ParameterizedType implements DartType { 8913 abstract class ParameterizedType implements DartType {
8904 /** 8914 /**
8905 * Return a list containing the actual types of the type arguments. If this 8915 * Return a list containing the actual types of the type arguments. If this
8906 * type's element does not have type parameters, then the array should be 8916 * type's element does not have type parameters, then the array should be
8907 * empty (although it is possible for type arguments to be erroneously 8917 * empty (although it is possible for type arguments to be erroneously
8908 * declared). If the element has type parameters and the actual type does not 8918 * declared). If the element has type parameters and the actual type does not
8909 * explicitly include argument values, then the type "dynamic" will be 8919 * explicitly include argument values, then the type "dynamic" will be
8910 * automatically provided. 8920 * automatically provided.
8911 */ 8921 */
8912 List<DartType> get typeArguments; 8922 List<DartType> get typeArguments;
8913 8923
8914 /** 8924 /**
8915 * Return a list containing all of the type parameters declared for this type. 8925 * Return a list containing all of the type parameters declared for this type.
8916 */ 8926 */
8917 List<TypeParameterElement> get typeParameters; 8927 List<TypeParameterElement> get typeParameters;
8918 } 8928 }
8919 8929
8920 /** 8930 /**
8921 * A parameter element defined in a parameterized type where the values of the 8931 * A parameter element defined in a parameterized type where the values of the
8922 * type parameters are known. 8932 * type parameters are known.
8923 */ 8933 */
8924 class ParameterMember extends VariableMember implements ParameterElement { 8934 class ParameterMember extends VariableMember
8935 with ParameterElementMixin
8936 implements ParameterElement {
8925 /** 8937 /**
8926 * Initialize a newly created element to represent a constructor, based on the 8938 * Initialize a newly created element to represent a constructor, based on the
8927 * [baseElement], defined by the [definingType]. 8939 * [baseElement], defined by the [definingType].
8928 */ 8940 */
8929 ParameterMember(ParameterElement baseElement, ParameterizedType definingType) 8941 ParameterMember(ParameterElement baseElement, ParameterizedType definingType)
8930 : super(baseElement, definingType); 8942 : super(baseElement, definingType);
8931 8943
8932 @override 8944 @override
8933 ParameterElement get baseElement => super.baseElement as ParameterElement; 8945 ParameterElement get baseElement => super.baseElement as ParameterElement;
8934 8946
(...skipping 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after
10771 10783
10772 @override 10784 @override
10773 void visitElement(Element element) { 10785 void visitElement(Element element) {
10774 int offset = element.nameOffset; 10786 int offset = element.nameOffset;
10775 if (offset != -1) { 10787 if (offset != -1) {
10776 map[offset] = element; 10788 map[offset] = element;
10777 } 10789 }
10778 super.visitElement(element); 10790 super.visitElement(element);
10779 } 10791 }
10780 } 10792 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/services/completion/imported_reference_contributor_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698