handle bad source code
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/c1a72014 Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/c1a72014 Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/c1a72014 Branch: refs/heads/develop Commit: c1a72014cc5b1118d04c70fa0636b4fa6442e783 Parents: 1240394 Author: Alex Harui <[email protected]> Authored: Thu Oct 30 21:35:47 2014 -0700 Committer: Alex Harui <[email protected]> Committed: Thu Oct 30 21:36:36 2014 -0700 ---------------------------------------------------------------------- .../internal/mxml/MXMLTagAttributeData.java | 16 +++++++++++++++- .../internal/tree/mxml/MXMLInstanceNode.java | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c1a72014/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTagAttributeData.java ---------------------------------------------------------------------- diff --git a/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTagAttributeData.java b/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTagAttributeData.java index 4b2c4ad..5e04336 100644 --- a/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTagAttributeData.java +++ b/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTagAttributeData.java @@ -75,6 +75,8 @@ public class MXMLTagAttributeData extends SourceLocation implements IMXMLTagAttr if (token.getType() != MXMLTokenTypes.TOKEN_EQUALS) { + if (token.getSourcePath() == null) + token.setSourcePath(spec.getPath()); problems.add(new SyntaxProblem(token)); // Restore the token position for error recovery. tokenIterator.previous(); @@ -86,6 +88,8 @@ public class MXMLTagAttributeData extends SourceLocation implements IMXMLTagAttr valueColumn = token.getColumn(); } + Boolean firstToken = true; + // Look for value token. while (tokenIterator.hasNext()) { @@ -96,7 +100,13 @@ public class MXMLTagAttributeData extends SourceLocation implements IMXMLTagAttr } else { - if (!MXMLToken.isTagEnd(token.getType()) && token.getType() != MXMLTokenTypes.TOKEN_NAME) + if (firstToken) + { + if (token.getSourcePath() == null) + token.setSourcePath(spec.getPath()); + problems.add(new SyntaxProblem(token)); + } + else if (!MXMLToken.isTagEnd(token.getType()) && token.getType() != MXMLTokenTypes.TOKEN_NAME) { if (token.getSourcePath() == null) token.setSourcePath(spec.getPath()); @@ -106,6 +116,7 @@ public class MXMLTagAttributeData extends SourceLocation implements IMXMLTagAttr tokenIterator.previous(); return; } + firstToken = false; } } @@ -283,6 +294,9 @@ public class MXMLTagAttributeData extends SourceLocation implements IMXMLTagAttr public ISourceFragment[] getValueFragments(Collection<ICompilerProblem> problems) { String value = getRawValue(); + if (value == null) + return new ISourceFragment[0]; + ISourceLocation location = getValueLocation(); MXMLDialect mxmlDialect = getMXMLDialect(); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c1a72014/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLInstanceNode.java ---------------------------------------------------------------------- diff --git a/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLInstanceNode.java b/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLInstanceNode.java index 13852cf..ee5ed4a 100644 --- a/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLInstanceNode.java +++ b/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLInstanceNode.java @@ -193,6 +193,8 @@ class MXMLInstanceNode extends MXMLClassReferenceNodeBase implements IMXMLInstan IMXMLTagAttributeData attribute) { String value = attribute.getRawValue(); + if (value == null) + value = ""; // Falcon trims this attribute even though the old compiler didn't. MXMLDialect mxmlDialect = builder.getMXMLDialect();
