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
The following commit(s) were added to refs/heads/develop by this push:
new 5b58be7 compiler: fixed end line/column values that are missing or
lost in MXML
5b58be7 is described below
commit 5b58be7c5f76f35b9397307e63b500c620fa37a5
Author: Josh Tynjala <[email protected]>
AuthorDate: Mon Apr 16 14:41:22 2018 -0700
compiler: fixed end line/column values that are missing or lost in MXML
---
.../internal/mxml/MXMLTagAttributeData.java | 3 +-
.../royale/compiler/internal/mxml/MXMLTagData.java | 6 +++-
.../internal/parsing/SourceFragmentsReader.java | 10 ++++++
.../internal/tree/mxml/MXMLDataBindingParser.java | 3 +-
.../compiler/internal/tree/mxml/MXMLNodeBase.java | 41 +++++++++++++++++++---
5 files changed, 55 insertions(+), 8 deletions(-)
diff --git
a/compiler/src/main/java/org/apache/royale/compiler/internal/mxml/MXMLTagAttributeData.java
b/compiler/src/main/java/org/apache/royale/compiler/internal/mxml/MXMLTagAttributeData.java
index 6299f62..e88b9e0 100644
---
a/compiler/src/main/java/org/apache/royale/compiler/internal/mxml/MXMLTagAttributeData.java
+++
b/compiler/src/main/java/org/apache/royale/compiler/internal/mxml/MXMLTagAttributeData.java
@@ -340,7 +340,8 @@ public class MXMLTagAttributeData extends SourceLocation
implements IMXMLTagAttr
@Override
public SourceLocation getValueLocation()
{
- return new SourceLocation(getSourcePath(), getValueStart(),
getValueEnd(), getValueLine(), getValueColumn());
+ return new SourceLocation(getSourcePath(), getValueStart(),
getValueEnd(), getValueLine(), getValueColumn(),
+ getValueLine(), getValueColumn() + getValueEnd() -
getValueStart());
}
//
diff --git
a/compiler/src/main/java/org/apache/royale/compiler/internal/mxml/MXMLTagData.java
b/compiler/src/main/java/org/apache/royale/compiler/internal/mxml/MXMLTagData.java
index a8a85ac..3404f46 100644
---
a/compiler/src/main/java/org/apache/royale/compiler/internal/mxml/MXMLTagData.java
+++
b/compiler/src/main/java/org/apache/royale/compiler/internal/mxml/MXMLTagData.java
@@ -1050,6 +1050,8 @@ public class MXMLTagData extends MXMLUnitData implements
IMXMLTagData
int end = getEnd();
int line = getLine();
int column = getColumn();
+ int endLine = getEndLine();
+ int endColumn = getEndColumn();
boolean foundFirstChild = false;
@@ -1061,6 +1063,8 @@ public class MXMLTagData extends MXMLUnitData implements
IMXMLTagData
start = unit.getStart();
line = unit.getLine();
column = unit.getColumn();
+ endLine = unit.getEndLine();
+ endColumn = unit.getEndColumn();
foundFirstChild = true;
}
@@ -1068,7 +1072,7 @@ public class MXMLTagData extends MXMLUnitData implements
IMXMLTagData
end = unit.getEnd();
}
- return new SourceLocation(sourcePath, start, end, line, column);
+ return new SourceLocation(sourcePath, start, end, line, column,
endLine, endColumn);
}
/**
diff --git
a/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/SourceFragmentsReader.java
b/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/SourceFragmentsReader.java
index 84e6a50..ac7b90c 100644
---
a/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/SourceFragmentsReader.java
+++
b/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/SourceFragmentsReader.java
@@ -151,6 +151,16 @@ public class SourceFragmentsReader extends StringReader
int logicalColumn = token.getColumn();
int physicalColumn = logicalColumn +
sourceFragments[i].getPhysicalColumn();
token.setColumn(physicalColumn);
+
+ // Convert token's 'end line' from logical to physical.
+ int logicalEndLine = token.getEndLine();
+ int physicalEndLine = logicalEndLine +
sourceFragments[i].getPhysicalLine();
+ token.setEndLine(physicalEndLine);
+
+ // Convert token's 'end column' from logical to physical.
+ int logicalEndColumn = token.getEndColumn();
+ int physicalEndColumn = logicalEndColumn +
sourceFragments[i].getPhysicalColumn();
+ token.setEndColumn(physicalEndColumn);
}
private int getFragmentIndexForStart(int start)
diff --git
a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLDataBindingParser.java
b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLDataBindingParser.java
index d5c4ac3..8a6e45a 100644
---
a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLDataBindingParser.java
+++
b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLDataBindingParser.java
@@ -282,7 +282,8 @@ class MXMLDataBindingParser
node.setLocation(sourceLocation.getSourcePath(),
sourceLocation.getAbsoluteStart(),
sourceLocation.getAbsoluteEnd(),
- sourceLocation.getLine(), sourceLocation.getColumn());
+ sourceLocation.getLine(), sourceLocation.getColumn(),
+ sourceLocation.getEndLine(),
sourceLocation.getEndColumn());
// Build a list of children for the MXMLConcatenatedDataBindingNode.
List<IASNode> children = new ArrayList<IASNode>();
diff --git
a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLNodeBase.java
b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLNodeBase.java
index ec49d85..4909e2e 100644
---
a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLNodeBase.java
+++
b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLNodeBase.java
@@ -700,6 +700,27 @@ public abstract class MXMLNodeBase extends NodeBase
implements IMXMLNode
}
/**
+ * Sets the start/end/line/column/endLine/endColumn location information
for this node.
+ *
+ * @param start The starting offset of this node.
+ * @param end The ending offset of this node.
+ * @param line The number of the line on which this node starts.
+ * @param column This number of the column at which this node starts.
+ * @param endLine The number of the line on which this node ends.
+ * @param endColumn This number of the column at which this node ends.
+ */
+ public void setLocation(String sourcePath, int start, int end, int line,
int column, int endLine, int endColumn)
+ {
+ setSourcePath(sourcePath);
+ setStart(start);
+ setEnd(end);
+ setLine(line);
+ setColumn(column);
+ setEndLine(endLine);
+ setEndColumn(endColumn);
+ }
+
+ /**
* Sets the start/end/line/column location information for this node.
*
* @param location A {@link SourceLocation} object.
@@ -711,8 +732,10 @@ public abstract class MXMLNodeBase extends NodeBase
implements IMXMLNode
int end = location.getEnd();
int line = location.getLine();
int column = location.getColumn();
+ int endLine = location.getEndLine();
+ int endColumn = location.getEndColumn();
- setLocation(sourcePath, start, end, line, column);
+ setLocation(sourcePath, start, end, line, column, endLine, endColumn);
}
/**
@@ -737,8 +760,10 @@ public abstract class MXMLNodeBase extends NodeBase
implements IMXMLNode
}
int line = unit.getLine();
int column = unit.getColumn();
+ int endLine = unit.getEndLine();
+ int endColumn = unit.getEndColumn();
- setLocation(sourcePath, start, end, line, column);
+ setLocation(sourcePath, start, end, line, column, endLine, endColumn);
}
/**
@@ -753,8 +778,10 @@ public abstract class MXMLNodeBase extends NodeBase
implements IMXMLNode
int end = attribute.getAbsoluteEnd();
int line = attribute.getLine();
int column = attribute.getColumn();
+ int endLine = attribute.getEndLine();
+ int endColumn = attribute.getEndColumn();
- setLocation(sourcePath, start, end, line, column);
+ setLocation(sourcePath, start, end, line, column, endLine, endColumn);
}
/**
@@ -785,8 +812,10 @@ public abstract class MXMLNodeBase extends NodeBase
implements IMXMLNode
int end = lastUnit.getEnd();
int line = firstUnit.getLine();
int column = firstUnit.getColumn();
+ int endLine = lastUnit.getEndLine();
+ int endColumn = lastUnit.getEndColumn();
- setLocation(sourcePath, start, end, line, column);
+ setLocation(sourcePath, start, end, line, column, endLine, endColumn);
adjustOffsets(builder);
}
@@ -936,8 +965,10 @@ public abstract class MXMLNodeBase extends NodeBase
implements IMXMLNode
int end = lastFragment.getPhysicalStart() +
lastFragment.getPhysicalText().length();
int line = firstFragment.getPhysicalLine();
int column = firstFragment.getPhysicalColumn();
+ int endLine = lastFragment.getPhysicalLine();
+ int endColumn = lastFragment.getPhysicalColumn() +
lastFragment.getPhysicalText().length();
- return new SourceLocation(sourcePath, start, end, line, column);
+ return new SourceLocation(sourcePath, start, end, line, column,
endLine, endColumn);
}
/**
--
To stop receiving notification emails like this one, please contact
[email protected].