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 2017/07/12 23:08:53 UTC
[2/4] git commit: [flex-falcon] [refs/heads/develop] - find a
workaround to hanging on unclosed last XML tag
find a workaround to hanging on unclosed last XML tag
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/2a78c286
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/2a78c286
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/2a78c286
Branch: refs/heads/develop
Commit: 2a78c286aa9d3a8228340bbde21e3bacb1397dbc
Parents: e409441
Author: Alex Harui <ah...@apache.org>
Authored: Tue Jul 11 14:08:50 2017 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Wed Jul 12 16:08:42 2017 -0700
----------------------------------------------------------------------
.../internal/parsing/mxml/MXMLTokenizer.java | 46 ++++++++++++--------
1 file changed, 27 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2a78c286/compiler/src/main/java/org/apache/flex/compiler/internal/parsing/mxml/MXMLTokenizer.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/parsing/mxml/MXMLTokenizer.java b/compiler/src/main/java/org/apache/flex/compiler/internal/parsing/mxml/MXMLTokenizer.java
index 51718ca..c476566 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/internal/parsing/mxml/MXMLTokenizer.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/internal/parsing/mxml/MXMLTokenizer.java
@@ -39,6 +39,8 @@ import org.apache.flex.compiler.parsing.IMXMLTokenizer;
import org.apache.flex.compiler.parsing.MXMLTokenTypes;
import org.apache.flex.compiler.problems.ICompilerProblem;
import org.apache.flex.compiler.problems.InternalCompilerProblem2;
+import org.apache.flex.compiler.problems.MXMLUnclosedTagProblem;
+import org.apache.flex.compiler.problems.UnexpectedTokenProblem;
import org.apache.flex.utils.NonLockingStringReader;
/**
@@ -201,26 +203,18 @@ public class MXMLTokenizer implements IMXMLTokenizer, Closeable
* @return an {@link MXMLToken} or null when no more tokens can be produced
*/
private final MXMLToken nextTokenInternal() {
- MXMLToken retVal = null;
- boolean cont = true;
- while(cont) {
- try
- {
- MXMLToken token = tokenizer.hasBufferToken() ? (MXMLToken)tokenizer.getBufferToken() : (MXMLToken)tokenizer.nextToken();
- if(token == null)
- return null;
- MXMLToken mxmlToken = processToken(token);
- if(mxmlToken != null) {
- retVal = mxmlToken;
- return retVal;
- }
- }
- catch (Exception e)
- {
- ICompilerProblem problem = new InternalCompilerProblem2(path, e, SUB_SYSTEM);
- problems.add(problem);
+ try
+ {
+ MXMLToken token = tokenizer.hasBufferToken() ? (MXMLToken)tokenizer.getBufferToken() : (MXMLToken)tokenizer.nextToken();
+ if(token == null)
return null;
- }
+ MXMLToken mxmlToken = processToken(token);
+ return mxmlToken;
+ }
+ catch (Exception e)
+ {
+ ICompilerProblem problem = new InternalCompilerProblem2(path, e, SUB_SYSTEM);
+ problems.add(problem);
}
return null;
}
@@ -339,6 +333,20 @@ public class MXMLTokenizer implements IMXMLTokenizer, Closeable
* @return an {@link MXMLToken} or null if it was not accepted
*/
private MXMLToken processToken(final MXMLToken token) {
+
+ if (lastToken != null && lastToken.getType() == MXMLTokenTypes.TOKEN_CLOSE_TAG_START &&
+ token.getType() != MXMLTokenTypes.TOKEN_TAG_END)
+ {
+ // once we hit this condition, we currently stop parsing.
+ // There is a condition where the last closing tag of the file in unclosed
+ // as in "<js:Application" (no closing ">") and the lexer
+ // can't seem to detect that and stop lexing. Yes, this means that
+ // if a bad closing tag occurs higher up in the file we'll bail
+ // and not report errors later in the file, but that's better than
+ // hanging, IMO.
+ problems.add(new MXMLUnclosedTagProblem(token, lastToken.getText()));
+ return null;
+ }
//TODO find xmlns uri values in the lexer instead of here
switch (token.getType())
{