-
Notifications
You must be signed in to change notification settings - Fork 316
/
TraceRegionToStringTester.java
129 lines (100 loc) · 2.85 KB
/
TraceRegionToStringTester.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/**
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.xtext.generator.trace;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import org.eclipse.xtext.util.ITextRegion;
public class TraceRegionToStringTester extends AbstractTraceRegionToString {
public static class Location extends LocationData {
public Location(int offset, int length, SourceRelativeURI path) {
super(offset, length, 0, 0, path);
}
public Location(int offset, int length) {
this(offset, length, null);
}
}
public static class Region extends TraceRegion {
public Region(int myOffset, int myLength, Collection<ILocationData> allLocationData,
AbstractTraceRegion parent) {
super(myOffset, myLength, 0, 0, true, allLocationData, parent);
}
public Region(int myOffset, int myLength, Collection<ILocationData> allLocationData) {
super(myOffset, myLength, 0, 0, true, allLocationData, null);
}
public TraceRegionToStringTester.Region addChild(int myOffset, int myLength,
List<ILocationData> allLocationData) {
return new TraceRegionToStringTester.Region(myOffset, myLength,
allLocationData, this);
}
}
private final SourceRelativeURI uri1 = new SourceRelativeURI("remote1");
private final SourceRelativeURI uri2 = new SourceRelativeURI("remote2");
private String localText;
private String remote1;
private String remote2;
private ITextRegion localFrame;
private TraceRegionToStringTester.Region trace;
public TraceRegionToStringTester() {
setShowLegend(false);
}
@Override
protected String getRemoteText(SourceRelativeURI uri) {
if (Objects.equals(uri, uri1)) {
return remote1;
}
if (Objects.equals(uri, uri2)) {
return remote2;
}
return null;
}
@Override
protected String getLocalTitle() {
return "local1";
}
public SourceRelativeURI getUri1() {
return uri1;
}
public SourceRelativeURI getUri2() {
return uri2;
}
@Override
public String getLocalText() {
return localText;
}
public void setLocalText(String localText) {
this.localText = localText;
}
public String getRemote1() {
return remote1;
}
public void setRemote1(String remote1) {
this.remote1 = remote1;
}
public String getRemote2() {
return remote2;
}
public void setRemote2(String remote2) {
this.remote2 = remote2;
}
@Override
public ITextRegion getLocalFrame() {
return localFrame;
}
public void setLocalFrame(ITextRegion localFrame) {
this.localFrame = localFrame;
}
@Override
public TraceRegionToStringTester.Region getTrace() {
return trace;
}
public void setTrace(TraceRegionToStringTester.Region trace) {
this.trace = trace;
}
}