WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit fadef44

Browse files
committed
Issue #36 - Added end line and column fields to ParsedElement classes.
- Added appropriate line and column methods to exception classes. - Also made ParsedElement an abstract class instead of an interface.
1 parent 8100c05 commit fadef44

File tree

130 files changed

+2312
-2594
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+2312
-2594
lines changed

org.modeldriven.alf.eclipse/src/org/modeldriven/alf/eclipse/fuml/mapping/FumlMapper.java

Lines changed: 0 additions & 64 deletions
This file was deleted.

org.modeldriven.alf.fuml.impl/src/org/modeldriven/alf/fuml/impl/mapping/FumlMapper.java

Lines changed: 0 additions & 64 deletions
This file was deleted.

org.modeldriven.alf/src/org/modeldriven/alf/execution/AlfBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void printConstraintViolations(Collection<ConstraintViolation> violations
9999
this.println("\n" + (fileName == null? "": fileName) + ":");
100100
}
101101
int prevLineNum = lineNum;
102-
lineNum = violation.getLine();
102+
lineNum = violation.getBeginLine();
103103
line = this.getLine(reader, line, prevLineNum, lineNum);
104104
this.printConstraintViolation(line, violation);
105105
}
@@ -127,7 +127,7 @@ protected void printConstraintViolation(String line, ConstraintViolation violati
127127
if (line != null) {
128128
this.println(line);
129129
StringBuffer indent = new StringBuffer();
130-
for (int n = violation.getColumn(); n > 1; n--) {
130+
for (int n = violation.getBeginColumn(); n > 1; n--) {
131131
indent.append(" ");
132132
}
133133
this.println(indent + "^");

org.modeldriven.alf/src/org/modeldriven/alf/parser/ParseException.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@ public ParseException(String message) {
8686
* defined in the generated ...Constants interface.
8787
*/
8888
public String[] tokenImage;
89+
90+
public int getBeginLine() {
91+
return this.currentToken.next.beginLine;
92+
}
93+
94+
public int getBeginColumn() {
95+
return this.currentToken.next.beginColumn;
96+
}
97+
98+
public int getEndLine() {
99+
return this.currentToken.next.endLine;
100+
}
101+
102+
public int getEndColumn() {
103+
return this.currentToken.next.endColumn;
104+
}
89105

90106
/**
91107
* It uses "currentToken" and "expectedTokenSequences" to generate a parse

org.modeldriven.alf/src/org/modeldriven/alf/parser/TokenMgrError.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLin
118118
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
119119
"after: \"" + addEscapes(errorAfter) + "\"");
120120
}
121+
122+
private int errorLine = 0;
123+
private int errorColumn = 0;
124+
125+
public int getLine() {
126+
return this.errorLine;
127+
}
128+
129+
public int getColumn() {
130+
return this.errorColumn;
131+
}
121132

122133
/**
123134
* You can also modify the body of this method to customize your error messages.
@@ -149,6 +160,8 @@ public TokenMgrError(String message, int reason) {
149160
/** Full Constructor. */
150161
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
151162
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
163+
this.errorLine = errorLine;
164+
this.errorColumn = errorColumn;
152165
}
153166
}
154167
/* JavaCC - OriginalChecksum=c1c6b3ec56ed5d0a4c0efc01fb23151e (do not edit this line) */

org.modeldriven.alf/src/org/modeldriven/alf/syntax/common/AssignedSource.java

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2011, 2016 Data Access Technologies, Inc. (Model Driven Solutions)
2+
* Copyright 2011, 2017 Data Access Technologies, Inc. (Model Driven Solutions)
33
* All rights reserved worldwide. This program and the accompanying materials
44
* are made available for use under the terms of the GNU General Public License
55
* (GPL) version 3 that accompanies this distribution and is available at
@@ -10,7 +10,6 @@
1010
package org.modeldriven.alf.syntax.common;
1111

1212
import org.modeldriven.alf.parser.Parser;
13-
import org.modeldriven.alf.parser.Token;
1413

1514
import java.util.Collection;
1615
import java.util.TreeSet;
@@ -22,58 +21,29 @@
2221
* input parameter, along with a record of the defined type (if any) and
2322
* multiplicity of the name.
2423
**/
25-
26-
public class AssignedSource implements ParsedElement {
24+
public class AssignedSource extends ParsedElement {
2725

2826
protected AssignedSourceImpl impl;
2927

30-
private String fileName = "";
31-
private int line = 0;
32-
private int column = 0;
33-
3428
public AssignedSource() {
3529
this.impl = new AssignedSourceImpl(this);
3630
}
3731

3832
public AssignedSource(Parser parser) {
3933
this();
40-
Token token = parser.getToken(0);
41-
if (token.next != null) {
42-
token = token.next;
43-
}
44-
this.setParserInfo(parser.getFileName(), token.beginLine,
45-
token.beginColumn);
34+
this.init(parser);
4635
}
4736

4837
public AssignedSource(ParsedElement element) {
4938
this();
50-
this.setParserInfo(element.getFileName(), element.getLine(), element
51-
.getColumn());
39+
this.init(element);
5240
}
5341

5442
public AssignedSourceImpl getImpl() {
5543
return (AssignedSourceImpl) this.impl;
5644
}
5745

58-
public String getFileName() {
59-
return this.fileName;
60-
}
61-
62-
public int getLine() {
63-
return this.line;
64-
}
65-
66-
public int getColumn() {
67-
return this.column;
68-
}
69-
70-
public void setParserInfo(String fileName, int line, int column) {
71-
this.fileName = fileName;
72-
this.line = line;
73-
this.column = column;
74-
}
75-
76-
public String getName() {
46+
public String getName() {
7747
return this.getImpl().getName();
7848
}
7949

org.modeldriven.alf/src/org/modeldriven/alf/syntax/common/ConstraintViolation.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public String getConstraintName() {
8989
}
9090

9191
public String getErrorMessage() {
92-
return "[" + this.getLine() + ":" + this.getColumn() + "] " +
92+
return "[" + this.getBeginLine() + ":" + this.getBeginColumn() + "] " +
9393
getErrorMessage(this.constraintName);
9494
}
9595

@@ -101,12 +101,20 @@ public String getFileName() {
101101
return this.getViolatingElement().getFileName();
102102
}
103103

104-
public int getLine() {
105-
return this.getViolatingElement().getLine();
104+
public int getBeginLine() {
105+
return this.getViolatingElement().getBeginLine();
106106
}
107107

108-
public int getColumn() {
109-
return this.getViolatingElement().getColumn();
108+
public int getBeginColumn() {
109+
return this.getViolatingElement().getBeginColumn();
110+
}
111+
112+
public int getEndLine() {
113+
return this.getViolatingElement().getEndLine();
114+
}
115+
116+
public int getEndColumn() {
117+
return this.getViolatingElement().getEndColumn();
110118
}
111119

112120
@Override
@@ -139,13 +147,13 @@ public int hashCode() {
139147
public int compareTo(ConstraintViolation other) {
140148
ParsedElement element = this.getViolatingElement();
141149
String fileName = element.getFileName();
142-
int line = element.getLine();
143-
int column = element.getColumn();
150+
int line = element.getBeginLine();
151+
int column = element.getBeginColumn();
144152

145153
element = other.getViolatingElement();
146154
String otherFileName = element.getFileName();
147-
int otherLine = element.getLine();
148-
int otherColumn = element.getColumn();
155+
int otherLine = element.getBeginLine();
156+
int otherColumn = element.getBeginColumn();
149157

150158
int compare = fileName.compareTo(otherFileName);
151159
return compare != 0? compare:

org.modeldriven.alf/src/org/modeldriven/alf/syntax/common/DocumentedElement.java

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
/*******************************************************************************
3-
* Copyright 2011, 2016 Data Access Technologies, Inc. (Model Driven Solutions)
2+
* Copyright 2011, 2017 Data Access Technologies, Inc. (Model Driven Solutions)
43
* All rights reserved worldwide. This program and the accompanying materials
54
* are made available for use under the terms of the GNU General Public License
65
* (GPL) version 3 that accompanies this distribution and is available at
@@ -10,41 +9,20 @@
109

1110
package org.modeldriven.alf.syntax.common;
1211

13-
import org.modeldriven.alf.parser.Parser;
14-
import org.modeldriven.alf.parser.Token;
15-
1612
import java.util.Collection;
13+
1714
import org.modeldriven.alf.syntax.common.impl.DocumentedElementImpl;
1815

1916
/**
2017
* A syntax element that has documentation comments associated with it.
2118
**/
2219

2320
public abstract class DocumentedElement extends SyntaxElement {
24-
25-
public DocumentedElement() {
26-
}
27-
28-
public DocumentedElement(Parser parser) {
29-
this();
30-
Token token = parser.getToken(0);
31-
if (token.next != null) {
32-
token = token.next;
33-
}
34-
this.setParserInfo(parser.getFileName(), token.beginLine,
35-
token.beginColumn);
36-
}
37-
38-
public DocumentedElement(ParsedElement element) {
39-
this();
40-
this.setParserInfo(element.getFileName(), element.getLine(), element
41-
.getColumn());
42-
}
43-
21+
4422
public DocumentedElementImpl getImpl() {
4523
return (DocumentedElementImpl) this.impl;
4624
}
47-
25+
4826
public Collection<String> getDocumentation() {
4927
return this.getImpl().getDocumentation();
5028
}

0 commit comments

Comments
 (0)