Updated Branches: refs/heads/develop a82dbc12b -> 0cf1d9c72
Removed support for MXML "tag blobs". This was a old performance optimization from when CodeModel and the old compiler were separate parts of FlashBuilder. It allowed CodeModel's MXML lexer/parser to skip over the contents of an <fx:Private> tag. But allowing an <fx:Private> tag to have malformed content is antithetical to the idea of MXML being XML. Falcon is both a compiler and a code intelligence engine, and it must check the lexical structure of the entire MXML file. This gets rid of - PrivateTagDetector and its interface ITagAggregateDector - TOKEN_MXML_BLOB - MXMLTagBlobData and its interface IMXMLTagBlobData Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/6b4f37ae Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/6b4f37ae Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/6b4f37ae Branch: refs/heads/develop Commit: 6b4f37ae25ada689b1a3fd624966eb08f1c7fd00 Parents: 6fd38b4 Author: Gordon Smith <[email protected]> Authored: Fri Apr 19 21:19:59 2013 -0700 Committer: Gordon Smith <[email protected]> Committed: Fri Apr 19 21:19:59 2013 -0700 ---------------------------------------------------------------------- .../flex/compiler/internal/mxml/MXMLData.java | 13 --- .../compiler/internal/mxml/MXMLTagBlobData.java | 66 --------------- .../parsing/mxml/ITagAggregateDetector.java | 42 --------- .../compiler/internal/parsing/mxml/MXMLToken.java | 5 - .../internal/parsing/mxml/MXMLTokenizer.java | 17 ---- .../internal/parsing/mxml/PrivateTagDetector.java | 61 ------------- .../internal/parsing/mxml/RawMXMLTokenizer.lex | 51 +---------- .../flex/compiler/mxml/IMXMLTagBlobData.java | 37 -------- .../apache/flex/compiler/parsing/IMXMLToken.java | 5 - .../flex/compiler/parsing/MXMLTokenTypes.java | 5 - 10 files changed, 4 insertions(+), 298 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6b4f37ae/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLData.java ---------------------------------------------------------------------- diff --git a/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLData.java b/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLData.java index 43b3f11..ac2adc2 100644 --- a/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLData.java +++ b/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLData.java @@ -589,19 +589,6 @@ public class MXMLData implements IMXMLData break; } - case MXMLTokenTypes.TOKEN_MXML_BLOB: - { - unit = new MXMLTagBlobData(token); - units.add(unit); - index++; - if (fullContent) - { - unit.setParentUnitDataIndex(depth.peek()); - unit.setLocation(data, index); - } - break; - } - case MXMLTokenTypes.TOKEN_PROCESSING_INSTRUCTION: { unit = new MXMLInstructionData(token); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6b4f37ae/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTagBlobData.java ---------------------------------------------------------------------- diff --git a/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTagBlobData.java b/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTagBlobData.java deleted file mode 100644 index 78b167d..0000000 --- a/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTagBlobData.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * 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.internal.mxml; - -import org.apache.flex.compiler.internal.parsing.mxml.MXMLToken; -import org.apache.flex.compiler.mxml.IMXMLTagBlobData; - -/** - * An MXML blob is a large chunk of MXML data that was passed over during - * tokenization. A blob, for example could be the contents of an fx:Private tag. - */ -public class MXMLTagBlobData extends MXMLUnitData implements IMXMLTagBlobData -{ - /** - * Constructor. - * - * @param token - */ - MXMLTagBlobData(MXMLToken token) - { - String text = token.getText(); - int length = text.length(); - int pos = 1; - while (pos < length) - { - if (Character.isWhitespace(text.charAt(pos))) - break; - pos++; - } - name = text.substring(1, pos - 1); - - setStart(token.getStart()); - setEnd(token.getEnd()); - setLine(token.getLine()); - setColumn(token.getColumn()); - } - - private String name; - - // - // IMXMLTagBlobData implementations - // - - @Override - public String getName() - { - return name; - } -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6b4f37ae/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/ITagAggregateDetector.java ---------------------------------------------------------------------- diff --git a/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/ITagAggregateDetector.java b/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/ITagAggregateDetector.java deleted file mode 100644 index f5b6882..0000000 --- a/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/ITagAggregateDetector.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * 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.internal.parsing.mxml; - -import antlr.Token; - -/** - * Interface used by the tokenizer to detect tokens that begin and end a tag - * (such as {@code <Private>} in MXML 2009) whose contents should be aggregated - * by the tokenizer into a single <code>TOKEN_MXML_BLOB</code> token. - */ -public interface ITagAggregateDetector -{ - /** - * Called on an <code>TOKEN_OPEN_TAG_START</code> token - * to determine whether an aggregated tag is starting. - */ - boolean shouldStartAggregate(Token token); - - /** - * Called on an <code>TOKEN_CLOSE_TAG_START</code> token - * to determine whether an aggregated tag is ending. - */ - boolean shouldEndAggregate(Token token); -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6b4f37ae/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLToken.java ---------------------------------------------------------------------- diff --git a/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLToken.java b/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLToken.java index be8e24b..62cd7fc 100644 --- a/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLToken.java +++ b/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLToken.java @@ -85,8 +85,6 @@ public class MXMLToken extends ASToken implements IMXMLToken return MXMLTokenKind.TAG_END; case MXMLTokenTypes.TOKEN_EMPTY_TAG_END: return MXMLTokenKind.EMPTY_TAG_END; - case MXMLTokenTypes.TOKEN_MXML_BLOB: - return MXMLTokenKind.MXML_BLOB; case MXMLTokenTypes.TOKEN_NAME: return MXMLTokenKind.NAME; case MXMLTokenTypes.TOKEN_EQUALS: @@ -182,7 +180,6 @@ public class MXMLToken extends ASToken implements IMXMLToken case MXMLTokenTypes.TOKEN_PROCESSING_INSTRUCTION: case MXMLTokenTypes.TOKEN_COMMENT: case MXMLTokenTypes.TOKEN_ASDOC_COMMENT: - case MXMLTokenTypes.TOKEN_MXML_BLOB: case MXMLTokenTypes.TOKEN_TEXT: case MXMLTokenTypes.TOKEN_CDATA: case MXMLTokenTypes.TOKEN_OPEN_TAG_START: @@ -232,8 +229,6 @@ public class MXMLToken extends ASToken implements IMXMLToken return "TOKEN_ASDOC_COMMENT"; case MXMLTokenTypes.TOKEN_COMMENT: return "TOKEN_COMMENT"; - case MXMLTokenTypes.TOKEN_MXML_BLOB : - return "MXML_BLOB"; case MXMLTokenTypes.TOKEN_PROCESSING_INSTRUCTION: return "TOKEN_PROCESSING_INSTRUCTION"; default: http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6b4f37ae/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLTokenizer.java ---------------------------------------------------------------------- diff --git a/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLTokenizer.java b/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLTokenizer.java index 67c4ed7..14dc8b2 100644 --- a/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLTokenizer.java +++ b/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLTokenizer.java @@ -62,8 +62,6 @@ public class MXMLTokenizer implements IMXMLTokenizer, Closeable private boolean inTagContent = false; private RawMXMLTokenizer tokenizer; - - private PrivateTagDetector detector; protected MXMLToken xmlNSToken = null; @@ -92,7 +90,6 @@ public class MXMLTokenizer implements IMXMLTokenizer, Closeable { tokenizer = new RawMXMLTokenizer(); problems = new ArrayList<ICompilerProblem>(); - setDetector(new PrivateTagDetector()); rootPrefixMap = new MutablePrefixMap(); this.path = path; } @@ -153,15 +150,6 @@ public class MXMLTokenizer implements IMXMLTokenizer, Closeable this.isRepairing = isRepairing; } - protected void setDetector(PrivateTagDetector detector) { - this.detector = detector; - // fTokenizer.setTagAggregateDetector(fDetector); - } - - protected void addPrefix(String prefix, String ns) { - detector.addPrefix(prefix, ns); - } - @Override public IMXMLToken[] getTokens(Reader reader) { List<MXMLToken> parseTokens = parseTokens(reader); @@ -291,7 +279,6 @@ public class MXMLTokenizer implements IMXMLTokenizer, Closeable return list; } finally { try { - detector = null; tokenizer.yyclose(); } catch (IOException e) { ICompilerProblem problem = new InternalCompilerProblem2(path, e, SUB_SYSTEM); @@ -312,7 +299,6 @@ public class MXMLTokenizer implements IMXMLTokenizer, Closeable case MXMLTokenTypes.TOKEN_PROCESSING_INSTRUCTION: case MXMLTokenTypes.TOKEN_COMMENT: case MXMLTokenTypes.TOKEN_ASDOC_COMMENT: - case MXMLTokenTypes.TOKEN_MXML_BLOB: case MXMLTokenTypes.TOKEN_STRING: case MXMLTokenTypes.TOKEN_TEXT: case MXMLTokenTypes.TOKEN_CDATA: @@ -376,7 +362,6 @@ public class MXMLTokenizer implements IMXMLTokenizer, Closeable // stuff inside tags case MXMLTokenTypes.TOKEN_EQUALS: //outside tags - case MXMLTokenTypes.TOKEN_MXML_BLOB: case MXMLTokenTypes.TOKEN_CDATA: return token; case MXMLTokenTypes.TOKEN_NAME: @@ -399,8 +384,6 @@ public class MXMLTokenizer implements IMXMLTokenizer, Closeable String ns = nsText.length() > 1 ? nsText.substring(1, nsText.length() -1) : ""; rootPrefixMap.add(prefix, ns); - if(detector != null) - detector.addPrefix(prefix, ns); } return token; // stuff outside tags http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6b4f37ae/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/PrivateTagDetector.java ---------------------------------------------------------------------- diff --git a/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/PrivateTagDetector.java b/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/PrivateTagDetector.java deleted file mode 100644 index 8f13893..0000000 --- a/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/PrivateTagDetector.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * 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.internal.parsing.mxml; - -import antlr.Token; - -import org.apache.flex.compiler.internal.mxml.MXMLDialect; -import org.apache.flex.compiler.mxml.IMXMLLanguageConstants; - -/** - * Detects the tokens that start and end a <Private> tag. - */ -public class PrivateTagDetector implements ITagAggregateDetector -{ - public PrivateTagDetector() - { - } - - private String expectedStartTokenText; // typically "<fx:Private" - private String expectedEndTokenText; // typically "</fx:Private> - - public void addPrefix(String prefix, String ns) - { - if (MXMLDialect.isLanguageNamespace(ns)) - { - expectedStartTokenText = "<" + prefix + ":" + IMXMLLanguageConstants.PRIVATE; - expectedEndTokenText = "</" + prefix + ":" + IMXMLLanguageConstants.PRIVATE + ">"; - } - } - - @Override - public boolean shouldStartAggregate(Token token) - { - String tokenText = token.getText(); - return tokenText.equals(expectedStartTokenText); - } - - @Override - public boolean shouldEndAggregate(Token token) - { - String tokenText = token.getText(); - return tokenText.equals(expectedEndTokenText); - } -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6b4f37ae/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/RawMXMLTokenizer.lex ---------------------------------------------------------------------- diff --git a/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/RawMXMLTokenizer.lex b/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/RawMXMLTokenizer.lex index 8ec1a56..4c3a6f6 100644 --- a/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/RawMXMLTokenizer.lex +++ b/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/RawMXMLTokenizer.lex @@ -41,8 +41,6 @@ import static org.apache.flex.compiler.parsing.MXMLTokenTypes.*; */ protected int bracketLevel; -private ITagAggregateDetector detector = null; - /** * Get the current column of the tokenizer. */ @@ -97,17 +95,12 @@ protected final void fillBuffer(StringBuilder builder) builder.append(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead); } -public void setTagAggregateDetector(ITagAggregateDetector detector) -{ - this.detector = detector; -} - %} %char %line %column -%state CDATA, COMMENT, ASDOC_COMMENT, DIRECTIVE, MARKUP, STRING1, STRING2, MARKUP_IGNORE, STRING1_IGNORE, STRING2_IGNORE, TAG_AGGREGATION, WHITESPACE +%state CDATA, COMMENT, ASDOC_COMMENT, DIRECTIVE, MARKUP, STRING1, STRING2, MARKUP_IGNORE, STRING1_IGNORE, STRING2_IGNORE, WHITESPACE %class RawMXMLTokenizer %function nextToken %type Token @@ -182,16 +175,8 @@ WHITE_SPACE_CHAR=[\r\n\ \t\b\012] <YYINITIAL> ("<"{ID}) { Token token = buildToken(TOKEN_OPEN_TAG_START); - if (detector != null && detector.shouldStartAggregate(token)) - { - startAggregate(token); - yybegin(TAG_AGGREGATION); - } - else - { - yybegin(MARKUP); - return token; - } + yybegin(MARKUP); + return token; } <YYINITIAL> ("</"{ID}) @@ -526,34 +511,6 @@ WHITE_SPACE_CHAR=[\r\n\ \t\b\012] } // -// The TAG_AGGREGATION state handles special tags like <fx:Private> -// whose contents are treated as a blob for performance reasons. -// It builds a single TOKEN_MXML_BLOB token before returning -// to the initial state. -// - -<TAG_AGGREGATION> ("</"{ID}">") -{ - Token token = buildToken(TOKEN_CLOSE_TAG_START); - continueAggregate(token); - if (detector.shouldEndAggregate(token)) - { - yybegin(YYINITIAL); - return buildAggregateToken(TOKEN_MXML_BLOB); - } -} - -<TAG_AGGREGATION> {WHITE_SPACE_CHAR}+ -{ - continueAggregate(); -} - -<TAG_AGGREGATION> . -{ - continueAggregate(); -} - -// // The CATA state handles a CDATA block such as // <![CDATA[File > New]]> // It builds a single TOKEN_CDATA token @@ -598,6 +555,6 @@ WHITE_SPACE_CHAR=[\r\n\ \t\b\012] // Just ignore anything we don't recognize // -<YYINITIAL, MARKUP, STRING1, STRING2, MARKUP_IGNORE, STRING1_IGNORE, STRING2_IGNORE, TAG_AGGREGATION> . +<YYINITIAL, MARKUP, STRING1, STRING2, MARKUP_IGNORE, STRING1_IGNORE, STRING2_IGNORE> . { } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6b4f37ae/compiler/src/org/apache/flex/compiler/mxml/IMXMLTagBlobData.java ---------------------------------------------------------------------- diff --git a/compiler/src/org/apache/flex/compiler/mxml/IMXMLTagBlobData.java b/compiler/src/org/apache/flex/compiler/mxml/IMXMLTagBlobData.java deleted file mode 100644 index 7ea9e1e..0000000 --- a/compiler/src/org/apache/flex/compiler/mxml/IMXMLTagBlobData.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * 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.mxml; - -/** - * Represents a blob of MXML. - * <p> - * An MXML blob is a large chunk of MXML data that was passed over during - * tokenization. A blob, for example could be the contents of an - * <code><fx:Private> tag. - */ -public interface IMXMLTagBlobData extends IMXMLUnitData -{ - /** - * Gets the content of the blob. - * - * @return The blob's content as a <code>String</code>. - */ - String getName(); -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6b4f37ae/compiler/src/org/apache/flex/compiler/parsing/IMXMLToken.java ---------------------------------------------------------------------- diff --git a/compiler/src/org/apache/flex/compiler/parsing/IMXMLToken.java b/compiler/src/org/apache/flex/compiler/parsing/IMXMLToken.java index 30821a7..bec8f50 100644 --- a/compiler/src/org/apache/flex/compiler/parsing/IMXMLToken.java +++ b/compiler/src/org/apache/flex/compiler/parsing/IMXMLToken.java @@ -80,11 +80,6 @@ public interface IMXMLToken extends ICMToken CDATA, /** - * A large chunk of untokenized MXML data - */ - MXML_BLOB, - - /** * An ActionScript token */ ACTIONSCRIPT, http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6b4f37ae/compiler/src/org/apache/flex/compiler/parsing/MXMLTokenTypes.java ---------------------------------------------------------------------- diff --git a/compiler/src/org/apache/flex/compiler/parsing/MXMLTokenTypes.java b/compiler/src/org/apache/flex/compiler/parsing/MXMLTokenTypes.java index c87a4f8..62f9796 100644 --- a/compiler/src/org/apache/flex/compiler/parsing/MXMLTokenTypes.java +++ b/compiler/src/org/apache/flex/compiler/parsing/MXMLTokenTypes.java @@ -140,9 +140,4 @@ public interface MXMLTokenTypes * Example: {@code xmlns} */ public static final int TOKEN_XMLNS = 14; - - /** - * TODO: Eliminate this. - */ - public static final int TOKEN_MXML_BLOB = 15; }
