You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2024/02/28 23:05:46 UTC
(royale-compiler) 02/02: IMXMLStyleNode: getContentStart() to indicate where the CSS text starts within the tag
This is an automated email from the ASF dual-hosted git repository.
joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
commit bdcb50cb1a4cfda4c666acfcef78701e85a4fa2b
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Wed Feb 28 15:05:28 2024 -0800
IMXMLStyleNode: getContentStart() to indicate where the CSS text starts within the <fx:Style> tag
---
.../compiler/internal/tree/mxml/MXMLStyleNode.java | 17 +++++++++++++----
.../royale/compiler/tree/mxml/IMXMLStyleNode.java | 6 ++++++
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLStyleNode.java b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLStyleNode.java
index 5d40c7e64..18a926b47 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLStyleNode.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLStyleNode.java
@@ -64,7 +64,8 @@ class MXMLStyleNode extends MXMLNodeBase implements IMXMLStyleNode
*/
private String cssText;
- private int cssTextStart = 0;
+ private int cssContentStart = -1;
+ private int cssCharPos = -1;
/**
* path of included css.
@@ -84,6 +85,12 @@ class MXMLStyleNode extends MXMLNodeBase implements IMXMLStyleNode
return IMXMLLanguageConstants.STYLE;
}
+ @Override
+ public int getContentStart()
+ {
+ return cssContentStart;
+ }
+
@Override
public ICSSDocument getCSSDocument(final Collection<ICompilerProblem> problems)
{
@@ -94,7 +101,7 @@ class MXMLStyleNode extends MXMLNodeBase implements IMXMLStyleNode
ANTLRStringStream stream = new ANTLRStringStream(cssText);
stream.name = cssSourcePath != null ? cssSourcePath : getSourcePath();
stream.setLine(getLine());
- stream.setCharPositionInLine(cssTextStart);
+ stream.setCharPositionInLine(cssCharPos);
cssDocument = CSSDocument.parse(stream, problems);
}
else
@@ -126,7 +133,8 @@ class MXMLStyleNode extends MXMLNodeBase implements IMXMLStyleNode
if (sourcePath != null)
{
cssText = builder.readExternalFile(attribute, sourcePath);
- cssTextStart = 0;
+ cssCharPos = -1;
+ cssContentStart = -1;
cssSourcePath = sourcePath;
}
}
@@ -161,7 +169,8 @@ class MXMLStyleNode extends MXMLNodeBase implements IMXMLStyleNode
if (cssText == null)
{
cssText = tag.getCompilableText();
- cssTextStart = tag.getEndColumn() + 1;
+ cssCharPos = tag.getEndColumn() + 1;
+ cssContentStart = tag.getEnd();
}
// Register this "style" node with the root "MXMLFileNode".
diff --git a/compiler/src/main/java/org/apache/royale/compiler/tree/mxml/IMXMLStyleNode.java b/compiler/src/main/java/org/apache/royale/compiler/tree/mxml/IMXMLStyleNode.java
index aa80d624a..47b15806a 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/tree/mxml/IMXMLStyleNode.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/tree/mxml/IMXMLStyleNode.java
@@ -40,4 +40,10 @@ public interface IMXMLStyleNode extends IMXMLNode
* @return An {@link ICSSDocument} object.
*/
ICSSDocument getCSSDocument(Collection<ICompilerProblem> problems);
+
+ /**
+ * Gets the start position of the CSS text content. Returns -1 if the
+ * <code><Style></code> tag has a <code>source</code> attribute.
+ */
+ public int getContentStart();
}