You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by go...@apache.org on 2013/05/08 00:47:09 UTC
git commit: [flex-falcon] [refs/heads/develop] - Eliminated
IMXMLTagAttributeValue and IMXMLTextValue.
Updated Branches:
refs/heads/develop 2ecbdebb1 -> 310c37669
Eliminated IMXMLTagAttributeValue and IMXMLTextValue.
IMXMLTagAttributeData and IMXMLTextData are sufficient
because IMXMLData does not parse entities or databindings.
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/310c3766
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/310c3766
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/310c3766
Branch: refs/heads/develop
Commit: 310c37669f1bfe975db741e444730794c4343efa
Parents: 2ecbdeb
Author: Gordon Smith <go...@apache.org>
Authored: Tue May 7 15:45:49 2013 -0700
Committer: Gordon Smith <go...@apache.org>
Committed: Tue May 7 15:45:49 2013 -0700
----------------------------------------------------------------------
.../internal/mxml/MXMLTagAttributeData.java | 119 +++------------
.../internal/mxml/MXMLTagAttributeValue.java | 53 -------
.../flex/compiler/internal/mxml/MXMLTextValue.java | 82 ----------
.../internal/parsing/mxml/MXMLScopeBuilder.java | 11 +-
.../flex/compiler/mxml/IMXMLTagAttributeData.java | 8 -
.../flex/compiler/mxml/IMXMLTagAttributeValue.java | 43 -----
.../apache/flex/compiler/mxml/IMXMLTextValue.java | 28 ----
7 files changed, 26 insertions(+), 318 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/310c3766/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 e611e46..4a6cd07 100644
--- a/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTagAttributeData.java
+++ b/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTagAttributeData.java
@@ -19,7 +19,6 @@
package org.apache.flex.compiler.internal.mxml;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.ListIterator;
@@ -31,10 +30,7 @@ import org.apache.flex.compiler.filespecs.IFileSpecification;
import org.apache.flex.compiler.internal.parsing.ISourceFragment;
import org.apache.flex.compiler.internal.parsing.mxml.MXMLToken;
import org.apache.flex.compiler.mxml.IMXMLTagAttributeData;
-import org.apache.flex.compiler.mxml.IMXMLTagAttributeValue;
import org.apache.flex.compiler.mxml.IMXMLTagData;
-import org.apache.flex.compiler.mxml.IMXMLTextValue;
-import org.apache.flex.compiler.parsing.IMXMLToken;
import org.apache.flex.compiler.parsing.MXMLTokenTypes;
import org.apache.flex.compiler.problems.ICompilerProblem;
import org.apache.flex.compiler.problems.SyntaxProblem;
@@ -87,13 +83,12 @@ public class MXMLTagAttributeData extends SourceLocation implements
}
// Look for value token
- ArrayList<IMXMLTagAttributeValue> values = new ArrayList<IMXMLTagAttributeValue>(3);
while (tokenIterator.hasNext())
{
token = tokenIterator.next();
if (token.getType() == MXMLTokenTypes.TOKEN_STRING)
{
- values.add(new MXMLTextValue(token, this));
+ valueIncludingDelimiters = token.getText();
}
else
{
@@ -111,19 +106,6 @@ public class MXMLTagAttributeData extends SourceLocation implements
break;
}
}
-
- this.values = values.toArray(new MXMLTagAttributeValue[0]);
-
- if (this.values.length > 0)
- {
- //set the start value
- IMXMLTagAttributeValue value = this.values[0];
- valueStart = value.getAbsoluteStart();
- valueLine = value.getLine();
- valueColumn = value.getColumn();
- final int valueEnd = getValueEnd();
- setEnd(valueEnd + 1);
- }
}
/**
@@ -132,11 +114,26 @@ public class MXMLTagAttributeData extends SourceLocation implements
protected IMXMLTagData parent;
/**
+ * The URI specified by this attribute's prefix.
+ */
+ protected String uri;
+
+ /**
* The name of this attribute.
*/
protected String attributeName;
/**
+ * The offset at which the optional state starts.
+ */
+ protected int stateStart;
+
+ /**
+ * The attribute value, including any delimiters.
+ */
+ protected String valueIncludingDelimiters;
+
+ /**
* The offset at which the attribute value starts
*/
protected int valueStart;
@@ -152,25 +149,10 @@ public class MXMLTagAttributeData extends SourceLocation implements
protected int valueColumn;
/**
- * Array of values inside this attribute data.
- */
- private IMXMLTagAttributeValue[] values = new IMXMLTagAttributeValue[0];
-
- /**
* The name of this state, if it exists
*/
protected String stateName;
- /**
- * The offset at which the optional state starts
- */
- protected int stateStart;
-
- /**
- * The URI specified by this attribute's prefix.
- */
- protected String uri;
-
//
// Object overrides.
//
@@ -243,14 +225,7 @@ public class MXMLTagAttributeData extends SourceLocation implements
}
if (hasValue())
- {
valueStart += offsetAdjustment;
- for (int i = 0; i < values.length; i++)
- {
- ((MXMLTagAttributeValue)values[i]).setStart(values[i].getAbsoluteStart() + offsetAdjustment);
- ((MXMLTagAttributeValue)values[i]).setEnd(values[i].getAbsoluteEnd() + offsetAdjustment);
- }
- }
if (stateName != null)
stateStart += offsetAdjustment;
@@ -281,13 +256,7 @@ public class MXMLTagAttributeData extends SourceLocation implements
@Override
public boolean hasValue()
{
- return values.length > 0;
- }
-
- @Override
- public IMXMLTagAttributeValue[] getValues()
- {
- return values;
+ return getRawValue() != null;
}
/**
@@ -297,24 +266,7 @@ public class MXMLTagAttributeData extends SourceLocation implements
*/
public String getValueWithQuotes()
{
- StringBuilder value = new StringBuilder();
-
- final int size = values.length;
- IMXMLTagAttributeValue lastData = null;
- for (int i = 0; i < size; i++)
- {
- IMXMLTagAttributeValue data = values[i];
- if (lastData != null)
- {
- for (int s = 0; s < data.getAbsoluteStart() - lastData.getAbsoluteEnd(); i++)
- {
- value.append(" ");
- }
- }
- value.append(data.getContent());
- }
-
- return value.toString();
+ return valueIncludingDelimiters;
}
@Override
@@ -345,27 +297,6 @@ public class MXMLTagAttributeData extends SourceLocation implements
return EntityProcessor.parse(value, location, mxmlDialect, problems);
}
- /**
- * Returns the value of the raw token (without quotes) only if only one
- * value exists and it is a string value New clients should take into
- * account that multiple values exist inside of an attribute value
- *
- * @return a value token, or null
- */
- // TODO Rename to getValueToken()
- public IMXMLToken getRawValueToken()
- {
- if (hasState() && values.length == 1 && values[0] instanceof IMXMLTextValue)
- {
- String value = getRawValue();
- if (value != null)
- {
- return new MXMLToken(MXMLTokenTypes.TOKEN_STRING, getValueStart() + 1, getValueStart() + 1 + value.length(), -1, -1, value);
- }
- }
- return null;
- }
-
public IFileSpecification getSource()
{
return getParent().getSource();
@@ -416,14 +347,7 @@ public class MXMLTagAttributeData extends SourceLocation implements
public int getValueEnd()
{
if (hasValue())
- {
- String lastContent = values[values.length - 1].getContent();
-
- if (lastContent.charAt(0) == lastContent.charAt(lastContent.length() - 1))
- return getValueStart() + lastContent.length() - 2;
-
- return getValueStart() + lastContent.length();
- }
+ return getValueStart() + getRawValue().length();
// If there is no valid "end", then we must return -1. Callers depend on this.
// See MXMLTagData.findArttributeContainingOffset for an example
@@ -482,8 +406,9 @@ public class MXMLTagAttributeData extends SourceLocation implements
// it ends with the same quote character, it's well formed.
if (hasValue())
{
- String lastContent = values[values.length - 1].getContent();
- return (lastContent.charAt(0) == lastContent.charAt(lastContent.length() - 1));
+ char firstChar = valueIncludingDelimiters.charAt(0);
+ char lastChar = valueIncludingDelimiters.charAt(valueIncludingDelimiters.length() - 1);
+ return (firstChar == '"' || firstChar == '\'') && firstChar == lastChar;
}
return false;
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/310c3766/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTagAttributeValue.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTagAttributeValue.java b/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTagAttributeValue.java
deleted file mode 100644
index 994cf14..0000000
--- a/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTagAttributeValue.java
+++ /dev/null
@@ -1,53 +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.common.SourceLocation;
-import org.apache.flex.compiler.mxml.IMXMLTagAttributeData;
-import org.apache.flex.compiler.mxml.IMXMLTagAttributeValue;
-
-public abstract class MXMLTagAttributeValue extends SourceLocation implements
- IMXMLTagAttributeValue
-{
- /**
- * Constructor.
- */
- public MXMLTagAttributeValue(IMXMLTagAttributeData parent)
- {
- this.parent = parent;
-
- if (parent != null)
- setSourcePath(parent.getSourcePath());
- }
-
- /**
- * The MXML attribute that contains this unit
- */
- private IMXMLTagAttributeData parent;
-
- //
- // Other methods
- //
-
- public IMXMLTagAttributeData getContainingAttribute()
- {
- return parent;
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/310c3766/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTextValue.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTextValue.java b/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTextValue.java
deleted file mode 100644
index 790aa7a..0000000
--- a/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLTextValue.java
+++ /dev/null
@@ -1,82 +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.IMXMLTagAttributeData;
-import org.apache.flex.compiler.mxml.IMXMLTextValue;
-import org.apache.flex.compiler.mxml.IMXMLTextData.TextType;
-
-public class MXMLTextValue extends MXMLTagAttributeValue implements
- IMXMLTextValue
-{
- /**
- * Constructor.
- */
- MXMLTextValue(MXMLToken textToken, IMXMLTagAttributeData parent)
- {
- super(parent);
- setStart(textToken.getStart());
- setEnd(textToken.getEnd());
- setColumn(textToken.getColumn());
- setLine(textToken.getLine());
- text = textToken.getText();
- }
-
- private String text;
-
- //
- // Object overrides
- //
-
- /**
- * For debugging only. This format is nice in the Eclipse debugger.
- */
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append("|");
- sb.append(getContent());
- sb.append("| ");
- sb.append(getLine());
- sb.append(" ");
- sb.append(getColumn());
-
- return sb.toString();
- }
-
- //
- // IMXMLTextData implementations
- //
-
- @Override
- public String getContent()
- {
- return text;
- }
-
- @Override
- public TextType getTextType()
- {
- return TextType.TEXT;
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/310c3766/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLScopeBuilder.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLScopeBuilder.java b/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLScopeBuilder.java
index 8722e12..7687710 100644
--- a/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLScopeBuilder.java
+++ b/compiler/src/org/apache/flex/compiler/internal/parsing/mxml/MXMLScopeBuilder.java
@@ -57,7 +57,6 @@ import org.apache.flex.compiler.internal.workspaces.Workspace;
import org.apache.flex.compiler.mxml.IMXMLData;
import org.apache.flex.compiler.mxml.IMXMLTagAttributeData;
import org.apache.flex.compiler.mxml.IMXMLLanguageConstants;
-import org.apache.flex.compiler.mxml.IMXMLTagAttributeValue;
import org.apache.flex.compiler.mxml.IMXMLTagData;
import org.apache.flex.compiler.mxml.IMXMLTextData;
import org.apache.flex.compiler.mxml.IMXMLTextData.TextType;
@@ -276,9 +275,8 @@ public class MXMLScopeBuilder
if (definitionName == null)
{
definitionName = attr.getRawValue();
- IMXMLTagAttributeValue[] values = attr.getValues();
- nameStart = values[0].getAbsoluteStart() + 1; //attr.getValueStart();
- nameEnd = values[values.length - 1].getAbsoluteEnd() - 1; // attr.getValueEnd();
+ nameStart = attr.getValueStart() + 1;
+ nameEnd = attr.getValueEnd() - 1;
}
// TODO create problem if definition name has already been set.
}
@@ -591,9 +589,8 @@ public class MXMLScopeBuilder
if (className == null)
{
className = attr.getRawValue();
- IMXMLTagAttributeValue[] values = attr.getValues();
- nameStart = values[0].getAbsoluteStart() + 1; //attr.getValueStart();
- nameEnd = values[values.length - 1].getAbsoluteEnd() - 1; // attr.getValueEnd();
+ nameStart = attr.getValueStart() + 1;
+ nameEnd = attr.getValueEnd() - 1;
}
// TODO create problem if className has already been set.
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/310c3766/compiler/src/org/apache/flex/compiler/mxml/IMXMLTagAttributeData.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/mxml/IMXMLTagAttributeData.java b/compiler/src/org/apache/flex/compiler/mxml/IMXMLTagAttributeData.java
index 3c9cf41..899340c 100644
--- a/compiler/src/org/apache/flex/compiler/mxml/IMXMLTagAttributeData.java
+++ b/compiler/src/org/apache/flex/compiler/mxml/IMXMLTagAttributeData.java
@@ -113,14 +113,6 @@ public interface IMXMLTagAttributeData extends ISourceLocation
boolean hasValue();
/**
- * Returns an array of {@code IMXMLTagAttributeValue} objects representing
- * the various parts of value of this attribute.
- *
- * @return An array of {@code IMXMLTagAttributeValue} objects.
- */
- IMXMLTagAttributeValue[] getValues();
-
- /**
* Gets the value of this attribute as a String.
* <p>
* The delimiting quotes are not included.
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/310c3766/compiler/src/org/apache/flex/compiler/mxml/IMXMLTagAttributeValue.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/mxml/IMXMLTagAttributeValue.java b/compiler/src/org/apache/flex/compiler/mxml/IMXMLTagAttributeValue.java
deleted file mode 100644
index 500ce76..0000000
--- a/compiler/src/org/apache/flex/compiler/mxml/IMXMLTagAttributeValue.java
+++ /dev/null
@@ -1,43 +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;
-
-import org.apache.flex.compiler.common.ISourceLocation;
-import org.apache.flex.compiler.mxml.IMXMLTextData.TextType;
-
-/**
- * Represents an attribute value in MXML.
- */
-public interface IMXMLTagAttributeValue extends ISourceLocation
-{
- /**
- * Gets the type of text for this part of the attribute value.
- *
- * @return A {@link TextType} value.
- */
- TextType getTextType();
-
- /**
- * Gets the content of thsi part of the attribute value.
- *
- * @return The content as a <code>String</code>.
- */
- String getContent();
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/310c3766/compiler/src/org/apache/flex/compiler/mxml/IMXMLTextValue.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/mxml/IMXMLTextValue.java b/compiler/src/org/apache/flex/compiler/mxml/IMXMLTextValue.java
deleted file mode 100644
index 117a5bc..0000000
--- a/compiler/src/org/apache/flex/compiler/mxml/IMXMLTextValue.java
+++ /dev/null
@@ -1,28 +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 text attribute value in MXML.
- */
-public interface IMXMLTextValue extends IMXMLTagAttributeValue
-{
-
-}