You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2014/10/02 00:36:56 UTC

[4/5] git commit: [flex-falcon] [refs/heads/develop] - use more useful error message when tags are unbalanced

use more useful error message when tags are unbalanced


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/736e33c8
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/736e33c8
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/736e33c8

Branch: refs/heads/develop
Commit: 736e33c820a6d8f61114c305ac61511d899b823f
Parents: 958a547
Author: Alex Harui <ah...@apache.org>
Authored: Wed Oct 1 15:25:26 2014 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Wed Oct 1 15:25:26 2014 -0700

----------------------------------------------------------------------
 .../internal/mxml/MXMLTagAttributeData.java     |  3 +-
 .../internal/parsing/mxml/MXMLTagDataDepth.java |  6 +--
 .../problems/MXMLUnclosedTagProblem.java        | 56 ++++++++++++++++++++
 3 files changed, 61 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/736e33c8/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 5debe58..4b2c4ad 100644
--- a/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTagAttributeData.java
+++ b/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTagAttributeData.java
@@ -34,6 +34,7 @@ import org.apache.flex.compiler.mxml.IMXMLTagAttributeData;
 import org.apache.flex.compiler.mxml.IMXMLTagData;
 import org.apache.flex.compiler.parsing.MXMLTokenTypes;
 import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.problems.MXMLUnclosedTagProblem;
 import org.apache.flex.compiler.problems.SyntaxProblem;
 
 /**
@@ -99,7 +100,7 @@ public class MXMLTagAttributeData extends SourceLocation implements IMXMLTagAttr
                 {
                     if (token.getSourcePath() == null)
                         token.setSourcePath(spec.getPath());
-                    problems.add(new SyntaxProblem(token));
+                    problems.add(new MXMLUnclosedTagProblem(token));
                 }
                 // Restore the token position for error recovery.
                 tokenIterator.previous();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/736e33c8/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLTagDataDepth.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLTagDataDepth.java b/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLTagDataDepth.java
index 814bdd2..cfdf106 100644
--- a/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLTagDataDepth.java
+++ b/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLTagDataDepth.java
@@ -35,7 +35,7 @@ import org.apache.flex.compiler.mxml.IMXMLTagAttributeData;
 import org.apache.flex.compiler.mxml.IMXMLUnitData;
 import org.apache.flex.compiler.parsing.MXMLTokenTypes;
 import org.apache.flex.compiler.problems.ICompilerProblem;
-import org.apache.flex.compiler.problems.SyntaxProblem;
+import org.apache.flex.compiler.problems.MXMLUnclosedTagProblem;
 import org.apache.flex.utils.FastStack;
 
 /**
@@ -224,7 +224,7 @@ class MXMLTagDataDepth {
 					while(pos < tokenSize) {
 						IMXMLUnitData currToken = data[pos];
 						if(currToken instanceof MXMLTagData && !((MXMLTagData)currToken).hasExplicitCloseTag()) {
-						    problems.add(new SyntaxProblem(currToken, ((MXMLTagData)currToken).getName()));
+						    problems.add(new MXMLUnclosedTagProblem(currToken, ((MXMLTagData)currToken).getName()));
 						    FakeMXMLTagData fakeMXMLTagData = new FakeMXMLTagData((MXMLTagData)currToken, true);
                             data[pos] = fakeMXMLTagData;
                             prefixMap.remove((MXMLTagData)currToken);
@@ -257,7 +257,7 @@ class MXMLTagDataDepth {
             if (tag.getSourcePath() == null)
                 tag.setSourcePath(fileSpec.getPath());
         }
-        return new SyntaxProblem(tagData, tagData.getName());
+        return new MXMLUnclosedTagProblem(tagData, tagData.getName());
     }
 	
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/736e33c8/compiler/src/org/apache/flex/compiler/problems/MXMLUnclosedTagProblem.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/problems/MXMLUnclosedTagProblem.java b/compiler/src/org/apache/flex/compiler/problems/MXMLUnclosedTagProblem.java
new file mode 100644
index 0000000..dab73ad
--- /dev/null
+++ b/compiler/src/org/apache/flex/compiler/problems/MXMLUnclosedTagProblem.java
@@ -0,0 +1,56 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.problems;
+
+import org.apache.flex.compiler.common.ISourceLocation;
+import org.apache.flex.compiler.internal.parsing.as.ASToken;
+import org.apache.flex.compiler.problems.annotations.ProblemClassification;
+
+/**
+ * Problem generated when an unterminated entity is found.
+ */
+@ProblemClassification(CompilerProblemClassification.SYNTAX_ERROR)
+public final class MXMLUnclosedTagProblem extends ParserProblem
+{
+    public static final String DESCRIPTION =
+        "'${tokenText}' tag (or tag before this tag) is unclosed or tag not allowed here.";
+
+    public static final int errorCode = 1552;
+    
+    public MXMLUnclosedTagProblem(ISourceLocation site, String text)
+    {
+        super(site);
+        tokenText = text;
+    }
+    
+    public MXMLUnclosedTagProblem(ASToken site, String text) 
+    {
+        super(site);
+        tokenText = text;
+    }
+
+    public MXMLUnclosedTagProblem(ASToken token) 
+    {
+        this(token, token.getText());
+    }
+
+    public final String tokenText;
+
+}