You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jo...@apache.org on 2016/04/18 08:27:32 UTC
[7/9] git commit: [flex-falcon] [refs/heads/develop] - compiler:
added getEndLine() and getEndColumn() to ISourceLocation
compiler: added getEndLine() and getEndColumn() to ISourceLocation
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/af3e883d
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/af3e883d
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/af3e883d
Branch: refs/heads/develop
Commit: af3e883d75a1e270d2174e35007f48698822085c
Parents: b2bfa2c
Author: Josh Tynjala <jo...@apache.org>
Authored: Sun Apr 17 22:44:59 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Sun Apr 17 22:44:59 2016 -0700
----------------------------------------------------------------------
.../flex/compiler/common/ISourceLocation.java | 10 ++++
.../flex/compiler/common/SourceLocation.java | 54 ++++++++++++++++++++
.../internal/definitions/metadata/MetaTag.java | 12 +++++
.../compiler/internal/parsing/TokenBase.java | 44 ++++++++++++++++
.../compiler/internal/tree/as/NodeBase.java | 17 ++++--
.../internal/tree/as/OperatorNodeBase.java | 2 +
.../flex/compiler/problems/CompilerProblem.java | 12 +++++
7 files changed, 148 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/af3e883d/compiler/src/org/apache/flex/compiler/common/ISourceLocation.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/common/ISourceLocation.java b/compiler/src/org/apache/flex/compiler/common/ISourceLocation.java
index 738bdf3..25f6b6d 100644
--- a/compiler/src/org/apache/flex/compiler/common/ISourceLocation.java
+++ b/compiler/src/org/apache/flex/compiler/common/ISourceLocation.java
@@ -64,6 +64,16 @@ public interface ISourceLocation
int getColumn();
/**
+ * Gets the local line number at the end. It is zero-based.
+ */
+ int getEndLine();
+
+ /**
+ * Gets the local column number at the end. It is zero-based.
+ */
+ int getEndColumn();
+
+ /**
* Gets the absolute starting offset. It is zero-based.
*/
int getAbsoluteStart();
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/af3e883d/compiler/src/org/apache/flex/compiler/common/SourceLocation.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/common/SourceLocation.java b/compiler/src/org/apache/flex/compiler/common/SourceLocation.java
index 88998b7..0d0e1b0 100644
--- a/compiler/src/org/apache/flex/compiler/common/SourceLocation.java
+++ b/compiler/src/org/apache/flex/compiler/common/SourceLocation.java
@@ -37,6 +37,8 @@ public class SourceLocation implements ISourceLocation
this.end = end;
this.line = line;
this.column = column;
+ this.endLine = UNKNOWN;
+ this.endColumn = UNKNOWN;
}
/**
@@ -93,6 +95,16 @@ public class SourceLocation implements ISourceLocation
* Corresponds to start, not end.
*/
private int column;
+
+ /**
+ * Zero-based line number that corresponds to end.
+ */
+ private int endLine;
+
+ /**
+ * Zero-based column number that corresponds to end.
+ */
+ private int endColumn;
/**
* Copies source location information from another instance
@@ -106,6 +118,8 @@ public class SourceLocation implements ISourceLocation
this.end = src.getEnd();
this.line = src.getLine();
this.column = src.getColumn();
+ this.endLine = src.getEndLine();
+ this.endColumn = src.getEndColumn();
this.sourcePath = src.getSourcePath();
}
@@ -212,6 +226,44 @@ public class SourceLocation implements ISourceLocation
}
/**
+ * Get the line number where this node ends.
+ * Line numbers start at 0, not 1.
+ * @return The line number
+ */
+ public int getEndLine()
+ {
+ return endLine;
+ }
+
+ /**
+ * Set the line number where this node ends.
+ * Column numbers start at 0, not 1.
+ * @param line The line number
+ */
+ public void setEndLine(int line)
+ {
+ this.endLine = line;
+ }
+
+ /**
+ * Get the column number where this node ends.
+ * @return The column number
+ */
+ public int getEndColumn()
+ {
+ return endColumn;
+ }
+
+ /**
+ * Set the column number where this node ends.
+ * @param column The column number
+ */
+ public void setEndColumn(int column)
+ {
+ this.endColumn = column;
+ }
+
+ /**
* Get the source path for this node.
* @return The source path for this node
*/
@@ -346,6 +398,8 @@ public class SourceLocation implements ISourceLocation
setEnd(end.getEnd());
setLine(start.getLine());
setColumn(start.getColumn());
+ setEndLine(end.getEndLine());
+ setEndColumn(end.getEndColumn());
}
/**
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/af3e883d/compiler/src/org/apache/flex/compiler/internal/definitions/metadata/MetaTag.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/definitions/metadata/MetaTag.java b/compiler/src/org/apache/flex/compiler/internal/definitions/metadata/MetaTag.java
index 92b9350..5b0b18e 100644
--- a/compiler/src/org/apache/flex/compiler/internal/definitions/metadata/MetaTag.java
+++ b/compiler/src/org/apache/flex/compiler/internal/definitions/metadata/MetaTag.java
@@ -230,6 +230,18 @@ public class MetaTag implements IMetaTag
}
@Override
+ public int getEndLine()
+ {
+ return line;
+ }
+
+ @Override
+ public int getEndColumn()
+ {
+ return column;
+ }
+
+ @Override
public int getAbsoluteStart()
{
return absoluteStart;
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/af3e883d/compiler/src/org/apache/flex/compiler/internal/parsing/TokenBase.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/parsing/TokenBase.java b/compiler/src/org/apache/flex/compiler/internal/parsing/TokenBase.java
index 68a76eb..ff726da 100644
--- a/compiler/src/org/apache/flex/compiler/internal/parsing/TokenBase.java
+++ b/compiler/src/org/apache/flex/compiler/internal/parsing/TokenBase.java
@@ -50,6 +50,8 @@ public abstract class TokenBase extends Token implements ICMToken, ISourceLocati
this.line = line;
this.column = column;
this.text = text;
+ this.endLine = line;
+ this.endColumn = column + end - start;
if (Counter.COUNT_TOKENS)
countTokens();
@@ -67,6 +69,8 @@ public abstract class TokenBase extends Token implements ICMToken, ISourceLocati
end = o.end;
line = o.line;
column = o.column;
+ endLine = o.endLine;
+ endColumn = o.endColumn;
text = o.text;
localStart = o.localStart;
@@ -103,6 +107,16 @@ public abstract class TokenBase extends Token implements ICMToken, ISourceLocati
private int column;
/**
+ * End line of this token
+ */
+ private int endLine;
+
+ /**
+ * End column of this token
+ */
+ private int endColumn;
+
+ /**
* Flag to determine if this token is locked
*/
private boolean locked;
@@ -143,6 +157,8 @@ public abstract class TokenBase extends Token implements ICMToken, ISourceLocati
this.end = end;
this.line = line;
this.column = column;
+ this.endLine = line;
+ this.endColumn = column + end - start;
this.text = text;
}
@@ -222,6 +238,8 @@ public abstract class TokenBase extends Token implements ICMToken, ISourceLocati
this.end = end;
this.line = line;
this.column = column;
+ this.endLine = line;
+ this.endColumn = column + end - start;
}
@Override
@@ -275,6 +293,28 @@ public abstract class TokenBase extends Token implements ICMToken, ISourceLocati
this.column = column;
}
+ @Override
+ public int getEndLine()
+ {
+ return endLine;
+ }
+
+ public void setEndLine(int line)
+ {
+ endLine = line;
+ }
+
+ @Override
+ public int getEndColumn()
+ {
+ return endColumn;
+ }
+
+ public void setEndColumn(int column)
+ {
+ endColumn = column;
+ }
+
/**
* Determine whether or not this token is bogus (i.e. the start and end
* offsets are the same, which implies that it was inserted from an included
@@ -439,6 +479,8 @@ public abstract class TokenBase extends Token implements ICMToken, ISourceLocati
end += offsetAdjustment;
line += lineAdjustment;
column += columnAdjustment;
+ endLine += lineAdjustment;
+ endColumn += columnAdjustment;
}
/**
@@ -485,6 +527,8 @@ public abstract class TokenBase extends Token implements ICMToken, ISourceLocati
assert getEnd() != UNKNOWN : "Token has unknown end: " + toString();
assert getLine() != UNKNOWN : "Token has an unknown line: " + toString();
assert getColumn() != UNKNOWN : "Token has an unknown column: " + toString();
+ assert getEndLine() != UNKNOWN : "Token has an unknown end line: " + toString();
+ assert getEndColumn() != UNKNOWN : "Token has an unknown end column: " + toString();
}
return true;
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/af3e883d/compiler/src/org/apache/flex/compiler/internal/tree/as/NodeBase.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/tree/as/NodeBase.java b/compiler/src/org/apache/flex/compiler/internal/tree/as/NodeBase.java
index be0510d..8dd4fb6 100644
--- a/compiler/src/org/apache/flex/compiler/internal/tree/as/NodeBase.java
+++ b/compiler/src/org/apache/flex/compiler/internal/tree/as/NodeBase.java
@@ -337,7 +337,6 @@ public abstract class NodeBase extends SourceLocation implements IASNode
if (token instanceof ISourceLocation)
{
startAfter((ISourceLocation) token);
- setColumn(getColumn() + token.getText().length());
}
}
@@ -354,8 +353,8 @@ public abstract class NodeBase extends SourceLocation implements IASNode
{
setSourcePath(location.getSourcePath());
setStart(end);
- setLine(location.getLine());
- setColumn(location.getColumn());
+ setLine(location.getEndLine());
+ setColumn(location.getEndColumn());
}
}
@@ -411,7 +410,11 @@ public abstract class NodeBase extends SourceLocation implements IASNode
{
final int end = location.getEnd();
if (end != UNKNOWN)
+ {
setEnd(end);
+ setEndLine(location.getEndLine());
+ setEndColumn(location.getEndColumn());
+ }
}
/**
@@ -436,7 +439,11 @@ public abstract class NodeBase extends SourceLocation implements IASNode
{
final int start = location.getStart();
if (start != UNKNOWN)
+ {
setEnd(start);
+ setEndLine(location.getLine());
+ setEndColumn(location.getColumn());
+ }
}
/**
@@ -620,7 +627,11 @@ public abstract class NodeBase extends SourceLocation implements IASNode
if (childEnd != -1)
{
if (end < childEnd)
+ {
setEnd(childEnd);
+ setEndLine(child.getEndLine());
+ setEndColumn(child.getEndColumn());
+ }
break;
}
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/af3e883d/compiler/src/org/apache/flex/compiler/internal/tree/as/OperatorNodeBase.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/tree/as/OperatorNodeBase.java b/compiler/src/org/apache/flex/compiler/internal/tree/as/OperatorNodeBase.java
index 5de6521..51eb0fc 100644
--- a/compiler/src/org/apache/flex/compiler/internal/tree/as/OperatorNodeBase.java
+++ b/compiler/src/org/apache/flex/compiler/internal/tree/as/OperatorNodeBase.java
@@ -41,6 +41,8 @@ public abstract class OperatorNodeBase extends ExpressionNodeBase implements IOp
operatorStart = operator.getStart();
setLine(operator.getLine());
setColumn(operator.getColumn());
+ setEndLine(operator.getEndLine());
+ setEndColumn(operator.getEndColumn());
setSourcePath(operator.getSourcePath());
}
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/af3e883d/compiler/src/org/apache/flex/compiler/problems/CompilerProblem.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/problems/CompilerProblem.java b/compiler/src/org/apache/flex/compiler/problems/CompilerProblem.java
index ee9c9a1..d2e9366 100644
--- a/compiler/src/org/apache/flex/compiler/problems/CompilerProblem.java
+++ b/compiler/src/org/apache/flex/compiler/problems/CompilerProblem.java
@@ -189,6 +189,18 @@ public abstract class CompilerProblem implements ICompilerProblem
}
@Override
+ public int getEndLine()
+ {
+ return line;
+ }
+
+ @Override
+ public int getEndColumn()
+ {
+ return column;
+ }
+
+ @Override
public int getAbsoluteStart()
{
return start;