Skip to content
This repository was archived by the owner on Jun 20, 2019. It is now read-only.

Summary integration#276

Merged
mk13 merged 60 commits into
dart-archive:angular_ast_integrationfrom
mk13:summary_integration
Apr 20, 2017
Merged

Summary integration#276
mk13 merged 60 commits into
dart-archive:angular_ast_integrationfrom
mk13:summary_integration

Conversation

@mk13

@mk13 mk13 commented Apr 11, 2017

Copy link
Copy Markdown
Contributor

One more try.

mk13 added 30 commits November 30, 2016 10:41
@mk13 mk13 removed the cla: no label Apr 11, 2017
@mk13 mk13 requested a review from MichaelRFairhurst April 11, 2017 23:11

@MichaelRFairhurst MichaelRFairhurst left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I do see one bug. In lib/tasks.dart, we have a list of errors that turn into a map of codes to types, which is used to deserialize errors from summaries.

We'll likely need a similar pattern for ast errors.

I bet that if you open up green tea, then hit reanalyze, all the syntactic errors will disappear because they will fail to be deserialized without a means to go from string error code to object error code.

Really looking forward to getting this merged. Love the new parser.

import 'package:html/parser.dart' as html;
import 'package:source_span/source_span.dart';

html.Element firstElement(html.Node node) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice we can remove this :)


// Following Angular2 Logic:
// https://github.com/dart-lang/angular2/blob/8220ba3a693aff51eed33cd1ec9542bde9017423/lib/src/compiler/schema/dom_element_schema_registry.dart#L199
static const attrToPropMap = const {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be done in angular_ast?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One problem I see with this is that angular_ast doesn't keep track of two different names, which could make the offset off for 'class':'className' conversion. ExpressionBoundAttribute class keeps track of two different names: origName and propName, which allows us some flexibility in what is being interpreted for value and one for offset.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From our conversation -- agreed. This is the right place for this!

Comment thread analyzer_plugin/lib/src/converter.dart Outdated
return root;
}

NodeInfo convert(StandaloneTemplateAst node, {ElementInfo parent}) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parent is no longer optional, really, right?

You could make it just a second parameter, or to keep the parent: naming (kinda nice right?) you can mark it @required which will make it an error if we forget to use parent: even though its a named (as opposed to positional) param.

Comment thread analyzer_plugin/lib/src/converter.dart Outdated
} else {
openingSpan = _toSourceRange(
node.beginToken.offset, node.endToken.end - node.beginToken.offset);
openingNameSpan =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no real opening/closing name span in angular ast? Would be nice to not make it openingNameSpan - '<'.length, but something tracked at parse time.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can use the identifierToken actually so it will be similar to how openingSpan is defined.
openingNameSpan = _toSourceRange(identifierToken.offset, identifierToken.length)

node.beginToken.offset, node.endToken.end - node.beginToken.offset);
openingNameSpan =
new SourceRange(openingSpan.offset + '<'.length, localName.length);
var pnode = node as ParsedEmbeddedContentAst;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this cast necessary? Can't the Parsed and Synthetic versions of EmbeddedContentAst both share the same interface?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parsed version have access to tokens, synthetic does not and the tokens contain the direct offsets. As a result, the casting is necessary.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Ok, just wanted to ask!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact that's great, as compared to getting null unexpectedly.

template.view.classElement, dartRequest,
skipChildClass: false));
var memberContributor = new TypeMemberContributor();
var inheritedContributor = new InheritedReferenceContributor();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Liking the reduction of types that don't help readability. Very nice! Though I might have preferred final, not everyone does, so it can be a controversy worth avoiding :) So looks great!

inheritedContributor.computeSuggestionsForClass(
template.view.classElement,
dartRequest,
skipChildClass: false,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dangling comma?

@mk13 mk13 Apr 12, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah turns out if you put a dangling comma at the end and call 'dartfmt', it makes long lists very neatly aligned. If it's a long list with nested functions, I think this adds to readability in exchange for some additional lines.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k, sgtm

suggestions, varExtractor.variables, dartRequest.opType);
suggestions,
varExtractor.variables,
dartRequest.opType,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same?

Comment thread server_plugin/lib/src/completion.dart Outdated
suggestTransclusions(target.parent, suggestions);
}
}
// Directly within closing tag; suggest nothing. Ex: '</div^>'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once again, nice comments.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you maybe move this comment inside the else block? Otherwise I read this as the end of the control structure, takes me a moment to realize that the "else" goes here.

Comment thread server_plugin/lib/src/completion.dart Outdated
}
}
// Directly within closing tag; suggest nothing. Ex: '</div^>'
else

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

brackets

@MichaelRFairhurst MichaelRFairhurst left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice changes so far, looking great

Comment thread analyzer_plugin/lib/src/converter.dart Outdated
valueOffset, dartParser.findMustaches(value, valueOffset)));
}
}
;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dangling semi

Comment thread analyzer_plugin/lib/src/converter.dart Outdated
property, "[", "]", ExpressionBoundType.input));
}
}
;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too

Comment thread analyzer_plugin/lib/src/converter.dart Outdated
valueOffset, dartParser.findMustaches(value, valueOffset)));
}
}
;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dangling semi

Comment thread analyzer_plugin/lib/src/converter.dart Outdated
property, "[", "]", ExpressionBoundType.input));
}
}
;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too

Comment thread analyzer_plugin/lib/src/converter.dart Outdated
valueOffset,
dartParser.findMustaches(value, valueOffset)));
}
;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too

void assertMultipleErrorsExplicit(
Source source,
String code,
List<Tuple4<String, int, ErrorCode, List<Object>>> expectedErrors,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

* code segment where offset begins,
* length of the error highlight,
* errorCode,
* and optional error args - pass empty list if not needed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only just realized that your new assertion function here checks the args. I've wanted to have tests for them, this is great!

NgParserWarningCode.EXPECTED_WHITESPACE_BEFORE_NEW_DECORATOR),
new AnalysisError(htmlSource, 6, 14, NgParserWarningCode.SUFFIX_PROPERTY),
assertMultipleErrorsExplicit(htmlSource, code, [
new Tuple4(']', 0, AngularWarningCode.NONEXIST_INPUT_BOUND, ['']),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, hadn't noticed before that these errors had a length of zero. How does intelliJ handle that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you double click it it puts the cursor right at the spot, but doesn't squiggle anything since it's of length 0. I'm planning sometime later once the ast is merged to do another pass and make the error messages more helpful in terms of length.

expect(realErrors.length, expectedErrors.length,
reason: 'Expected error counts do not match.');
for (Tuple4 expectedError in expectedErrors) {
var offset = code.indexOf(expectedError.item1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to assert that this isn't -1, or maybe even assert that the expected code doesn't occur more than once in the test file?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you did this, and github didn't realize. Commenting here so we know

Comment thread server_plugin/lib/src/completion.dart Outdated
suggestTransclusions(target.parent, suggestions);
}
}
// Directly within closing tag; suggest nothing. Ex: '</div^>'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you maybe move this comment inside the else block? Otherwise I read this as the end of the control structure, takes me a moment to realize that the "else" goes here.

@mk13

mk13 commented Apr 15, 2017

Copy link
Copy Markdown
Contributor Author

Still need to add change such that conversion does not have three semi-redundant conversions based on check of ElementAst, EmbeddedTemplateAst, and EmbeddedContentAst.

Need to add some refactor into angular_ast to create a generic encapsulation interface and want to re-factor EmbeddedContentAst generation to recycle some code instead of creating its own (seemingly wasteful) logic.

@MichaelRFairhurst MichaelRFairhurst left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice changes

List<ParsedEventAst> events: const [],
List<ParsedPropertyAst> properties: const [],
List<ParsedReferenceAst> references: const [],
List<ParsedStarAst> stars: const [],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the use of named params, makes it really clean when called

(there should probably be a lint for having more than x unnamed parameters, don't you think?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, especially when the values have defaults - makes things so much cleaner.

Comment thread analyzer_plugin/lib/src/converter.dart Outdated

element.events.forEach((event) {
attributes.add(_convertStatementsBoundAttribute(event, "(", ")"));
bananas.forEach((banana) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could -- depending on preference -- be

bananas.map(_convertExpressionBoundAttribute).forEach(returnAttributes.add)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, changing it 👍

Comment thread analyzer_plugin/lib/src/converter.dart Outdated

value = ast.value;
ParsedEventAst ast) {
var origName =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nested ternaries...hmm, should probably have at least one if statement I think

expect(realErrors.length, expectedErrors.length,
reason: 'Expected error counts do not match.');
for (Tuple4 expectedError in expectedErrors) {
var offset = code.indexOf(expectedError.item1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you did this, and github didn't realize. Commenting here so we know

Comment thread deps/pubspec.yaml Outdated
git:
url: https://github.com/mk13/angular_ast
ref: master
ref: on_bind_parsing

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be master again, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, that's true. But I might have to switch this again.

@mk13 mk13 added cla: yes and removed cla: no labels Apr 18, 2017
@mk13

mk13 commented Apr 18, 2017

Copy link
Copy Markdown
Contributor Author

I wanted to condense the three element type condensing - but that depends on the condensing of the three types in the angular_ast (dart-archive/angular_ast#34). Seeing as how it needs to be discussed more, it might be a good point to end this PR here and make the condensing of Element types into a separate PR.

Ending the refactor of code/code clean-up and moving onto resolving the potential issue of errors not properly deserializing.

@mk13

mk13 commented Apr 18, 2017

Copy link
Copy Markdown
Contributor Author

Ping @MichaelRFairhurst for approval.

Modified logic that loads the error codes into memory. Think we should add this logic here? or create a separate map within angular_ast?

@MichaelRFairhurst

Copy link
Copy Markdown
Contributor

Definitely worth building and running against greentea as a last check, but it LGTM!

@mk13 mk13 added cla: yes and removed cla: no labels Apr 20, 2017
@mk13 mk13 merged commit 4ac4248 into dart-archive:angular_ast_integration Apr 20, 2017
mk13 added a commit that referenced this pull request May 16, 2017
* Summary integration (#276)

* Sync to origin master

* checkpoint

* Initial ast integration - ranges not behaving properly

* Minor bug fix

* checkpoint

* Tasks tests all passing

* Checkpoint before error code fix

* Tasks tests set back to 100% after introducing error codes

* resolver_test midway checkpoint

* Checkpoint

* Full test coverage in analyzer. Server still left

* All tests passing

* Make paths explicit

* Remove comments

* Attributes now sorted by offset. Improves performance in auto completion

* DOCTYPE now acceptable

* Created separate Ast for top level document container

* Refactored primary function in completion.dart

* Minor code clean up

* Fuzz tester bug fix

* Revert try catch block

* Rename exception codes after changes in angular_ast

* Bug fix on [class. [style. [attr. bindings; range error

* Allow spaces in msutaches

* Autocompletion in text attribute value is now empty

* Allow for plain [class] binding

* Fixed update_deps.sh to work with angular_ast

* Clean up deps and remove some unnecessary comments

* Changed pubspec to pull from master

* Defend against files hidden by generated files (#271)

* Fix travis build. Fix sdk related errors (ContextRoot and IdeOptions). Clean up imports to remove unused

* Travis sdk fix (#272)

* Sync to origin master

* Fix travis build. Fix sdk related errors (ContextRoot and IdeOptions). Clean up imports to remove unused

* First round of quick fixes based on feedback

* remove comment

* Error codes no longer use hard offsets; uses string instead

* Merged attribute generating logic to be agnostic of Element or template type.

* Assert for indexOf added into test. Moved comments for clarity

* Remove comment-blocked chunk

* Changes based on feedback

* Error codes added to hashmap so now show up. Fixed issue with <div template> causing crash

* Changed pubspec to pull from master in angular_ast

* Summary integration sync (#288)

* Sync to origin master

* checkpoint

* Initial ast integration - ranges not behaving properly

* Minor bug fix

* checkpoint

* Tasks tests all passing

* Checkpoint before error code fix

* Tasks tests set back to 100% after introducing error codes

* resolver_test midway checkpoint

* Checkpoint

* Full test coverage in analyzer. Server still left

* All tests passing

* Make paths explicit

* Remove comments

* Attributes now sorted by offset. Improves performance in auto completion

* DOCTYPE now acceptable

* Created separate Ast for top level document container

* Refactored primary function in completion.dart

* Minor code clean up

* Fuzz tester bug fix

* Revert try catch block

* Rename exception codes after changes in angular_ast

* Bug fix on [class. [style. [attr. bindings; range error

* Allow spaces in msutaches

* Autocompletion in text attribute value is now empty

* Allow for plain [class] binding

* Fixed update_deps.sh to work with angular_ast

* Clean up deps and remove some unnecessary comments

* Changed pubspec to pull from master

* Defend against files hidden by generated files (#271)

* Fix travis build. Fix sdk related errors (ContextRoot and IdeOptions). Clean up imports to remove unused

* Travis sdk fix (#272)

* Sync to origin master

* Fix travis build. Fix sdk related errors (ContextRoot and IdeOptions). Clean up imports to remove unused

* First round of quick fixes based on feedback

* Tick to 8 (#277)

* Sync to origin master

* Fix travis build. Fix sdk related errors (ContextRoot and IdeOptions). Clean up imports to remove unused

* Tick to 0.0.8

* remove comment

* Error codes no longer use hard offsets; uses string instead

* Track @Attribute annotated constructor parameters (#270)

* Merged attribute generating logic to be agnostic of Element or template type.

* Assert for indexOf added into test. Moved comments for clarity

* Remove comment-blocked chunk

* Resolve plain attributes -- in ranges, and strchecks for inputs. (#278)

* Resolve plain attributes -- in ranges, and strchecks for inputs.

Record resolved ranges for `x="y"` where `x` is an input or a constructor
`@Attribute`. If its an input, check that strings are assignable to it.
If not, give it its own error that hopefully explains the semi magical
situation.

* Track/typecheck std attrs

Eventually we should
* report errors for <a href="foo" [href]="bar">
* not suggest href after [href] has been used
* not suggest [href] after href has been used

* Changes based on feedback

* Error codes added to hashmap so now show up. Fixed issue with <div template> causing crash

* Changed pubspec to pull from master in angular_ast

* Template parsing fix (#279)

* Sync to origin master

* Fix travis build. Fix sdk related errors (ContextRoot and IdeOptions). Clean up imports to remove unused

* Fix issue that caused empty binding on template attribute to crash

* Now ready: Priority angular analysis (#273)

* Priority dart & html analysis

* Starter class, await supplementing errors or they're added too late.

* Report has work to analyze for priority requests

* Don't await for requesting files, do have a cache busting option

* Handle case of files being requested multiple times

* Priority html requests, requires serving errors with line infos.

* Report all html files for all dart contexts in one method, plus tests

I think before we were getting a last-one-wins effect, where the last
analyzed dart/html pair would cover up all the errors for every other
dart/html pair.

As such, I need to carefully test that this change doesn't introduce
new false errors (from them being covered up before).

But now with this, we can report html errors back for multiple contexts
from a single method when that's requested. Next I just have to use
that method on getErrors when we have multiple relationships tracked
already.

* Guess html/dart relationship when none exist, otherwise use what's known
  using isEmpty rather than == 0

* Get setterType by setter.parameters[0] instead of setter.variable.type (#283)

Seems like in the precense of a getter, setter.variable.type is the
getter type, not the setter's type. So use the first function argument
instead.

* Remove contextRoot, won't be required in master soon, and breaks dev (#284)

* Disable global attr plaintext typechecking until #280 has a clear solution (#286)

* Update test_reflective_loader, fix analyzer warnings&errors (#285)

* Update test_reflective_loader, fix analyzer warnings&errors

* Fix the single server test too, which prevents build errors

* Use var instead of types in angular_driver_test

* Add TODOs

* Percentage use fix in style.width and style.height. Test cases added (#282)

* Percentage use fix in style.width and style.height. Test cases added

* Added more property names that use percentage

* Tests passing

* Sync to master; tests passing
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

3 participants