diff --git a/analyzer_plugin/analysis_options.yaml b/analyzer_plugin/analysis_options.yaml index 35930e6f..613e5287 100644 --- a/analyzer_plugin/analysis_options.yaml +++ b/analyzer_plugin/analysis_options.yaml @@ -12,7 +12,6 @@ linter: - always_require_non_null_named_parameters - annotate_overrides - avoid_annotating_with_dynamic - - avoid_catches_without_on_clauses - avoid_catching_errors - avoid_classes_with_only_static_members - avoid_empty_else @@ -20,7 +19,6 @@ linter: - avoid_null_checks_in_equality_operators - avoid_positional_boolean_parameters - avoid_return_types_on_setters - - avoid_returning_this - avoid_setters_without_getters - avoid_slow_async_io - avoid_types_on_closure_parameters diff --git a/analyzer_plugin/lib/ast.dart b/analyzer_plugin/lib/ast.dart index 613df9d8..4fbac7b6 100644 --- a/analyzer_plugin/lib/ast.dart +++ b/analyzer_plugin/lib/ast.dart @@ -4,6 +4,7 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/src/generated/source.dart'; import 'package:angular_analyzer_plugin/src/model.dart'; import 'package:analyzer/src/dart/element/element.dart'; +import 'package:meta/meta.dart'; enum ExpressionBoundType { input, twoWay, attr, clazz, style } @@ -341,10 +342,10 @@ class ElementInfo extends NodeInfo implements HasDirectives { this.closingSpan, this.openingNameSpan, this.closingNameSpan, - this.isTemplate, this.attributes, this.templateAttribute, - this.parent) { + this.parent, + {@required this.isTemplate}) { if (!isSynthetic) { childNodesMaxEnd = offset + length; } diff --git a/analyzer_plugin/lib/src/angular_driver.dart b/analyzer_plugin/lib/src/angular_driver.dart index 76141af5..34c15a6b 100644 --- a/analyzer_plugin/lib/src/angular_driver.dart +++ b/analyzer_plugin/lib/src/angular_driver.dart @@ -11,7 +11,7 @@ import 'package:analysis_server/plugin/protocol/protocol_dart.dart' as protocol; import 'package:analysis_server/src/protocol_server.dart' as protocol; import 'package:analyzer/error/error.dart'; import 'package:analyzer/src/dart/analysis/driver.dart'; -import 'package:analyzer/src/summary/api_signature.dart'; +import 'package:front_end/src/base/api_signature.dart'; import 'package:angular_analyzer_plugin/tasks.dart'; import 'package:angular_analyzer_plugin/src/file_tracker.dart'; import 'package:angular_analyzer_plugin/src/from_file_prefixed_error.dart'; @@ -86,6 +86,8 @@ class AngularDriver // TODO analyze these files first } + List get priorityFiles => []; + /// Notify the driver that the client is going to stop using it. @override void dispose() { @@ -416,7 +418,9 @@ class AngularDriver final unit = (await dartDriver.getUnitElement(dartPath)).element; final htmlSource = _sourceFactory.forUri('file:$htmlPath'); - if (unit == null) return null; + if (unit == null) { + return null; + } final context = unit.context; final dartSource = _sourceFactory.forUri('file:$dartPath'); final htmlContent = getFileContent(htmlPath); @@ -534,7 +538,9 @@ class AngularDriver Future pushDartErrors(String path) async { final result = await resolveDart(path); - if (result == null) return; + if (result == null) { + return; + } final errors = result.errors; final lineInfo = new LineInfo.fromContent(getFileContent(path)); final serverErrors = protocol.doAnalysisError_listFromEngine( @@ -585,7 +591,9 @@ class AngularDriver final result = await getDirectives(path); final directives = result.directives; final unit = (await dartDriver.getUnitElement(path)).element; - if (unit == null) return null; + if (unit == null) { + return null; + } final context = unit.context; final source = unit.source; diff --git a/analyzer_plugin/lib/src/converter.dart b/analyzer_plugin/lib/src/converter.dart index 03cbfd1e..bc68ef59 100644 --- a/analyzer_plugin/lib/src/converter.dart +++ b/analyzer_plugin/lib/src/converter.dart @@ -15,6 +15,7 @@ import 'package:angular_analyzer_plugin/src/strings.dart'; import 'package:angular_analyzer_plugin/tasks.dart'; import 'package:html/dom.dart' as html; import 'package:html/parser.dart' as html; +import 'package:meta/meta.dart'; import 'package:source_span/source_span.dart'; html.Element firstElement(html.Node node) { @@ -52,10 +53,10 @@ class HtmlTreeConverter { closingSpan, openingNameSpan, closingNameSpan, - isTemplate, attributes, findTemplateAttribute(attributes), - parent); + parent, + isTemplate: isTemplate); for (final attribute in attributes) { attribute.parent = element; @@ -132,7 +133,7 @@ class HtmlTreeConverter { valueOffset, dartParser.findMustaches(value, valueOffset))); } - } on IgnorableHtmlInternalError { + } on IgnorableHtmlInternalException { // See https://github.com/dart-lang/html/issues/44, this error will // be thrown looking for nameOffset. Catch it so that analysis else // where continues. @@ -235,13 +236,14 @@ class HtmlTreeConverter { valueOffset, origName, origNameOffset, - dartParser.parseDartExpression(valueOffset, value, true), + dartParser.parseDartExpression(valueOffset, value, + detectTrailing: true), bound); } List _convertChildren(html.Element node, ElementInfo parent) { final children = []; - for (html.Node child in node.nodes) { + for (final child in node.nodes) { final childNode = convert(child, parent: parent); if (childNode != null) { children.add(childNode); @@ -285,7 +287,7 @@ class HtmlTreeConverter { AttributeSpanContainer.generateAttributeSpans(element); return container.attributeSpans[name].start.offset; } catch (e) { - throw new IgnorableHtmlInternalError(e); + throw new IgnorableHtmlInternalException(e); } } } @@ -304,7 +306,7 @@ class HtmlTreeConverter { : null; } } catch (e) { - throw new IgnorableHtmlInternalError(e); + throw new IgnorableHtmlInternalException(e); } } @@ -325,7 +327,8 @@ class EmbeddedDartParser { this.templateSource, this.errorListener, this.errorReporter); /// Parse the given Dart [code] that starts at [offset]. - Expression parseDartExpression(int offset, String code, bool detectTrailing) { + Expression parseDartExpression(int offset, String code, + {@required bool detectTrailing}) { if (code == null) { return null; } @@ -471,8 +474,8 @@ class EmbeddedDartParser { } // resolve final code = text.substring(exprBegin, exprEnd); - final expression = - parseDartExpression(fileOffset + exprBegin, code, detectTrailing); + final expression = parseDartExpression(fileOffset + exprBegin, code, + detectTrailing: detectTrailing); final offset = fileOffset + begin; @@ -638,6 +641,10 @@ class EmbeddedDartParser { _tokenMatchesBuiltInIdentifier(token); } -class IgnorableHtmlInternalError extends StateError { - IgnorableHtmlInternalError(String msg) : super(msg); +class IgnorableHtmlInternalException implements Exception { + String msg; + IgnorableHtmlInternalException(this.msg); + + @override + String toString() => "IgnorableHtmlInternalException: $msg"; } diff --git a/analyzer_plugin/lib/src/directive_extraction.dart b/analyzer_plugin/lib/src/directive_extraction.dart index 1effdf75..1eb75023 100644 --- a/analyzer_plugin/lib/src/directive_extraction.dart +++ b/analyzer_plugin/lib/src/directive_extraction.dart @@ -59,12 +59,9 @@ class DirectiveExtractor extends AnnotationProcessorMixin { final isComponent = isAngularAnnotation(node, 'Component'); final isDirective = isAngularAnnotation(node, 'Directive'); if (isComponent || isDirective) { - var selector = _parseSelector(node); - if (selector == null) { - // empty selector. Don't fail to create a Component just because of a - // broken or missing selector, that results in cascading errors. - selector = new AndSelector([]); - } + // Don't fail to create a Component just because of a broken or missing + // selector, that results in cascading errors. + final selector = _parseSelector(node) ?? new AndSelector([]); final exportAs = _parseExportAs(node); final inputElements = []; final outputElements = []; diff --git a/analyzer_plugin/lib/src/directive_linking.dart b/analyzer_plugin/lib/src/directive_linking.dart index 05da6caf..c63856cf 100644 --- a/analyzer_plugin/lib/src/directive_linking.dart +++ b/analyzer_plugin/lib/src/directive_linking.dart @@ -69,7 +69,9 @@ class DirectiveLinker { // is this correct lookup? final setter = classElem.lookUpSetter(inputSum.propName, classElem.library); - if (setter == null) continue; + if (setter == null) { + continue; + } inputs.add(new InputElement( inputSum.name, inputSum.nameOffset, @@ -85,7 +87,9 @@ class DirectiveLinker { // is this correct lookup? final getter = classElem.lookUpGetter(outputSum.propName, classElem.library); - if (getter == null) continue; + if (getter == null) { + continue; + } outputs.add(new OutputElement( outputSum.name, outputSum.nameOffset, diff --git a/analyzer_plugin/lib/src/file_tracker.dart b/analyzer_plugin/lib/src/file_tracker.dart index b7a46825..d14df225 100644 --- a/analyzer_plugin/lib/src/file_tracker.dart +++ b/analyzer_plugin/lib/src/file_tracker.dart @@ -1,6 +1,6 @@ import 'dart:collection'; -import 'package:analyzer/src/summary/api_signature.dart'; +import 'package:front_end/src/base/api_signature.dart'; abstract class FileHasher { ApiSignature getContentHash(String path); @@ -33,6 +33,7 @@ class FileTracker { void setDartHtmlTemplates(String dartPath, List htmlPaths) => _dartToHtml.setFileReferencesFiles(dartPath, htmlPaths); + // ignore: avoid_positional_boolean_parameters void setDartHasTemplate(String dartPath, bool hasTemplate) { if (hasTemplate) { _dartFilesWithDartTemplates.add(dartPath); diff --git a/analyzer_plugin/lib/src/ng_expr_parser.dart b/analyzer_plugin/lib/src/ng_expr_parser.dart index 478da4b5..4ba0c780 100644 --- a/analyzer_plugin/lib/src/ng_expr_parser.dart +++ b/analyzer_plugin/lib/src/ng_expr_parser.dart @@ -23,7 +23,7 @@ class NgExprParser extends Parser { Token beforePipeToken; expression = parseBitwiseXorExpression(); while (_currentToken.type == TokenType.BAR) { - if (beforePipeToken == null) beforePipeToken = _currentToken.previous; + beforePipeToken ??= _currentToken.previous; getAndAdvance(); parsePipeExpression(); } diff --git a/analyzer_plugin/lib/src/resolver.dart b/analyzer_plugin/lib/src/resolver.dart index 19ba30dd..a7ccc645 100644 --- a/analyzer_plugin/lib/src/resolver.dart +++ b/analyzer_plugin/lib/src/resolver.dart @@ -1,6 +1,7 @@ library angular2.src.analysis.analyzer_plugin.src.resolver; import 'dart:collection'; +import 'package:meta/meta.dart'; import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/ast/visitor.dart'; @@ -198,10 +199,8 @@ class _DartReferencesRecorder extends RecursiveAstVisitor { void visitSimpleIdentifier(SimpleIdentifier node) { final dartElement = node.bestElement; if (dartElement != null) { - var angularElement = dartToAngularMap[dartElement]; - if (angularElement == null) { - angularElement = new DartElement(dartElement); - } + final angularElement = + dartToAngularMap[dartElement] ?? new DartElement(dartElement); final range = new SourceRange(node.offset, node.length); template.addRange(range, angularElement); } @@ -472,10 +471,7 @@ class PrepareScopeVisitor extends AngularScopeVisitor { offset += prefixLen; // prepare internal variable name - var internalName = attribute.value; - if (internalName == null) { - internalName = r'$implicit'; - } + final internalName = attribute.value ?? r'$implicit'; // maybe an internal variable reference DartType type; @@ -498,9 +494,7 @@ class PrepareScopeVisitor extends AngularScopeVisitor { } // any unmatched values should be dynamic to prevent secondary errors - if (type == null) { - type = typeProvider.dynamicType; - } + type ??= typeProvider.dynamicType; // add a new local variable with type final localVariableElement = @@ -553,8 +547,8 @@ class DartVariableManager { // ensure artificial Dart elements in the template source if (htmlMethodElement == null) { htmlCompilationUnitElement = - new CompilationUnitElementImpl(templateSource.fullName); - htmlCompilationUnitElement.source = templateSource; + new CompilationUnitElementImpl(templateSource.fullName) + ..source = templateSource; htmlClassElement = new ClassElementImpl('AngularTemplateClass', -1); htmlCompilationUnitElement.types = [htmlClassElement]; htmlMethodElement = new MethodElementImpl('angularTemplateMethod', -1); @@ -842,8 +836,8 @@ class ComponentContentResolver extends AngularAstVisitor { } if (!tagIsStandard) { - checkTransclusionsContentChildren( - component, element.childNodes, tagIsStandard); + checkTransclusionsContentChildren(component, element.childNodes, + tagIsStandard: tagIsStandard); } for (final child in element.childNodes) { @@ -852,7 +846,8 @@ class ComponentContentResolver extends AngularAstVisitor { } void checkTransclusionsContentChildren( - Component component, List children, bool tagIsStandard) { + Component component, List children, + {@required bool tagIsStandard}) { if (component?.ngContents == null) { return; } @@ -1346,7 +1341,8 @@ class SingleScopeResolver extends AngularScopeVisitor { astNode.accept(visitor); } final resolver = new AngularResolverVisitor( - library, templateSource, typeProvider, errorListener, acceptAssignment); + library, templateSource, typeProvider, errorListener, + acceptAssignment: acceptAssignment); // fill the name scope final classScope = new ClassScope(resolver.nameScope, classElement); final localScope = new EnclosedScope(classScope); @@ -1358,8 +1354,9 @@ class SingleScopeResolver extends AngularScopeVisitor { // do resolve astNode.accept(resolver); // verify - final verifier = new AngularErrorVerifier(errorReporter, library, - typeProvider, new InheritanceManager(library), acceptAssignment); + final verifier = new AngularErrorVerifier( + errorReporter, library, typeProvider, new InheritanceManager(library), + acceptAssignment: acceptAssignment); astNode.accept(verifier); } @@ -1431,12 +1428,9 @@ class AngularResolverVisitor extends _IntermediateResolverVisitor with ReportUnacceptableNodesMixin { final bool acceptAssignment; - AngularResolverVisitor( - LibraryElement library, - Source source, - TypeProvider typeProvider, - AnalysisErrorListener errorListener, - this.acceptAssignment) + AngularResolverVisitor(LibraryElement library, Source source, + TypeProvider typeProvider, AnalysisErrorListener errorListener, + {@required this.acceptAssignment}) : super(library, source, typeProvider, errorListener); @override @@ -1514,12 +1508,9 @@ class AngularErrorVerifier extends ErrorVerifier @override TypeProvider typeProvider; - AngularErrorVerifier( - ErrorReporter errorReporter, - LibraryElement library, - TypeProvider typeProvider, - InheritanceManager inheritanceManager, - this.acceptAssignment) + AngularErrorVerifier(ErrorReporter errorReporter, LibraryElement library, + TypeProvider typeProvider, InheritanceManager inheritanceManager, + {@required this.acceptAssignment}) : errorReporter = errorReporter, typeProvider = typeProvider, super(errorReporter, library, typeProvider, inheritanceManager, false); diff --git a/analyzer_plugin/lib/src/selector.dart b/analyzer_plugin/lib/src/selector.dart index a34d134c..28e09f46 100644 --- a/analyzer_plugin/lib/src/selector.dart +++ b/analyzer_plugin/lib/src/selector.dart @@ -5,6 +5,7 @@ import 'dart:collection'; import 'package:analyzer/src/generated/source.dart'; import 'package:angular_analyzer_plugin/src/model.dart'; import 'package:angular_analyzer_plugin/src/strings.dart'; +import 'package:meta/meta.dart'; enum SelectorMatch { NoMatch, NonTagMatch, TagMatch } @@ -63,7 +64,7 @@ class AttributeSelector extends Selector { final bool isWildcard; final String value; - AttributeSelector(this.nameElement, this.value, this.isWildcard); + AttributeSelector(this.nameElement, this.value, {@required this.isWildcard}); @override SelectorMatch match(ElementView element, Template template) { @@ -447,6 +448,7 @@ class HtmlTagForSelector { ? true : _classes.length == 1 && _classes.first == _attributes["class"]; + String get name => _name; set name(String name) { if (_name != null && _name != name) { _isValid = false; @@ -473,15 +475,11 @@ class HtmlTagForSelector { _classes.add(classname); } - HtmlTagForSelector clone() { - final copy = new HtmlTagForSelector(); - copy - ..name = _name - .._attributes = ({}..addAll(_attributes)) - .._isValid = _isValid - .._classes = new HashSet.from(_classes); - return copy; - } + HtmlTagForSelector clone() => new HtmlTagForSelector() + ..name = _name + .._attributes = ({}..addAll(_attributes)) + .._isValid = _isValid + .._classes = new HashSet.from(_classes); @override String toString() { @@ -629,9 +627,8 @@ class SelectorParser { } selectors.add(new AttributeSelector( - new SelectorName(name, nameOffset, name.length, source), - value, - isWildcard)); + new SelectorName(name, nameOffset, name.length, source), value, + isWildcard: isWildcard)); } else if (currentMatchType == _SelectorRegexMatch.Comma) { advance(); final rhs = parseNested(); diff --git a/analyzer_plugin/lib/src/standard_components.dart b/analyzer_plugin/lib/src/standard_components.dart index 238f6f7b..a0abb30c 100644 --- a/analyzer_plugin/lib/src/standard_components.dart +++ b/analyzer_plugin/lib/src/standard_components.dart @@ -122,8 +122,7 @@ class BuildStandardHtmlComponentsVisitor extends RecursiveAstVisitor { } List _buildInputs(bool skipHtmlElement) => - _captureAspects((Map inputMap, - PropertyAccessorElement accessor) { + _captureAspects((inputMap, accessor) { final name = accessor.displayName; if (!inputMap.containsKey(name)) { if (accessor.isSetter) { @@ -140,8 +139,7 @@ class BuildStandardHtmlComponentsVisitor extends RecursiveAstVisitor { }, skipHtmlElement); // Either grabbing HtmlElement attrs or skipping them List _buildOutputs(bool skipHtmlElement) => - _captureAspects((Map outputMap, - PropertyAccessorElement accessor) { + _captureAspects((outputMap, accessor) { final domName = _getDomName(accessor); if (domName == null) { return; diff --git a/analyzer_plugin/lib/src/summary/format.dart b/analyzer_plugin/lib/src/summary/format.dart index fef0b1ff..47ae931a 100644 --- a/analyzer_plugin/lib/src/summary/format.dart +++ b/analyzer_plugin/lib/src/summary/format.dart @@ -5,10 +5,10 @@ // This file has been automatically generated. Please do not edit it manually. // To regenerate the file, use the script "pkg/analyzer/tool/generate_files". -import 'package:analyzer/src/summary/flat_buffers.dart' as fb; +import 'package:front_end/src/base/flat_buffers.dart' as fb; import 'idl.dart' as idl; import 'dart:convert' as convert; -import 'package:analyzer/src/summary/api_signature.dart' as api_sig; +import 'package:front_end/src/base/api_signature.dart' as api_sig; class PackageBundleBuilder extends Object with _PackageBundleMixin diff --git a/analyzer_plugin/lib/src/view_extraction.dart b/analyzer_plugin/lib/src/view_extraction.dart index 2a674a4e..21d68bad 100644 --- a/analyzer_plugin/lib/src/view_extraction.dart +++ b/analyzer_plugin/lib/src/view_extraction.dart @@ -200,8 +200,8 @@ class TemplateParser { content = ' ' * offset + content; } final parser = new AngularHtmlParser(content, - generateSpans: true, lowercaseAttrName: false); - parser.compatMode = 'quirks'; + generateSpans: true, lowercaseAttrName: false) + ..compatMode = 'quirks'; document = parser.parse(); final htmlErrors = parser.errors; @@ -214,9 +214,12 @@ class TemplateParser { } final span = parseError.span; + // html parser lib isn't nice enough to send this error all the time // see github #47 for dart-lang/html - if (span == null) continue; + if (span == null) { + continue; + } parseErrors.add(new AnalysisError(source, span.start.offset, span.length, HtmlErrorCode.PARSE_ERROR, [parseError.errorCode])); diff --git a/analyzer_plugin/lib/starter.dart b/analyzer_plugin/lib/starter.dart index 8040979d..757a2789 100644 --- a/analyzer_plugin/lib/starter.dart +++ b/analyzer_plugin/lib/starter.dart @@ -40,7 +40,7 @@ class Starter { final driver = new AngularDriver(server, analysisDriver, scheduler, byteStore, sourceFactory, contentOverlay); angularDrivers[driverPath] = driver; - server.onFileAdded.listen((String path) { + server.onFileAdded.listen((path) { if (server.contextManager.getContextFolderFor(path).path == driverPath) { // only the owning driver "adds" the path driver.addFile(path); diff --git a/analyzer_plugin/test/abstract_angular.dart b/analyzer_plugin/test/abstract_angular.dart index b538c8dd..15595f57 100644 --- a/analyzer_plugin/test/abstract_angular.dart +++ b/analyzer_plugin/test/abstract_angular.dart @@ -327,7 +327,7 @@ class NgFor { ErrorCode errCode, String code, String snippet) { final snippetIndex = code.indexOf(snippet); expect(snippetIndex, greaterThan(-1), - reason: 'Error in test: snippet ${snippet} not part of code ${code}'); + reason: 'Error in test: snippet $snippet not part of code $code'); errorListener.assertErrorsWithCodes([errCode]); final error = errorListener.errors.single; expect(error.offset, snippetIndex); @@ -414,7 +414,7 @@ class GatheringErrorListener implements AnalysisErrorListener { // // Compare the expected and actual number of each type of error. // - expectedCounts.forEach((ErrorCode code, int expectedCount) { + expectedCounts.forEach((code, expectedCount) { int actualCount; final list = errorsByCode.remove(code); if (list == null) { @@ -440,7 +440,7 @@ class GatheringErrorListener implements AnalysisErrorListener { // Check that there are no more errors in the actual-errors map, // otherwise record message. // - errorsByCode.forEach((ErrorCode code, List actualErrors) { + errorsByCode.forEach((code, actualErrors) { final actualCount = actualErrors.length; if (buffer.isEmpty) { buffer.write("Expected "); diff --git a/analyzer_plugin/test/angular_driver_test.dart b/analyzer_plugin/test/angular_driver_test.dart index 009d5c83..3dc4e449 100644 --- a/analyzer_plugin/test/angular_driver_test.dart +++ b/analyzer_plugin/test/angular_driver_test.dart @@ -279,31 +279,31 @@ class ComponentB { expect(directives, hasLength(2)); { final component = directives[0]; - expect(component, new isInstanceOf()); + expect(component, const isInstanceOf()); { final selector = component.selector; - expect(selector, new isInstanceOf()); + expect(selector, const isInstanceOf()); expect(selector.toString(), 'comp-a'); } { expect(component.elementTags, hasLength(1)); final selector = component.elementTags[0]; - expect(selector, new isInstanceOf()); + expect(selector, const isInstanceOf()); expect(selector.toString(), 'comp-a'); } } { final component = directives[1]; - expect(component, new isInstanceOf()); + expect(component, const isInstanceOf()); { final selector = component.selector; - expect(selector, new isInstanceOf()); + expect(selector, const isInstanceOf()); expect(selector.toString(), 'comp-b'); } { expect(component.elementTags, hasLength(1)); final selector = component.elementTags[0]; - expect(selector, new isInstanceOf()); + expect(selector, const isInstanceOf()); expect(selector.toString(), 'comp-b'); } } @@ -328,31 +328,31 @@ class DirectiveB { expect(directives, hasLength(2)); { final directive = directives[0]; - expect(directive, new isInstanceOf()); + expect(directive, const isInstanceOf()); { final selector = directive.selector; - expect(selector, new isInstanceOf()); + expect(selector, const isInstanceOf()); expect(selector.toString(), 'dir-a'); } { expect(directive.elementTags, hasLength(1)); final selector = directive.elementTags[0]; - expect(selector, new isInstanceOf()); + expect(selector, const isInstanceOf()); expect(selector.toString(), 'dir-a'); } } { final directive = directives[1]; - expect(directive, new isInstanceOf()); + expect(directive, const isInstanceOf()); { final selector = directive.selector; - expect(selector, new isInstanceOf()); + expect(selector, const isInstanceOf()); expect(selector.toString(), 'dir-b'); } { expect(directive.elementTags, hasLength(1)); final selector = directive.elementTags[0]; - expect(selector, new isInstanceOf()); + expect(selector, const isInstanceOf()); expect(selector.toString(), 'dir-b'); } } @@ -377,40 +377,40 @@ class DirectiveB { expect(directives, hasLength(2)); { final directive = directives[0]; - expect(directive, new isInstanceOf()); + expect(directive, const isInstanceOf()); { final selector = directive.selector; - expect(selector, new isInstanceOf()); + expect(selector, const isInstanceOf()); expect((selector as OrSelector).selectors, hasLength(3)); } { expect(directive.elementTags, hasLength(3)); - expect( - directive.elementTags[0], new isInstanceOf()); + expect(directive.elementTags[0], + const isInstanceOf()); expect(directive.elementTags[0].toString(), 'dir-a1'); - expect( - directive.elementTags[1], new isInstanceOf()); + expect(directive.elementTags[1], + const isInstanceOf()); expect(directive.elementTags[1].toString(), 'dir-a2'); - expect( - directive.elementTags[2], new isInstanceOf()); + expect(directive.elementTags[2], + const isInstanceOf()); expect(directive.elementTags[2].toString(), 'dir-a3'); } } { final directive = directives[1]; - expect(directive, new isInstanceOf()); + expect(directive, const isInstanceOf()); { final selector = directive.selector; - expect(selector, new isInstanceOf()); + expect(selector, const isInstanceOf()); expect((selector as OrSelector).selectors, hasLength(2)); } { expect(directive.elementTags, hasLength(2)); - expect( - directive.elementTags[0], new isInstanceOf()); + expect(directive.elementTags[0], + const isInstanceOf()); expect(directive.elementTags[0].toString(), 'dir-b1'); - expect( - directive.elementTags[1], new isInstanceOf()); + expect(directive.elementTags[1], + const isInstanceOf()); expect(directive.elementTags[1].toString(), 'dir-b2'); } } @@ -435,31 +435,31 @@ class DirectiveB { expect(directives, hasLength(2)); { final directive = directives[0]; - expect(directive, new isInstanceOf()); + expect(directive, const isInstanceOf()); { final selector = directive.selector; - expect(selector, new isInstanceOf()); + expect(selector, const isInstanceOf()); expect((selector as AndSelector).selectors, hasLength(3)); } { expect(directive.elementTags, hasLength(1)); - expect( - directive.elementTags[0], new isInstanceOf()); + expect(directive.elementTags[0], + const isInstanceOf()); expect(directive.elementTags[0].toString(), 'dir-a'); } } { final directive = directives[1]; - expect(directive, new isInstanceOf()); + expect(directive, const isInstanceOf()); { final selector = directive.selector; - expect(selector, new isInstanceOf()); + expect(selector, const isInstanceOf()); expect((selector as AndSelector).selectors, hasLength(2)); } { expect(directive.elementTags, hasLength(1)); - expect( - directive.elementTags[0], new isInstanceOf()); + expect(directive.elementTags[0], + const isInstanceOf()); expect(directive.elementTags[0].toString(), 'dir-b'); } } @@ -484,37 +484,37 @@ class DirectiveB { expect(directives, hasLength(2)); { final directive = directives[0]; - expect(directive, new isInstanceOf()); + expect(directive, const isInstanceOf()); { final selector = directive.selector; - expect(selector, new isInstanceOf()); + expect(selector, const isInstanceOf()); expect((selector as OrSelector).selectors, hasLength(2)); } { expect(directive.elementTags, hasLength(2)); - expect( - directive.elementTags[0], new isInstanceOf()); + expect(directive.elementTags[0], + const isInstanceOf()); expect(directive.elementTags[0].toString(), 'dir-a1'); - expect( - directive.elementTags[1], new isInstanceOf()); + expect(directive.elementTags[1], + const isInstanceOf()); expect(directive.elementTags[1].toString(), 'dir-a2'); } } { final directive = directives[1]; - expect(directive, new isInstanceOf()); + expect(directive, const isInstanceOf()); { final selector = directive.selector; - expect(selector, new isInstanceOf()); + expect(selector, const isInstanceOf()); expect((selector as OrSelector).selectors, hasLength(2)); } { expect(directive.elementTags, hasLength(2)); - expect( - directive.elementTags[0], new isInstanceOf()); + expect(directive.elementTags[0], + const isInstanceOf()); expect(directive.elementTags[0].toString(), 'dir-b1'); - expect( - directive.elementTags[1], new isInstanceOf()); + expect(directive.elementTags[1], + const isInstanceOf()); expect(directive.elementTags[1].toString(), 'dir-b2'); } } @@ -1948,7 +1948,7 @@ class ContentChildComp {} final component = directives.first; final childs = component.contentChilds; expect(childs, hasLength(1)); - expect(childs.first.query, new isInstanceOf()); + expect(childs.first.query, const isInstanceOf()); final DirectiveQueriedChildType child = childs.first.query; expect(child.directive, equals(directives[1])); @@ -1976,7 +1976,7 @@ class ContentChildComp {} final childrens = component.contentChildren; expect(childrens, hasLength(1)); expect( - childrens.first.query, new isInstanceOf()); + childrens.first.query, const isInstanceOf()); final DirectiveQueriedChildType children = childrens.first.query; expect(children.directive, equals(directives[1])); @@ -2007,14 +2007,14 @@ class ContentChildComp {} final childrens = component.contentChildren; expect(childrens, hasLength(1)); expect( - childrens.first.query, new isInstanceOf()); + childrens.first.query, const isInstanceOf()); final DirectiveQueriedChildType children = childrens.first.query; expect(children.directive, equals(directives[1])); final childs = component.contentChilds; expect(childs, hasLength(1)); - expect(childs.first.query, new isInstanceOf()); + expect(childs.first.query, const isInstanceOf()); final DirectiveQueriedChildType child = childs.first.query; expect(child.directive, equals(directives[1])); @@ -2051,27 +2051,27 @@ class ContentChildComp {} final LetBoundQueriedChildType childDirective = childs .singleWhere((c) => c.field.fieldName == "contentChildDirective") .query; - expect(childDirective, new isInstanceOf()); + expect(childDirective, const isInstanceOf()); expect(childDirective.letBoundName, equals("foo")); expect(childDirective.containerType.toString(), equals("ContentChildComp")); final LetBoundQueriedChildType childTemplate = childs.singleWhere((c) => c.field.fieldName == "contentChildTpl").query; - expect(childTemplate, new isInstanceOf()); + expect(childTemplate, const isInstanceOf()); expect(childTemplate.letBoundName, equals("fooTpl")); expect(childTemplate.containerType.toString(), equals("TemplateRef")); final LetBoundQueriedChildType childElement = childs .singleWhere((c) => c.field.fieldName == "contentChildElem") .query; - expect(childElement, new isInstanceOf()); + expect(childElement, const isInstanceOf()); expect(childElement.letBoundName, equals("fooElem")); expect(childElement.containerType.toString(), equals("ElementRef")); final LetBoundQueriedChildType childDynamic = childs .singleWhere((c) => c.field.fieldName == "contentChildDynamic") .query; - expect(childDynamic, new isInstanceOf()); + expect(childDynamic, const isInstanceOf()); expect(childDynamic.letBoundName, equals("fooDynamic")); expect(childDynamic.containerType.toString(), equals("dynamic")); @@ -2108,7 +2108,7 @@ class ContentChildComp {} final LetBoundQueriedChildType childrenDirective = childrens .singleWhere((c) => c.field.fieldName == "contentChildDirective") .query; - expect(childrenDirective, new isInstanceOf()); + expect(childrenDirective, const isInstanceOf()); expect(childrenDirective.letBoundName, equals("foo")); expect( childrenDirective.containerType.toString(), equals("ContentChildComp")); @@ -2116,21 +2116,21 @@ class ContentChildComp {} final LetBoundQueriedChildType childrenTemplate = childrens .singleWhere((c) => c.field.fieldName == "contentChildTpl") .query; - expect(childrenTemplate, new isInstanceOf()); + expect(childrenTemplate, const isInstanceOf()); expect(childrenTemplate.letBoundName, equals("fooTpl")); expect(childrenTemplate.containerType.toString(), equals("TemplateRef")); final LetBoundQueriedChildType childrenElement = childrens .singleWhere((c) => c.field.fieldName == "contentChildElem") .query; - expect(childrenElement, new isInstanceOf()); + expect(childrenElement, const isInstanceOf()); expect(childrenElement.letBoundName, equals("fooElem")); expect(childrenElement.containerType.toString(), equals("ElementRef")); final LetBoundQueriedChildType childrenDynamic = childrens .singleWhere((c) => c.field.fieldName == "contentChildDynamic") .query; - expect(childrenDynamic, new isInstanceOf()); + expect(childrenDynamic, const isInstanceOf()); expect(childrenDynamic.letBoundName, equals("fooDynamic")); expect(childrenDynamic.containerType.toString(), equals("dynamic")); @@ -2157,7 +2157,8 @@ class ContentChildComp {} final component = directives.first; final childs = component.contentChilds; expect(childs, hasLength(1)); - expect(childs.first.query, new isInstanceOf()); + expect( + childs.first.query, const isInstanceOf()); // validate errorListener.assertNoErrors(); @@ -2179,8 +2180,8 @@ class ComponentA { final component = directives.first; final childrens = component.contentChildren; expect(childrens, hasLength(1)); - expect( - childrens.first.query, new isInstanceOf()); + expect(childrens.first.query, + const isInstanceOf()); // validate errorListener.assertNoErrors(); @@ -2202,8 +2203,8 @@ class ComponentA { final component = directives.first; final childrens = component.contentChildren; expect(childrens, hasLength(1)); - expect( - childrens.first.query, new isInstanceOf()); + expect(childrens.first.query, + const isInstanceOf()); // validate errorListener.assertNoErrors(); @@ -2228,7 +2229,8 @@ class ContentChildComp {} final component = directives.first; final childs = component.contentChilds; expect(childs, hasLength(1)); - expect(childs.first.query, new isInstanceOf()); + expect( + childs.first.query, const isInstanceOf()); // validate errorListener.assertNoErrors(); @@ -2320,7 +2322,7 @@ class ContentChildComp {} final component = directives.first; final childs = component.contentChilds; expect(childs, hasLength(1)); - expect(childs.first.query, new isInstanceOf()); + expect(childs.first.query, const isInstanceOf()); final DirectiveQueriedChildType child = childs.first.query; expect(child.directive, equals(directives[1])); @@ -2348,7 +2350,7 @@ class ContentChildComp {} final component = directives.first; final childs = component.contentChilds; expect(childs, hasLength(1)); - expect(childs.first.query, new isInstanceOf()); + expect(childs.first.query, const isInstanceOf()); final DirectiveQueriedChildType child = childs.first.query; expect(child.directive, equals(directives[1])); @@ -2377,7 +2379,7 @@ class ContentChildCompSub extends ContentChildComp {} final component = directives.first; final childs = component.contentChilds; expect(childs, hasLength(1)); - expect(childs.first.query, new isInstanceOf()); + expect(childs.first.query, const isInstanceOf()); final DirectiveQueriedChildType child = childs.first.query; expect(child.directive, equals(directives[1])); @@ -2406,7 +2408,7 @@ class ContentChildComp {} final childrens = component.contentChildren; expect(childrens, hasLength(1)); expect( - childrens.first.query, new isInstanceOf()); + childrens.first.query, const isInstanceOf()); final DirectiveQueriedChildType children = childrens.first.query; expect(children.directive, equals(directives[1])); @@ -2437,7 +2439,7 @@ class ContentChildComp {} final childrens = component.contentChildren; expect(childrens, hasLength(1)); expect( - childrens.first.query, new isInstanceOf()); + childrens.first.query, const isInstanceOf()); final DirectiveQueriedChildType children = childrens.first.query; expect(children.directive, equals(directives[1])); @@ -2487,7 +2489,7 @@ class ContentChildComp {} final childrens = component.contentChildren; expect(childrens, hasLength(1)); expect( - childrens.first.query, new isInstanceOf()); + childrens.first.query, const isInstanceOf()); final DirectiveQueriedChildType children = childrens.first.query; expect(children.directive, equals(directives[1])); @@ -2515,7 +2517,7 @@ class ContentChildComp {} final childrens = component.contentChildren; expect(childrens, hasLength(1)); expect( - childrens.first.query, new isInstanceOf()); + childrens.first.query, const isInstanceOf()); final DirectiveQueriedChildType children = childrens.first.query; expect(children.directive, equals(directives[1])); @@ -2565,7 +2567,7 @@ class ContentChildComp {} final childrens = component.contentChildren; expect(childrens, hasLength(1)); expect( - childrens.first.query, new isInstanceOf()); + childrens.first.query, const isInstanceOf()); final DirectiveQueriedChildType children = childrens.first.query; expect(children.directive, equals(directives[1])); @@ -2596,7 +2598,7 @@ abstract class CannotSubtypeQueryList extends QueryList {} final childrens = component.contentChildren; expect(childrens, hasLength(1)); expect( - childrens.first.query, new isInstanceOf()); + childrens.first.query, const isInstanceOf()); final DirectiveQueriedChildType children = childrens.first.query; expect(children.directive, equals(directives[1])); @@ -2966,7 +2968,7 @@ class TodoList { getResolvedRangeAtString(code, ranges, r'gotClicked($'); expect(resolvedRange.range.length, 'gotClicked'.length); final element = (resolvedRange.element as DartElement).element; - expect(element, new isInstanceOf()); + expect(element, const isInstanceOf()); expect(element.name, 'gotClicked'); expect( element.nameOffset, code.indexOf('gotClicked(MouseEvent event)')); @@ -2976,7 +2978,7 @@ class TodoList { getResolvedRangeAtString(code, ranges, r"$event)'>"); expect(resolvedRange.range.length, r'$event'.length); final element = (resolvedRange.element as LocalVariable).dartVariable; - expect(element, new isInstanceOf()); + expect(element, const isInstanceOf()); expect(element.name, r'$event'); expect(element.nameOffset, -1); } @@ -3031,7 +3033,7 @@ class User { final resolvedRange = getResolvedRangeAtString(code, ranges, 'user.'); expect(resolvedRange.range.length, 'user'.length); final element = (resolvedRange.element as DartElement).element; - expect(element, new isInstanceOf()); + expect(element, const isInstanceOf()); expect(element.name, 'user'); expect(element.nameOffset, code.indexOf('user; // 1')); } @@ -3039,7 +3041,7 @@ class User { final resolvedRange = getResolvedRangeAtString(code, ranges, "name'>"); expect(resolvedRange.range.length, 'name'.length); final element = (resolvedRange.element as DartElement).element; - expect(element, new isInstanceOf()); + expect(element, const isInstanceOf()); expect(element.name, 'name'); expect(element.nameOffset, code.indexOf('name; // 2')); } @@ -3485,7 +3487,7 @@ class ComponentA { await getDirectives(htmlSource, dartSource); final errors = errorListener.errors; expect(errors, hasLength(1)); - expect(errors.first, new isInstanceOf()); + expect(errors.first, const isInstanceOf()); expect(errors.first.message, equals('Unresolved tag "unresolved-tag" (from /weird.dart)')); } diff --git a/analyzer_plugin/test/element_assert.dart b/analyzer_plugin/test/element_assert.dart index 46133675..5a7347f3 100644 --- a/analyzer_plugin/test/element_assert.dart +++ b/analyzer_plugin/test/element_assert.dart @@ -137,9 +137,7 @@ class _AbstractElementAssert { _AbstractElementAssert([this._source, this._code]); void _at(int actualOffset, String search) { - if (_code == null) { - _code = _source.contents.data; - } + _code ??= _source.contents.data; final offset = _code.indexOf(search); expect(offset, isNonNegative, reason: "|$search| in |$_code|"); expect(actualOffset, offset); diff --git a/analyzer_plugin/test/file_tracker_test.dart b/analyzer_plugin/test/file_tracker_test.dart index 8abefecf..a5e4868b 100644 --- a/analyzer_plugin/test/file_tracker_test.dart +++ b/analyzer_plugin/test/file_tracker_test.dart @@ -1,5 +1,5 @@ import 'package:angular_analyzer_plugin/src/file_tracker.dart'; -import 'package:analyzer/src/summary/api_signature.dart'; +import 'package:front_end/src/base/api_signature.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; import 'package:unittest/unittest.dart'; import 'package:typed_mock/typed_mock.dart'; diff --git a/analyzer_plugin/test/fuzz_test.dart b/analyzer_plugin/test/fuzz_test.dart index 0f9a9481..7e659bdd 100644 --- a/analyzer_plugin/test/fuzz_test.dart +++ b/analyzer_plugin/test/fuzz_test.dart @@ -1,5 +1,5 @@ -import 'dart:math'; import 'dart:async'; +import 'dart:math'; import 'package:angular_analyzer_plugin/src/model.dart'; import 'package:front_end/src/scanner/token.dart'; @@ -640,7 +640,9 @@ class CounterComponent { if (mismatchDescription.length > 0) { description.add(' Which: $mismatchDescription\n'); } - if (reason != null) description.add(reason).add('\n'); + if (reason != null) { + description.add(reason).add('\n'); + } print(description.toString()); return new Future.error(description); diff --git a/analyzer_plugin/test/mock_sdk.dart b/analyzer_plugin/test/mock_sdk.dart index 8ef1c922..15364842 100644 --- a/analyzer_plugin/test/mock_sdk.dart +++ b/analyzer_plugin/test/mock_sdk.dart @@ -1,5 +1,3 @@ -library test.src.mock_sdk; - import 'package:analyzer/file_system/file_system.dart' as resource; import 'package:analyzer/file_system/memory_file_system.dart' as resource; import 'package:analyzer/src/context/cache.dart'; @@ -522,7 +520,7 @@ class MockSdk implements DartSdk { uriMap = dartAsync ? FULL_URI_MAP : NO_ASYNC_URI_MAP { for (_MockSdkLibrary library in sdkLibraries) { provider.newFile(provider.convertPath(library.path), library.content); - library.parts.forEach((String path, String content) { + library.parts.forEach((path, content) { provider.newFile(provider.convertPath(path), content); }); } @@ -555,7 +553,7 @@ class MockSdk implements DartSdk { @override List get uris => - sdkLibraries.map((SdkLibrary library) => library.shortName).toList(); + sdkLibraries.map((library) => library.shortName).toList(); @override Source fromFileUri(Uri uri) { @@ -646,9 +644,8 @@ class MockSdk implements DartSdk { /// Compute the bytes of the linked bundle associated with this SDK. List _computeLinkedBundleBytes() { - final librarySources = sdkLibraries - .map((SdkLibrary library) => mapDartUri(library.shortName)) - .toList(); + final librarySources = + sdkLibraries.map((library) => mapDartUri(library.shortName)).toList(); return new SummaryBuilder( librarySources, context, context.analysisOptions.strongMode) .build(); diff --git a/analyzer_plugin/test/resolver_test.dart b/analyzer_plugin/test/resolver_test.dart index 091f163f..b1613016 100644 --- a/analyzer_plugin/test/resolver_test.dart +++ b/analyzer_plugin/test/resolver_test.dart @@ -4175,26 +4175,23 @@ $code resolvedRange.element, resolvedRange.range.offset); } - ElementAssert _assertInputElement(String atString) { - return _assertElement(atString, _isInputElement); - } + ElementAssert _assertInputElement(String atString) => + _assertElement(atString, _isInputElement); - ElementAssert _assertSelectorElement(String atString) { - return _assertElement(atString, _isSelectorName); - } + ElementAssert _assertSelectorElement(String atString) => + _assertElement(atString, _isSelectorName); /// Return the [ResolvedRange] that starts at the position of the give /// [search] and, if specified satisfies the given [condition]. ResolvedRange _findResolvedRange(String search, - [ResolvedRangeCondition condition]) { - return getResolvedRangeAtString(htmlCode, ranges, search, condition); - } + [ResolvedRangeCondition condition]) => + getResolvedRangeAtString(htmlCode, ranges, search, condition); /// Compute all the views declared in the given [dartSource], and resolve the /// external template of the last one. Future _resolveSingleTemplate(Source dartSource) async { final result = await angularDriver.resolveDart(dartSource.fullName); - final finder = (AbstractDirective d) => + bool finder(AbstractDirective d) => d is Component && d.view.templateUriSource != null; fillErrorListener(result.errors); errorListener.assertNoErrors(); @@ -4208,13 +4205,11 @@ $code ranges = template.ranges; } - static bool _isInputElement(ResolvedRange region) { - return region.element is InputElement; - } + static bool _isInputElement(ResolvedRange region) => + region.element is InputElement; - static bool _isSelectorName(ResolvedRange region) { - return region.element is SelectorName; - } + static bool _isSelectorName(ResolvedRange region) => + region.element is SelectorName; } class ElementSearch extends AngularAstVisitor { diff --git a/analyzer_plugin/test/selector_test.dart b/analyzer_plugin/test/selector_test.dart index d55e85cd..8e855a71 100644 --- a/analyzer_plugin/test/selector_test.dart +++ b/analyzer_plugin/test/selector_test.dart @@ -116,14 +116,16 @@ class AttributeSelectorTest extends _SelectorTest { // ignore: non_constant_identifier_names void test_match_notName() { - final selector = new AttributeSelector(nameElement, null, false); + final selector = + new AttributeSelector(nameElement, null, isWildcard: false); when(element.attributes).thenReturn({'not-kind': 'no-matter'}); expect(selector.match(element, template), equals(SelectorMatch.NoMatch)); } // ignore: non_constant_identifier_names void test_match_notValue() { - final selector = new AttributeSelector(nameElement, 'silly', false); + final selector = + new AttributeSelector(nameElement, 'silly', isWildcard: false); when(element.attributes).thenReturn({'kind': 'strange'}); when(element.attributeNameSpans) .thenReturn({'kind': _newStringSpan(100, "kind")}); @@ -132,7 +134,8 @@ class AttributeSelectorTest extends _SelectorTest { // ignore: non_constant_identifier_names void test_match_noValue() { - final selector = new AttributeSelector(nameElement, null, false); + final selector = + new AttributeSelector(nameElement, null, isWildcard: false); when(element.attributes).thenReturn({'kind': 'no-matter'}); when(element.attributeNameSpans) .thenReturn({'kind': _newStringSpan(100, "kind")}); @@ -144,7 +147,7 @@ class AttributeSelectorTest extends _SelectorTest { // ignore: non_constant_identifier_names void test_match_wildCard() { - final selector = new AttributeSelector(nameElement, null, true); + final selector = new AttributeSelector(nameElement, null, isWildcard: true); when(element.attributes).thenReturn({'kindatrue': 'no-matter'}); when(element.attributeNameSpans) .thenReturn({'kindatrue': _newStringSpan(100, "kindatrue")}); @@ -156,7 +159,7 @@ class AttributeSelectorTest extends _SelectorTest { // ignore: non_constant_identifier_names void test_noMatch_wildCard() { - final selector = new AttributeSelector(nameElement, null, true); + final selector = new AttributeSelector(nameElement, null, isWildcard: true); when(element.attributes).thenReturn({'indatrue': 'no-matter'}); when(element.attributeNameSpans) .thenReturn({'indatrue': _newStringSpan(100, "indatrue")}); @@ -166,13 +169,15 @@ class AttributeSelectorTest extends _SelectorTest { // ignore: non_constant_identifier_names void test_toString_hasValue() { - final selector = new AttributeSelector(nameElement, 'daffy', false); + final selector = + new AttributeSelector(nameElement, 'daffy', isWildcard: false); expect(selector.toString(), '[kind=daffy]'); } // ignore: non_constant_identifier_names void test_toString_noValue() { - final selector = new AttributeSelector(nameElement, null, false); + final selector = + new AttributeSelector(nameElement, null, isWildcard: false); expect(selector.toString(), '[kind]'); } } @@ -603,8 +608,8 @@ class SelectorParserTest { expect(selector, const isInstanceOf()); expect( selector.toString(), - equals("aaa || bbb && :not(ccc) || " + - ":not(:not(ddd) && [eee] || fff && [ggg])")); + equals('aaa || bbb && :not(ccc) || ' + ':not(:not(ddd) && [eee] || fff && [ggg])')); { final ElementNameSelector subSelector = selector.selectors[0]; expect(subSelector, const isInstanceOf()); @@ -730,7 +735,8 @@ class SuggestTagsTest { // ignore: non_constant_identifier_names void test_suggestPropertyNoValue() { final selector = new AttributeSelector( - new AngularElementImpl('attr', 10, 5, null), null, false); + new AngularElementImpl('attr', 10, 5, null), null, + isWildcard: false); final suggestions = _evenInvalidSuggestions(selector); expect(suggestions.length, 1); @@ -741,7 +747,8 @@ class SuggestTagsTest { // ignore: non_constant_identifier_names void test_suggestPropertyWithValue() { final selector = new AttributeSelector( - new AngularElementImpl('attr', 10, 5, null), "blah", false); + new AngularElementImpl('attr', 10, 5, null), "blah", + isWildcard: false); final suggestions = _evenInvalidSuggestions(selector); expect(suggestions.length, 1); @@ -752,7 +759,8 @@ class SuggestTagsTest { // ignore: non_constant_identifier_names void test_suggestWildcardProperty() { final selector = new AttributeSelector( - new AngularElementImpl('attr', 10, 5, null), null, true); + new AngularElementImpl('attr', 10, 5, null), null, + isWildcard: true); final suggestions = _evenInvalidSuggestions(selector); expect(suggestions.length, 1); @@ -764,7 +772,8 @@ class SuggestTagsTest { // ignore: non_constant_identifier_names void test_suggestWildcardPropertyValue() { final selector = new AttributeSelector( - new AngularElementImpl('attr', 10, 5, null), "value", true); + new AngularElementImpl('attr', 10, 5, null), "value", + isWildcard: true); final suggestions = _evenInvalidSuggestions(selector); expect(suggestions.length, 1); @@ -802,7 +811,8 @@ class SuggestTagsTest { final nameSelector = new ElementNameSelector(new AngularElementImpl('panel', 10, 5, null)); final attrSelector = new AttributeSelector( - new AngularElementImpl('attr', 10, 5, null), "value", true); + new AngularElementImpl('attr', 10, 5, null), "value", + isWildcard: true); final selector = new AndSelector([nameSelector, attrSelector]); final suggestions = selector.suggestTags(); @@ -816,7 +826,8 @@ class SuggestTagsTest { final nameSelector = new ElementNameSelector(new AngularElementImpl('panel', 10, 5, null)); final attrSelector = new AttributeSelector( - new AngularElementImpl('attr', 10, 5, null), "value", true); + new AngularElementImpl('attr', 10, 5, null), "value", + isWildcard: true); final selector = new OrSelector([nameSelector, attrSelector]); final suggestions = _evenInvalidSuggestions(selector); @@ -834,12 +845,14 @@ class SuggestTagsTest { final nameSelector1 = new ElementNameSelector(new AngularElementImpl('name1', 10, 5, null)); final attrSelector1 = new AttributeSelector( - new AngularElementImpl('attr1', 10, 5, null), "value", true); + new AngularElementImpl('attr1', 10, 5, null), "value", + isWildcard: true); final andSelector1 = new AndSelector([nameSelector1, attrSelector1]); final nameSelector2 = new ElementNameSelector(new AngularElementImpl('name2', 10, 5, null)); final attrSelector2 = new AttributeSelector( - new AngularElementImpl('attr2', 10, 5, null), "value", true); + new AngularElementImpl('attr2', 10, 5, null), "value", + isWildcard: true); final andSelector2 = new AndSelector([nameSelector2, attrSelector2]); final selector = new OrSelector([andSelector1, andSelector2]); @@ -860,9 +873,11 @@ class SuggestTagsTest { final orSelector1 = new OrSelector([nameSelector1, nameSelector2]); final attrSelector1 = new AttributeSelector( - new AngularElementImpl('attr1', 10, 5, null), "value", true); + new AngularElementImpl('attr1', 10, 5, null), "value", + isWildcard: true); final attrSelector2 = new AttributeSelector( - new AngularElementImpl('attr2', 10, 5, null), "value", true); + new AngularElementImpl('attr2', 10, 5, null), "value", + isWildcard: true); final orSelector2 = new OrSelector([attrSelector1, attrSelector2]); final selector = new AndSelector([orSelector1, orSelector2]); @@ -888,9 +903,11 @@ class SuggestTagsTest { final orSelector1 = new OrSelector([nameSelector1, nameSelector2]); final attrSelector1 = new AttributeSelector( - new AngularElementImpl('attr1', 10, 5, null), "value", true); + new AngularElementImpl('attr1', 10, 5, null), "value", + isWildcard: true); final attrSelector2 = new AttributeSelector( - new AngularElementImpl('attr2', 10, 5, null), "value", true); + new AngularElementImpl('attr2', 10, 5, null), "value", + isWildcard: true); final orSelector2 = new OrSelector([attrSelector1, attrSelector2]); final selector = new OrSelector([orSelector1, orSelector2]); @@ -1210,10 +1227,8 @@ class _SelectorTest { List resolvedRanges = []; void setUp() { - when(template.addRange(anyObject, anyObject)) - .thenInvoke((SourceRange range, AngularElement element) { - resolvedRanges.add(new ResolvedRange(range, element)); - }); + when(template.addRange(anyObject, anyObject)).thenInvoke((range, element) => + resolvedRanges.add(new ResolvedRange(range, element))); } void _assertRange(ResolvedRange resolvedRange, int offset, int length, diff --git a/analyzer_plugin/test/test_all.dart b/analyzer_plugin/test/test_all.dart index a29b3c9a..34a0bd21 100644 --- a/analyzer_plugin/test/test_all.dart +++ b/analyzer_plugin/test/test_all.dart @@ -2,11 +2,11 @@ library angular2.src.analysis.analyzer_plugin.src; import 'package:test_reflective_loader/test_reflective_loader.dart'; -import 'resolver_test.dart' as resolver_test; -import 'selector_test.dart' as selector_test; import 'angular_driver_test.dart' as angular_driver_test; import 'offsetting_constant_value_visitor_test.dart' as offsetting_constant_value_visitor_test; +import 'resolver_test.dart' as resolver_test; +import 'selector_test.dart' as selector_test; /// Utility for manually running all tests. void main() { diff --git a/server_plugin/analysis_options.yaml b/server_plugin/analysis_options.yaml index 11b79bb1..e0636d8f 100644 --- a/server_plugin/analysis_options.yaml +++ b/server_plugin/analysis_options.yaml @@ -9,7 +9,6 @@ linter: - always_require_non_null_named_parameters - annotate_overrides - avoid_annotating_with_dynamic - - avoid_catches_without_on_clauses - avoid_catching_errors - avoid_classes_with_only_static_members - avoid_empty_else diff --git a/server_plugin/lib/src/completion.dart b/server_plugin/lib/src/completion.dart index f0f77340..cf892123 100644 --- a/server_plugin/lib/src/completion.dart +++ b/server_plugin/lib/src/completion.dart @@ -107,7 +107,8 @@ class DartSnippetExtractor extends AngularAstVisitor { final analysisErrorListener = new IgnoringAnalysisErrorListener(); final dartParser = new EmbeddedDartParser(null, analysisErrorListener, null); - dartSnippet = dartParser.parseDartExpression(offset, '', false); + dartSnippet = + dartParser.parseDartExpression(offset, '', detectTrailing: false); } } } @@ -260,8 +261,7 @@ class TemplateCompleter { .enclosingElement.context.typeProvider; final target = findTarget(request.offset, template.ast) ..accept(new ReplacementRangeCalculator(request)); - final extractor = new DartSnippetExtractor(); - extractor.offset = request.offset; + final extractor = new DartSnippetExtractor()..offset = request.offset; target.accept(extractor); if (extractor.dartSnippet != null) { final dartRequest = new EmbeddedDartCompletionRequest.from( diff --git a/server_plugin/test/analysis_test.dart b/server_plugin/test/analysis_test.dart index e3e57afe..0b1c703d 100644 --- a/server_plugin/test/analysis_test.dart +++ b/server_plugin/test/analysis_test.dart @@ -64,9 +64,8 @@ class AngularNavigationContributorTest extends AbstractAngularTaskTest { @override void setUp() { super.setUp(); - when(collector.addRegion(anyInt, anyInt, anyObject, anyObject)).thenInvoke( - (int offset, int length, protocol.ElementKind targetKind, - protocol.Location targetLocation) { + when(collector.addRegion(anyInt, anyInt, anyObject, anyObject)) + .thenInvoke((offset, length, targetKind, targetLocation) { regions.add(new _RecordedNavigationRegion( offset, length, targetKind, targetLocation)); }); @@ -396,11 +395,11 @@ class AbstractAngularTaskTest { ..add(new AngularAnalyzerPlugin())); emptySource = newSource('/test.dart'); // prepare AnalysisContext - context = new AnalysisContextImpl(); - context.sourceFactory = new SourceFactory([ - new DartUriResolver(sdk), - new ResourceUriResolver(resourceProvider) - ]); + context = new AnalysisContextImpl() + ..sourceFactory = new SourceFactory([ + new DartUriResolver(sdk), + new ResourceUriResolver(resourceProvider) + ]); // configure AnalysisDriver analysisDriver = context.driver; } diff --git a/server_plugin/test/completion_contributor_test.dart b/server_plugin/test/completion_contributor_test.dart index 75c36ce5..92a0737c 100644 --- a/server_plugin/test/completion_contributor_test.dart +++ b/server_plugin/test/completion_contributor_test.dart @@ -537,9 +537,8 @@ class HtmlCompletionContributorTest extends AbstractCompletionContributorTest { } @override - CompletionContributor createContributor() { - return new AngularCompletionContributor(angularDriver); - } + CompletionContributor createContributor() => + new AngularCompletionContributor(angularDriver); // ignore: non_constant_identifier_names Future test_completeMemberInMustache() async { diff --git a/server_plugin/test/completion_contributor_test_util.dart b/server_plugin/test/completion_contributor_test_util.dart index 74ea63bb..be3d37f2 100644 --- a/server_plugin/test/completion_contributor_test_util.dart +++ b/server_plugin/test/completion_contributor_test_util.dart @@ -509,7 +509,7 @@ abstract class BaseCompletionContributorTest extends AbstractAngularTest { protocol.ElementKind elemKind: null}) { var cs; if (suggestions != null) { - suggestions.forEach((CompletionSuggestion s) { + suggestions.forEach((s) { if (completion != null && completion != s.completion) { return; } diff --git a/server_plugin/test/mock_sdk.dart b/server_plugin/test/mock_sdk.dart index 9dbb4621..5cc57215 100644 --- a/server_plugin/test/mock_sdk.dart +++ b/server_plugin/test/mock_sdk.dart @@ -520,7 +520,7 @@ class MockSdk implements DartSdk { uriMap = dartAsync ? FULL_URI_MAP : NO_ASYNC_URI_MAP { for (_MockSdkLibrary library in sdkLibraries) { provider.newFile(provider.convertPath(library.path), library.content); - library.parts.forEach((String path, String content) { + library.parts.forEach((path, content) { provider.newFile(provider.convertPath(path), content); }); } @@ -553,7 +553,7 @@ class MockSdk implements DartSdk { @override List get uris => - sdkLibraries.map((SdkLibrary library) => library.shortName).toList(); + sdkLibraries.map((library) => library.shortName).toList(); @override Source fromFileUri(Uri uri) { @@ -644,9 +644,8 @@ class MockSdk implements DartSdk { /// Compute the bytes of the linked bundle associated with this SDK. List _computeLinkedBundleBytes() { - final librarySources = sdkLibraries - .map((SdkLibrary library) => mapDartUri(library.shortName)) - .toList(); + final librarySources = + sdkLibraries.map((library) => mapDartUri(library.shortName)).toList(); return new SummaryBuilder( librarySources, context, context.analysisOptions.strongMode) .build();