Microsoft/TypeScript — pull request #1385 by CyrusNajmabadi (2014-12-05 21:04:23+00:00)
Title: Remove restriction that you cannot reuse nodes/tokens during incremental parsing while doing speculatively operations.

Great idea from @yuit

This restriction was in place because the old parser would mutate nodes as it created them. i.e. when
creating a node it would set the parent of its children right then. During incremental parsing, this
couldl be bad because we might take an old node, set its parent to be something else, and then decide
we didn't even want to go down that speculative path to begin with. Now the parent of some child node
would be mutated. So we might have a node that pointed to a child that then pointed to a different
parent.

To get around this, we restricted the incremental so that it would not reuse from the previous tree
if we were speculatively parsing. However, Yui had a very good idea to just move the parent setting
phase to be a postpast (similar to the new compiler). By doing this, we never mutate nodes as we
parse, and thus we never end up with inconsistent nodes. The post pass then ensures that all parents
are correct relative to the new tree.

Conflicts:
src/services/syntax/SyntaxGenerator.js
src/services/syntax/SyntaxGenerator.js.map
src/services/syntax/incrementalParser.ts
src/services/syntax/scanner.ts
src/services/syntax/syntaxGenerator.ts
src/services/syntax/syntaxNodes.concrete.generated.ts