[analysis_server] minor cleanups to analysis server spec generation

Change-Id: I9fd780fb627eaab24731d426e5a0f51b9608f189
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249734
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Devon Carew 2022-06-27 17:21:02 +00:00 committed by Commit Bot
parent 78bb59655a
commit cb5b66f694
17 changed files with 147 additions and 153 deletions

View file

@ -170,12 +170,12 @@ a:focus, a:hover {
</p>
<p>
Every request is required to have two fields and may have two
additional optional fields. The first required field is the id
additional optional fields. The first required field is the 'id'
field, which is only used by the server to associate a response
with the request that generated the response. The second
required field is the method field, which is used to determine
required field is the 'method' field, which is used to determine
what the server is being requested to do. One optional field is
the params field, whose structure is dependent on the method
the 'params' field, whose structure is dependent on the method
being requested. The structure of this field is described with
each request for which it is required. The other optional field
is the 'clientRequestTime' field, which is a number indicating
@ -186,11 +186,11 @@ a:focus, a:hover {
</p>
<p>
Every response has up to three fields. The first field is the
id field, which is always present and whose value is the
'id' field, which is always present and whose value is the
identifier that was passed to the request that generated the
response. The second field is the error field, which is only
response. The second field is the 'error' field, which is only
present if an error was encountered while processing the
request. The third field is the result field, whose structure
request. The third field is the 'result' field, whose structure
is dependent on the method being responded to, and is described
with each request that will produce it.
</p>
@ -209,9 +209,9 @@ a:focus, a:hover {
errors can be returned together at a later time.
</p>
<p>
Each notification has two fields. The first field is the event
Each notification has two fields. The first field is the 'event'
field, which identifies the kind of notification. The second
field is the params field, whose structure is dependent on the
field is the 'params' field, whose structure is dependent on the
kind of notification being sent. The structure of this field is
described with each notification.
</p>
@ -298,7 +298,7 @@ a:focus, a:hover {
<h3>Domains</h3>
<p>
For convenience, the API is divided into domains. Each domain is specified
in a separate section below. The specifications of the APIs refer to data
in a separate section below. The specifications of the API's refer to data
structures beyond the standard JSON primitives. These data structures are
documented in the section titled <a href="#types">Types</a>.
</p>
@ -434,7 +434,7 @@ a:focus, a:hover {
<h1>Domains</h1>
<h2 class="domain"><a name="domain_server">server domain</a></h2>
<p>
The server domain contains APIs related to the execution of
The server domain contains API's related to the execution of
the server.
</p>
@ -628,7 +628,7 @@ a:focus, a:hover {
</dd></dl></dd></dl>
<h2 class="domain"><a name="domain_analysis">analysis domain</a></h2>
<p>
The analysis domain contains APIs related to the analysis of
The analysis domain contains API's related to the analysis of
files.
</p>
@ -962,7 +962,7 @@ a:focus, a:hover {
file. If none is found, then the parents of the directory
will be searched until such a file is found or the root of
the file system is reached. If such a file is found, it will
be used to resolve package: URIs within the file.
be used to resolve package: URI's within the file.
</p>
<h4>parameters:</h4><dl><dt class="field"><b>included: List&lt;<a href="#type_FilePath">FilePath</a>&gt;</b></dt><dd>
@ -3142,7 +3142,7 @@ a:focus, a:hover {
<h2 class="domain"><a name="domain_flutter">flutter domain</a></h2>
<p>
The analysis domain contains APIs related to Flutter support.
The analysis domain contains API's related to Flutter support.
</p>
@ -3230,7 +3230,7 @@ a:focus, a:hover {
<h2 class="domain"><a name="types">Types</a></h2>
<p>
This section contains descriptions of the data types referenced
in the APIs of the various domains.
in the API's of the various domains.
</p>
@ -4045,10 +4045,10 @@ a:focus, a:hover {
0x01 - set if the element is explicitly or implicitly abstract
</li>
<li>
0x02 - set if the element was declared to be const
0x02 - set if the element was declared to be 'const'
</li>
<li>
0x04 - set if the element was declared to be final
0x04 - set if the element was declared to be 'final'
</li>
<li>
0x08 - set if the element is a static member of a class or is a

View file

@ -483,7 +483,7 @@ abstract class IntegrationTestMixin {
/// directory containing the file for a pubspec.yaml file. If none is found,
/// then the parents of the directory will be searched until such a file is
/// found or the root of the file system is reached. If such a file is found,
/// it will be used to resolve package: URIs within the file.
/// it will be used to resolve package: URI's within the file.
///
/// Parameters
///

View file

@ -24,7 +24,7 @@ String _capitalize(String name) =>
'${name.substring(0, 1).toUpperCase()}${name.substring(1)}';
List<String> _generateDartDoc(Element html) => html.children
.where((Element elem) => elem.localName == 'p')
.where((Element elem) => elem.name == 'p')
.map<String>((Element elem) => innerText(elem).trim())
.toList();

View file

@ -109,24 +109,24 @@ class ApiReader {
if (!requiredAttributes.contains(name) &&
!optionalAttributes.contains(name)) {
throw Exception(
'$context: Unexpected attribute in ${element.localName}: $name');
'$context: Unexpected attribute in ${element.name}: $name');
}
attributesFound.add(name);
});
for (var expectedAttribute in requiredAttributes) {
if (!attributesFound.contains(expectedAttribute)) {
throw Exception(
'$context: ${element.localName} must contain attribute $expectedAttribute');
'$context: ${element.name} must contain attribute $expectedAttribute');
}
}
}
/// Check that the given [element] has the given [expectedName].
void checkName(dom.Element element, String expectedName, [String? context]) {
if (element.localName != expectedName) {
context ??= element.localName;
if (element.name != expectedName) {
context ??= element.name;
throw Exception(
'$context: Expected $expectedName, found ${element.localName}');
'$context: Expected $expectedName, found ${element.name}');
}
}
@ -165,13 +165,12 @@ class ApiReader {
dom.Element getAncestor(dom.Element html, String name, String context) {
var ancestor = html.parent;
while (ancestor != null) {
if (ancestor.localName == name) {
if (ancestor.name == name) {
return ancestor;
}
ancestor = ancestor.parent;
}
throw Exception(
'$context: <${html.localName}> must be nested within <$name>');
throw Exception('$context: <${html.name}> must be nested within <$name>');
}
/// Create a [Notification] object from an HTML representation such as:
@ -316,7 +315,7 @@ class ApiReader {
var htmlContents = file.readAsStringSync();
var document = dom.parse(htmlContents, file.uri);
var htmlElement = document.children
.singleWhere((element) => element.localName!.toLowerCase() == 'html');
.singleWhere((element) => element.name.toLowerCase() == 'html');
return apiFromHtml(htmlElement);
}
@ -329,11 +328,11 @@ class ApiReader {
}
for (var node in parent.nodes) {
if (node is dom.Element) {
var processor = elementProcessors[node.localName];
var processor = elementProcessors[node.name];
if (processor != null) {
processor(node);
} else if (specialElements.contains(node.localName)) {
throw Exception('$context: Unexpected use of <${node.localName}>');
} else if (specialElements.contains(node.name)) {
throw Exception('$context: Unexpected use of <${node.name}>');
} else {
recurse(node, context, elementProcessors);
}

View file

@ -209,19 +209,19 @@ public interface AnalysisServer {
* If an included path represents a file, then server will look in the directory containing the
* file for a pubspec.yaml file. If none is found, then the parents of the directory will be
* searched until such a file is found or the root of the file system is reached. If such a file is
* found, it will be used to resolve package: URIs within the file.
* found, it will be used to resolve package: URI's within the file.
*
* @param included A list of the files and directories that should be analyzed.
* @param excluded A list of the files and directories within the included directories that should
* not be analyzed.
* not be analyzed.
* @param packageRoots A mapping from source directories to package roots that should override the
* normal package: URI resolution mechanism. If a package root is a file, then the analyzer
* will behave as though that file is a ".dart_tool/package_config.json" file in the source
* directory. The effect is the same as specifying the file as a "--packages" parameter to
* the Dart VM when executing any Dart file inside the source directory. Files in any
* directories that are not overridden by this mapping have their package: URI's resolved
* using the normal pubspec.yaml mechanism. If this field is absent, or the empty map is
* specified, that indicates that the normal pubspec.yaml mechanism should always be used.
* normal package: URI resolution mechanism. If a package root is a file, then the analyzer
* will behave as though that file is a ".dart_tool/package_config.json" file in the source
* directory. The effect is the same as specifying the file as a "--packages" parameter to
* the Dart VM when executing any Dart file inside the source directory. Files in any
* directories that are not overridden by this mapping have their package: URI's resolved
* using the normal pubspec.yaml mechanism. If this field is absent, or the empty map is
* specified, that indicates that the normal pubspec.yaml mechanism should always be used.
*/
public void analysis_setAnalysisRoots(List<String> included, List<String> excluded, Map<String, String> packageRoots);
@ -286,7 +286,7 @@ public interface AnalysisServer {
* the existing subscriptions will remain unchanged.
*
* @param subscriptions A table mapping services to a list of the files being subscribed to the
* service.
* service.
*/
public void analysis_setSubscriptions(Map<String, List<String>> subscriptions);
@ -300,7 +300,7 @@ public interface AnalysisServer {
* path to a directory on the filesystem.
*
* @param files A table mapping the files whose content has changed to a description of the content
* change.
* change.
*/
public void analysis_updateContent(Map<String, Object> files, UpdateContentConsumer consumer);
@ -396,7 +396,7 @@ public interface AnalysisServer {
* @param file The path of the file into which this completion is being inserted.
* @param id The identifier of the AvailableSuggestionSet containing the selected label.
* @param label The label from the AvailableSuggestionSet with the `id` for which insertion
* information is requested.
* information is requested.
* @param offset The offset in the file where the completion will be inserted.
*/
public void completion_getSuggestionDetails(String file, int id, String label, int offset, GetSuggestionDetailsConsumer consumer);
@ -413,10 +413,10 @@ public interface AnalysisServer {
* @param file The path of the file into which this completion is being inserted.
* @param offset The offset in the file where the completion will be inserted.
* @param completion The completion from the selected CompletionSuggestion. It could be a name of a
* class, or a name of a constructor in form "typeName.constructorName()", or an
* enumeration constant in form "enumName.constantName", etc.
* class, or a name of a constructor in form "typeName.constructorName()", or an enumeration
* constant in form "enumName.constantName", etc.
* @param libraryUri The URI of the library to import, so that the element referenced in the
* completion becomes accessible.
* completion becomes accessible.
*/
public void completion_getSuggestionDetails2(String file, int offset, String completion, String libraryUri, GetSuggestionDetails2Consumer consumer);
@ -439,17 +439,17 @@ public interface AnalysisServer {
* @param file The file containing the point at which suggestions are to be made.
* @param offset The offset within the file at which suggestions are to be made.
* @param maxResults The maximum number of suggestions to return. If the number of suggestions
* after filtering is greater than the maxResults, then isIncomplete is set to true.
* after filtering is greater than the maxResults, then isIncomplete is set to true.
* @param completionCaseMatchingMode The mode of code completion being invoked. If no value is
* provided, MATCH_FIRST_CHAR will be assumed.
* provided, MATCH_FIRST_CHAR will be assumed.
* @param completionMode The mode of code completion being invoked. If no value is provided, BASIC
* will be assumed. BASIC is also the only currently supported.
* will be assumed. BASIC is also the only currently supported.
* @param invocationCount The number of times that the user has invoked code completion at the same
* code location, counting from 1. If no value is provided, 1 will be assumed.
* code location, counting from 1. If no value is provided, 1 will be assumed.
* @param timeout The approximate time in milliseconds that the server should spend. The server
* will perform some steps anyway, even if it takes longer than the specified timeout. This
* field is intended to be used for benchmarking, and usually should not be provided, so
* that the default timeout is used.
* will perform some steps anyway, even if it takes longer than the specified timeout. This
* field is intended to be used for benchmarking, and usually should not be provided, so
* that the default timeout is used.
*/
public void completion_getSuggestions2(String file, int offset, int maxResults, String completionCaseMatchingMode, String completionMode, int invocationCount, int timeout, GetSuggestions2Consumer consumer);
@ -463,9 +463,9 @@ public interface AnalysisServer {
* paths are replaced by the given set of paths.
*
* @param paths A list of objects each containing a path and the additional libraries from which
* the client is interested in receiving completion suggestions. If one configured path is
* beneath another, the descendent will override the ancestors' configured libraries of
* interest.
* the client is interested in receiving completion suggestions. If one configured path is
* beneath another, the descendent will override the ancestors' configured libraries of
* interest.
*
* @deprecated
*/
@ -508,15 +508,15 @@ public interface AnalysisServer {
* specified sources if a change in a specified source requires it.
*
* @param included A list of the files and directories for which edits should be suggested. If a
* request is made with a path that is invalid, e.g. is not absolute and normalized, an
* error of type INVALID_FILE_PATH_FORMAT will be generated. If a request is made for a
* file which does not exist, or which is not currently subject to analysis (e.g. because
* it is not associated with any analysis root specified to analysis.setAnalysisRoots), an
* error of type FILE_NOT_ANALYZED will be generated.
* request is made with a path that is invalid, e.g. is not absolute and normalized, an
* error of type INVALID_FILE_PATH_FORMAT will be generated. If a request is made for a file
* which does not exist, or which is not currently subject to analysis (e.g. because it is
* not associated with any analysis root specified to analysis.setAnalysisRoots), an error
* of type FILE_NOT_ANALYZED will be generated.
* @param inTestMode A flag indicating whether the bulk fixes are being run in test mode. The only
* difference is that in test mode the fix processor will look for a configuration file
* that can modify the content of the data file used to compute the fixes when data-driven
* fixes are being considered. If this field is omitted the flag defaults to false.
* difference is that in test mode the fix processor will look for a configuration file that
* can modify the content of the data file used to compute the fixes when data-driven fixes
* are being considered. If this field is omitted the flag defaults to false.
*/
public void edit_bulkFixes(List<String> included, boolean inTestMode, BulkFixesConsumer consumer);
@ -619,12 +619,12 @@ public interface AnalysisServer {
* @param offset The offset of the region involved in the refactoring.
* @param length The length of the region involved in the refactoring.
* @param validateOnly True if the client is only requesting that the values of the options be
* validated and no change be generated.
* validated and no change be generated.
* @param options Data used to provide values provided by the user. The structure of the data is
* dependent on the kind of refactoring being performed. The data that is expected is
* documented in the section titled Refactorings, labeled as "Options". This field can be
* omitted if the refactoring does not require any options or if the values of those
* options are not known.
* dependent on the kind of refactoring being performed. The data that is expected is
* documented in the section titled Refactorings, labeled as "Options". This field can be
* omitted if the refactoring does not require any options or if the values of those options
* are not known.
*/
public void edit_getRefactoring(String kind, String file, int offset, int length, boolean validateOnly, RefactoringOptions options, GetRefactoringConsumer consumer);
@ -655,9 +655,9 @@ public interface AnalysisServer {
* @param file The file in which the specified elements are to be made accessible.
* @param elements The elements to be made accessible in the specified file.
* @param offset The offset at which the specified elements need to be made accessible. If
* provided, this is used to guard against adding imports for text that would be inserted
* into a comment, string literal, or other location where the imports would not be
* necessary.
* provided, this is used to guard against adding imports for text that would be inserted
* into a comment, string literal, or other location where the imports would not be
* necessary.
*/
public void edit_importElements(String file, List<ImportedElements> elements, int offset, ImportElementsConsumer consumer);
@ -719,7 +719,7 @@ public interface AnalysisServer {
* responsible for managing the lifetime of execution contexts.
*
* @param contextRoot The path of the Dart or HTML file that will be launched, or the path of the
* directory containing the file.
* directory containing the file.
*/
public void execution_createContext(String contextRoot, CreateContextConsumer consumer);
@ -751,17 +751,17 @@ public interface AnalysisServer {
* @param code The code to get suggestions in.
* @param offset The offset within the code to get suggestions at.
* @param contextFile The path of the context file, e.g. the file of the current debugger frame.
* The combination of the context file and context offset can be used to ensure that all
* variables of the context are available for completion (with their static types).
* The combination of the context file and context offset can be used to ensure that all
* variables of the context are available for completion (with their static types).
* @param contextOffset The offset in the context file, e.g. the line offset in the current
* debugger frame.
* debugger frame.
* @param variables The runtime context variables that are potentially referenced in the code.
* @param expressions The list of sub-expressions in the code for which the client wants to provide
* runtime types. It does not have to be the full list of expressions requested by the
* server, for missing expressions their static types will be used. When this field is
* omitted, the server will return completion suggestions only when there are no
* interesting sub-expressions in the given code. The client may provide an empty list, in
* this case the server will return completion suggestions.
* runtime types. It does not have to be the full list of expressions requested by the
* server, for missing expressions their static types will be used. When this field is
* omitted, the server will return completion suggestions only when there are no interesting
* sub-expressions in the given code. The client may provide an empty list, in this case the
* server will return completion suggestions.
*/
public void execution_getSuggestions(String code, int offset, String contextFile, int contextOffset, List<RuntimeCompletionVariable> variables, List<RuntimeCompletionExpression> expressions, GetSuggestionsConsumer consumer);
@ -849,7 +849,7 @@ public interface AnalysisServer {
* the existing subscriptions will remain unchanged.
*
* @param subscriptions A table mapping services to a list of the files being subscribed to the
* service.
* service.
*/
public void flutter_setSubscriptions(Map<String, List<String>> subscriptions);
@ -864,14 +864,14 @@ public interface AnalysisServer {
* intermediate widgets instantiated.
*
* @param id The identifier of the property, previously returned as a part of a
* FlutterWidgetProperty. An error of type FLUTTER_SET_WIDGET_PROPERTY_VALUE_INVALID_ID is
* generated if the identifier is not valid.
* FlutterWidgetProperty. An error of type FLUTTER_SET_WIDGET_PROPERTY_VALUE_INVALID_ID is
* generated if the identifier is not valid.
* @param value The new value to set for the property. If absent, indicates that the property
* should be removed. If the property corresponds to an optional parameter, the
* corresponding named argument is removed. If the property isRequired is true,
* FLUTTER_SET_WIDGET_PROPERTY_VALUE_IS_REQUIRED error is generated. If the expression is
* not a syntactically valid Dart code, then
* FLUTTER_SET_WIDGET_PROPERTY_VALUE_INVALID_EXPRESSION is reported.
* should be removed. If the property corresponds to an optional parameter, the
* corresponding named argument is removed. If the property isRequired is true,
* FLUTTER_SET_WIDGET_PROPERTY_VALUE_IS_REQUIRED error is generated. If the expression is
* not a syntactically valid Dart code, then
* FLUTTER_SET_WIDGET_PROPERTY_VALUE_INVALID_EXPRESSION is reported.
*/
public void flutter_setWidgetPropertyValue(int id, FlutterWidgetPropertyValue value, SetWidgetPropertyValueConsumer consumer);
@ -928,7 +928,7 @@ public interface AnalysisServer {
* search.results notification as they become available.
*
* @param file The file containing the declaration of or reference to the element used to define
* the search.
* the search.
* @param offset The offset within the file of the declaration of or reference to the element.
* @param includePotential True if potential matches are to be included in the results.
*/
@ -979,11 +979,11 @@ public interface AnalysisServer {
* Return top-level and class member declarations.
*
* @param file If this field is provided, return only declarations in this file. If this field is
* missing, return declarations in all files.
* missing, return declarations in all files.
* @param pattern The regular expression used to match the names of declarations. If this field is
* missing, return all declarations.
* missing, return all declarations.
* @param maxResults The maximum number of declarations to return. If this field is missing, return
* all matching declarations.
* all matching declarations.
*/
public void search_getElementDeclarations(String file, String pattern, int maxResults, GetElementDeclarationsConsumer consumer);
@ -993,7 +993,7 @@ public interface AnalysisServer {
* Return the type hierarchy of the class declared or referenced at the given location.
*
* @param file The file containing the declaration or reference to the type for which a hierarchy
* is being requested.
* is being requested.
* @param offset The offset of the name of the type within the file.
* @param superOnly True if the client is only requesting superclasses and interfaces hierarchy.
*/

View file

@ -66,8 +66,8 @@ public class Element {
* A bit-map containing the following flags:
*
* - 0x01 - set if the element is explicitly or implicitly abstract
* - 0x02 - set if the element was declared to be const
* - 0x04 - set if the element was declared to be final
* - 0x02 - set if the element was declared to be 'const'
* - 0x04 - set if the element was declared to be 'final'
* - 0x08 - set if the element is a static member of a class or is a top-level function or field
* - 0x10 - set if the element is private
* - 0x20 - set if the element is deprecated
@ -167,8 +167,8 @@ public class Element {
* A bit-map containing the following flags:
*
* - 0x01 - set if the element is explicitly or implicitly abstract
* - 0x02 - set if the element was declared to be const
* - 0x04 - set if the element was declared to be final
* - 0x02 - set if the element was declared to be 'const'
* - 0x04 - set if the element was declared to be 'final'
* - 0x08 - set if the element is a static member of a class or is a top-level function or field
* - 0x10 - set if the element is private
* - 0x20 - set if the element is deprecated

View file

@ -67,12 +67,12 @@
</p>
<p>
Every request is required to have two fields and may have two
additional optional fields. The first required field is the id
additional optional fields. The first required field is the 'id'
field, which is only used by the server to associate a response
with the request that generated the response. The second
required field is the method field, which is used to determine
required field is the 'method' field, which is used to determine
what the server is being requested to do. One optional field is
the params field, whose structure is dependent on the method
the 'params' field, whose structure is dependent on the method
being requested. The structure of this field is described with
each request for which it is required. The other optional field
is the 'clientRequestTime' field, which is a number indicating
@ -83,11 +83,11 @@
</p>
<p>
Every response has up to three fields. The first field is the
id field, which is always present and whose value is the
'id' field, which is always present and whose value is the
identifier that was passed to the request that generated the
response. The second field is the error field, which is only
response. The second field is the 'error' field, which is only
present if an error was encountered while processing the
request. The third field is the result field, whose structure
request. The third field is the 'result' field, whose structure
is dependent on the method being responded to, and is described
with each request that will produce it.
</p>
@ -106,9 +106,9 @@
errors can be returned together at a later time.
</p>
<p>
Each notification has two fields. The first field is the event
Each notification has two fields. The first field is the 'event'
field, which identifies the kind of notification. The second
field is the params field, whose structure is dependent on the
field is the 'params' field, whose structure is dependent on the
kind of notification being sent. The structure of this field is
described with each notification.
</p>
@ -195,7 +195,7 @@
<h3>Domains</h3>
<p>
For convenience, the API is divided into domains. Each domain is specified
in a separate section below. The specifications of the APIs refer to data
in a separate section below. The specifications of the API's refer to data
structures beyond the standard JSON primitives. These data structures are
documented in the section titled <a href="#types">Types</a>.
</p>
@ -272,7 +272,7 @@
<domains></domains>
<domain name="server">
<p>
The server domain contains APIs related to the execution of
The server domain contains API's related to the execution of
the server.
</p>
<request method="getVersion">
@ -441,7 +441,7 @@
</domain>
<domain name="analysis">
<p>
The analysis domain contains APIs related to the analysis of
The analysis domain contains API's related to the analysis of
files.
</p>
<request method="getErrors">
@ -843,7 +843,7 @@
file. If none is found, then the parents of the directory
will be searched until such a file is found or the root of
the file system is reached. If such a file is found, it will
be used to resolve package: URIs within the file.
be used to resolve package: URI's within the file.
</p>
<params>
<field name="included">
@ -3340,7 +3340,7 @@
</domain>
<domain name="flutter">
<p>
The analysis domain contains APIs related to Flutter support.
The analysis domain contains API's related to Flutter support.
</p>
<request method="getWidgetDescription" experimental="true">
<p>
@ -3517,7 +3517,7 @@
<h2 class="domain"><a name="types">Types</a></h2>
<p>
This section contains descriptions of the data types referenced
in the APIs of the various domains.
in the API's of the various domains.
</p>
<include path="../../../analyzer_plugin/tool/spec/common_types_spec.html"
import="package:analyzer_plugin/protocol/protocol_common.dart"></include>

View file

@ -419,7 +419,7 @@ class ToHtmlVisitor extends HierarchicalApiVisitor
}
for (var node in html.nodes) {
if (node is dom.Element) {
var localName = node.localName!;
var localName = node.name;
if (squashParagraphs && localName == 'p') {
translateHtml(node, squashParagraphs: squashParagraphs);
continue;
@ -609,7 +609,7 @@ class ToHtmlVisitor extends HierarchicalApiVisitor
void visitTypeEnumValue(TypeEnumValue typeEnumValue) {
var isDocumented = false;
for (var node in typeEnumValue.html.nodes) {
if ((node is dom.Element && node.localName != 'code') ||
if ((node is dom.Element && node.name != 'code') ||
(node is dom.Text && node.text.trim().isNotEmpty)) {
isDocumented = true;
break;

View file

@ -1241,8 +1241,8 @@ class Element implements HasToJson {
/// A bit-map containing the following flags:
///
/// - 0x01 - set if the element is explicitly or implicitly abstract
/// - 0x02 - set if the element was declared to be const
/// - 0x04 - set if the element was declared to be final
/// - 0x02 - set if the element was declared to be 'const'
/// - 0x04 - set if the element was declared to be 'final'
/// - 0x08 - set if the element is a static member of a class or is a
/// top-level function or field
/// - 0x10 - set if the element is private

View file

@ -125,7 +125,7 @@ a:focus, a:hover {
</p>
<h2 class="domain"><a name="domain_plugin">plugin domain</a></h2>
<p>
The plugin domain contains APIs related to the execution of a plugin.
The plugin domain contains API's related to the execution of a plugin.
</p>
<p>
TODO: Provide notifications by which plugins can report instrumentation
@ -265,7 +265,7 @@ a:focus, a:hover {
</dd></dl></dd></dl>
<h2 class="domain"><a name="domain_analysis">analysis domain</a></h2>
<p>
The analysis domain contains APIs related to the analysis of files.
The analysis domain contains API's related to the analysis of files.
</p>
@ -829,7 +829,7 @@ a:focus, a:hover {
<h2 class="domain"><a name="types">Types</a></h2>
<p>
This section contains descriptions of the data types referenced in the APIs
This section contains descriptions of the data types referenced in the API's
of the various domains.
</p>
@ -1308,10 +1308,10 @@ a:focus, a:hover {
0x01 - set if the element is explicitly or implicitly abstract
</li>
<li>
0x02 - set if the element was declared to be const
0x02 - set if the element was declared to be 'const'
</li>
<li>
0x04 - set if the element was declared to be final
0x04 - set if the element was declared to be 'final'
</li>
<li>
0x08 - set if the element is a static member of a class or is a

View file

@ -1241,8 +1241,8 @@ class Element implements HasToJson {
/// A bit-map containing the following flags:
///
/// - 0x01 - set if the element is explicitly or implicitly abstract
/// - 0x02 - set if the element was declared to be const
/// - 0x04 - set if the element was declared to be final
/// - 0x02 - set if the element was declared to be 'const'
/// - 0x04 - set if the element was declared to be 'final'
/// - 0x08 - set if the element is a static member of a class or is a
/// top-level function or field
/// - 0x10 - set if the element is private

View file

@ -538,10 +538,10 @@
0x01 - set if the element is explicitly or implicitly abstract
</li>
<li>
0x02 - set if the element was declared to be const
0x02 - set if the element was declared to be 'const'
</li>
<li>
0x04 - set if the element was declared to be final
0x04 - set if the element was declared to be 'final'
</li>
<li>
0x08 - set if the element is a static member of a class or is a

View file

@ -111,24 +111,24 @@ class ApiReader {
if (!requiredAttributes.contains(name) &&
!optionalAttributes.contains(name)) {
throw Exception(
'$context: Unexpected attribute in ${element.localName}: $name');
'$context: Unexpected attribute in ${element.name}: $name');
}
attributesFound.add(name);
});
for (var expectedAttribute in requiredAttributes) {
if (!attributesFound.contains(expectedAttribute)) {
throw Exception(
'$context: ${element.localName} must contain attribute $expectedAttribute');
'$context: ${element.name} must contain attribute $expectedAttribute');
}
}
}
/// Check that the given [element] has the given [expectedName].
void checkName(dom.Element element, String expectedName, [String? context]) {
if (element.localName != expectedName) {
context ??= element.localName;
if (element.name != expectedName) {
context ??= element.name;
throw Exception(
'$context: Expected $expectedName, found ${element.localName}');
'$context: Expected $expectedName, found ${element.name}');
}
}
@ -164,13 +164,12 @@ class ApiReader {
dom.Element getAncestor(dom.Element html, String name, String context) {
var ancestor = html.parent;
while (ancestor != null) {
if (ancestor.localName == name) {
if (ancestor.name == name) {
return ancestor;
}
ancestor = ancestor.parent;
}
throw Exception(
'$context: <${html.localName}> must be nested within <$name>');
throw Exception('$context: <${html.name}> must be nested within <$name>');
}
/// Create a [Notification] object from an HTML representation such as:
@ -295,7 +294,7 @@ class ApiReader {
var htmlContents = file.readAsStringSync();
var document = dom.parse(htmlContents, file.uri);
var htmlElement = document.children
.singleWhere((element) => element.localName?.toLowerCase() == 'html');
.singleWhere((element) => element.name.toLowerCase() == 'html');
return apiFromHtml(htmlElement);
}
@ -308,10 +307,10 @@ class ApiReader {
}
for (var node in parent.nodes) {
if (node is dom.Element) {
if (elementProcessors.containsKey(node.localName)) {
elementProcessors[node.localName]!(node);
} else if (specialElements.contains(node.localName)) {
throw Exception('$context: Unexpected use of <${node.localName}>');
if (elementProcessors.containsKey(node.name)) {
elementProcessors[node.name]!(node);
} else if (specialElements.contains(node.name)) {
throw Exception('$context: Unexpected use of <${node.name}>');
} else {
recurse(node, context, elementProcessors);
}

View file

@ -22,7 +22,7 @@
</p>
<domain name="plugin">
<p>
The plugin domain contains APIs related to the execution of a plugin.
The plugin domain contains API's related to the execution of a plugin.
</p>
<p>
TODO: Provide notifications by which plugins can report instrumentation
@ -147,7 +147,7 @@
</domain>
<domain name="analysis">
<p>
The analysis domain contains APIs related to the analysis of files.
The analysis domain contains API's related to the analysis of files.
</p>
<request method="getNavigation">
<p>
@ -874,7 +874,7 @@
<types>
<h2 class="domain"><a name="types">Types</a></h2>
<p>
This section contains descriptions of the data types referenced in the APIs
This section contains descriptions of the data types referenced in the API's
of the various domains.
</p>
<include path="common_types_spec.html"

View file

@ -422,11 +422,11 @@ class ToHtmlVisitor extends HierarchicalApiVisitor
}
for (var node in html.nodes) {
if (node is dom.Element) {
if (squashParagraphs && node.localName == 'p') {
if (squashParagraphs && node.name == 'p') {
translateHtml(node, squashParagraphs: squashParagraphs);
continue;
}
switch (node.localName) {
switch (node.name) {
case 'domains':
generateDomainsHeader();
break;
@ -463,8 +463,8 @@ class ToHtmlVisitor extends HierarchicalApiVisitor
generateIndex();
break;
default:
if (!ApiReader.specialElements.contains(node.localName)) {
element(node.localName!, node.attributes, () {
if (!ApiReader.specialElements.contains(node.name)) {
element(node.name, node.attributes, () {
translateHtml(node, squashParagraphs: squashParagraphs);
});
}
@ -608,7 +608,7 @@ class ToHtmlVisitor extends HierarchicalApiVisitor
void visitTypeEnumValue(TypeEnumValue typeEnumValue) {
var isDocumented = false;
for (var node in typeEnumValue.html?.nodes ?? []) {
if ((node is dom.Element && node.localName != 'code') ||
if ((node is dom.Element && node.name != 'code') ||
(node is dom.Text && node.text.trim().isNotEmpty)) {
isDocumented = true;
break;

View file

@ -18,7 +18,7 @@ abstract class Node {
}
class Element extends Node {
String name;
final String name;
Map<String, String> attributes = {};
@ -26,9 +26,6 @@ class Element extends Node {
Element.tag(this.name);
// This is for compatibility with the package:html DOM API.
String? get localName => name;
void append(Node child) {
child.parent = this;
nodes.add(child);

View file

@ -64,7 +64,7 @@ class _TextFormatter extends CodeGenerator {
}
}
} else if (node is dom.Element) {
switch (node.localName) {
switch (node.name) {
case 'br':
lineBreak(false);
break;
@ -83,8 +83,7 @@ class _TextFormatter extends CodeGenerator {
lineBreak(false);
if (node.classes.contains('hangingIndent')) {
resolveVerticalSpace();
// TODO(devoncarew): Remove a space here.
indentSpecial('', ' ', () {
indentSpecial('', ' ', () {
addAll(node.nodes);
lineBreak(false);
});
@ -144,7 +143,7 @@ class _TextFormatter extends CodeGenerator {
case 'head':
break;
default:
throw Exception('Unexpected HTML element: ${node.localName}');
throw Exception('Unexpected HTML element: ${node.name}');
}
} else {
throw Exception('Unexpected HTML: $node');