| Index: pkg/analyzer/lib/src/generated/resolver.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
|
| index 366162f80da4c37e73733933535bc0aaee848ea0..a34649ad2af240ec1394a639f6ec33e30c25fe7d 100644
|
| --- a/pkg/analyzer/lib/src/generated/resolver.dart
|
| +++ b/pkg/analyzer/lib/src/generated/resolver.dart
|
| @@ -152,12 +152,25 @@ class AngularCompilationUnitBuilder {
|
| * cannot parse.
|
| */
|
| static AngularSelectorElement parseSelector(int offset, String text) {
|
| + // [attribute]
|
| if (StringUtilities.startsWithChar(text, 0x5B) && StringUtilities.endsWithChar(text, 0x5D)) {
|
| int nameOffset = offset + "[".length;
|
| String attributeName = text.substring(1, text.length - 1);
|
| // TODO(scheglov) report warning if there are spaces between [ and identifier
|
| return new HasAttributeSelectorElementImpl(attributeName, nameOffset);
|
| }
|
| + // tag[attribute]
|
| + if (StringUtilities.endsWithChar(text, 0x5D)) {
|
| + int index = StringUtilities.indexOf1(text, 0, 0x5B);
|
| + if (index != -1) {
|
| + String tagName = text.substring(0, index);
|
| + String attributeName = text.substring(index + 1, text.length - 1);
|
| + if (StringUtilities.isTagName(tagName)) {
|
| + return new IsTagHasAttributeSelectorElementImpl(tagName, attributeName);
|
| + }
|
| + }
|
| + }
|
| + // tag
|
| if (StringUtilities.isTagName(text)) {
|
| return new IsTagSelectorElementImpl(text, offset);
|
| }
|
| @@ -398,9 +411,11 @@ class AngularCompilationUnitBuilder {
|
| void parseNgComponent() {
|
| bool isValid = true;
|
| // publishAs
|
| - if (!hasStringArgument(_PUBLISH_AS)) {
|
| - reportErrorForAnnotation(AngularCode.MISSING_PUBLISH_AS, []);
|
| - isValid = false;
|
| + String name = null;
|
| + int nameOffset = -1;
|
| + if (hasStringArgument(_PUBLISH_AS)) {
|
| + name = getStringArgument(_PUBLISH_AS);
|
| + nameOffset = getStringArgumentOffset(_PUBLISH_AS);
|
| }
|
| // selector
|
| AngularSelectorElement selector = null;
|
| @@ -416,30 +431,28 @@ class AngularCompilationUnitBuilder {
|
| }
|
| }
|
| // templateUrl
|
| - if (!hasStringArgument(_TEMPLATE_URL)) {
|
| - reportErrorForAnnotation(AngularCode.MISSING_TEMPLATE_URL, []);
|
| - isValid = false;
|
| + String templateUri = null;
|
| + int templateUriOffset = -1;
|
| + if (hasStringArgument(_TEMPLATE_URL)) {
|
| + templateUri = getStringArgument(_TEMPLATE_URL);
|
| + templateUriOffset = getStringArgumentOffset(_TEMPLATE_URL);
|
| }
|
| // cssUrl
|
| - if (!hasStringArgument(_CSS_URL)) {
|
| - reportErrorForAnnotation(AngularCode.MISSING_CSS_URL, []);
|
| - isValid = false;
|
| + String styleUri = null;
|
| + int styleUriOffset = -1;
|
| + if (hasStringArgument(_CSS_URL)) {
|
| + styleUri = getStringArgument(_CSS_URL);
|
| + styleUriOffset = getStringArgumentOffset(_CSS_URL);
|
| }
|
| // create
|
| if (isValid) {
|
| - String name = getStringArgument(_PUBLISH_AS);
|
| - int nameOffset = getStringArgumentOffset(_PUBLISH_AS);
|
| - String templateUri = getStringArgument(_TEMPLATE_URL);
|
| - int templateUriOffset = getStringArgumentOffset(_TEMPLATE_URL);
|
| - String styleUri = getStringArgument(_CSS_URL);
|
| - int styleUriOffset = getStringArgumentOffset(_CSS_URL);
|
| AngularComponentElementImpl element = new AngularComponentElementImpl(name, nameOffset);
|
| element.selector = selector;
|
| element.templateUri = templateUri;
|
| element.templateUriOffset = templateUriOffset;
|
| // resolve template URI
|
| // TODO(scheglov) resolve to HtmlElement to allow F3 ?
|
| - {
|
| + if (templateUri != null) {
|
| try {
|
| parseUriWithException(templateUri);
|
| // TODO(scheglov) think if there is better solution
|
| @@ -448,9 +461,14 @@ class AngularCompilationUnitBuilder {
|
| }
|
| Source templateSource = _context.sourceFactory.resolveUri(_source, templateUri);
|
| if (templateSource == null || !templateSource.exists()) {
|
| + templateSource = _context.sourceFactory.resolveUri(_source, "package:${templateUri}");
|
| + }
|
| + if (templateSource == null || !templateSource.exists()) {
|
| reportErrorForArgument(_TEMPLATE_URL, AngularCode.URI_DOES_NOT_EXIST, [templateUri]);
|
| }
|
| - element.templateSource = templateSource;
|
| + if (AnalysisEngine.isHtmlFileName(templateUri)) {
|
| + element.templateSource = templateSource;
|
| + }
|
| } on URISyntaxException catch (exception) {
|
| reportErrorForArgument(_TEMPLATE_URL, AngularCode.INVALID_URI, [templateUri]);
|
| }
|
| @@ -571,11 +589,12 @@ class AngularCompilationUnitBuilder {
|
| String fieldName = spec.substring(fieldNameOffset);
|
| fieldNameOffset += specLiteral.valueOffset;
|
| // prepare field
|
| - FieldElement field = _classElement.getField(fieldName);
|
| - if (field == null) {
|
| + PropertyAccessorElement setter = _classElement.type.lookUpSetter(fieldName, _classElement.library);
|
| + if (setter == null) {
|
| reportError2(fieldNameOffset, fieldName.length, AngularCode.INVALID_PROPERTY_FIELD, [fieldName]);
|
| continue;
|
| }
|
| + FieldElement field = setter.variable as FieldElement;
|
| // add property
|
| AngularPropertyElementImpl property = new AngularPropertyElementImpl(name, nameOffset);
|
| property.field = field;
|
| @@ -8200,17 +8219,6 @@ class Library {
|
| _directiveUris[directive] = uriContent;
|
| uriContent = Uri.encodeFull(uriContent);
|
| if (directive is ImportDirective && uriContent.startsWith(_DART_EXT_SCHEME)) {
|
| - String uriBase = uriContent.substring(_DART_EXT_SCHEME.length);
|
| - Source source = _analysisContext.sourceFactory.resolveUri(librarySource, "${uriBase}.dll");
|
| - if (source == null || !source.exists()) {
|
| - source = _analysisContext.sourceFactory.resolveUri(librarySource, "${uriBase}.so");
|
| - if (source == null || !source.exists()) {
|
| - source = _analysisContext.sourceFactory.resolveUri(librarySource, "${uriBase}.dylib");
|
| - if (source == null || !source.exists()) {
|
| - _errorListener.onError(new AnalysisError.con2(librarySource, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.URI_DOES_NOT_EXIST, [uriContent]));
|
| - }
|
| - }
|
| - }
|
| _libraryElement.hasExtUri2 = true;
|
| return null;
|
| }
|
| @@ -10772,9 +10780,12 @@ abstract class ScopedVisitor extends UnifyingASTVisitor<Object> {
|
|
|
| /**
|
| * Replaces the current [Scope] with the enclosing [Scope].
|
| + *
|
| + * @return the enclosing [Scope].
|
| */
|
| - void popNameScope() {
|
| + Scope popNameScope() {
|
| _nameScope = _nameScope.enclosingScope;
|
| + return _nameScope;
|
| }
|
|
|
| /**
|
| @@ -10785,7 +10796,7 @@ abstract class ScopedVisitor extends UnifyingASTVisitor<Object> {
|
| Scope pushNameScope() {
|
| Scope newScope = new EnclosedScope(_nameScope);
|
| _nameScope = newScope;
|
| - return newScope;
|
| + return _nameScope;
|
| }
|
|
|
| /**
|
|
|