Skip to content
This repository was archived by the owner on Nov 28, 2020. It is now read-only.

Commit 0907407

Browse files
committed
More ugly hacks added to context selection. Can now select map members
1 parent 1592744 commit 0907407

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

src/me/coley/jremapper/parse/Context.java

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public class Context {
3535

3636
public Context(Program callback) {
3737
this.callback = callback;
38+
for (int i = 0; i < ID_PRIMITIVES.size(); i++) {
39+
simpleToQuantified.put(ID_PRIMITIVES.get(i), ID_PRIMITIVES_SYMBOL.get(i));
40+
}
3841
}
3942

4043
public ContextType getContextForLine(int line) {
@@ -198,8 +201,13 @@ private Segment readHeader(IndexableStringReader read, Segment lastType, String
198201

199202
private void readMember(IndexableStringReader read, String currentSimple, String elem) throws IOException {
200203
if (elem.contains("<")) {
204+
// Hack to skip to the end of the generic type parameters
205+
String temp = elem;
206+
while (!elem.contains(">")) {
207+
elem = read.nextWord();
208+
}
201209
// Cut off generics
202-
elem = elem.substring(0, elem.indexOf("<"));
210+
elem = temp.substring(0, temp.indexOf("<"));
203211
}
204212
String name = null;
205213
String retType = "";
@@ -211,12 +219,14 @@ private void readMember(IndexableStringReader read, String currentSimple, String
211219
arrayDepth++;
212220
}
213221
// Get the return type
214-
if (ID_PRIMITIVES.contains(type)) {
215-
retTypeSuffic = ID_PRIMITIVES_SYMBOL.get(ID_PRIMITIVES.indexOf(type));
216-
} if (simpleToQuantified.containsKey(type)) {
222+
if (simpleToQuantified.containsKey(type)) {
217223
// From imported
218224
String full = simpleToQuantified.get(type);
219-
retTypeSuffic = "L" + full + ";";
225+
if (ID_PRIMITIVES.contains(type)) {
226+
retTypeSuffic = full;
227+
} else {
228+
retTypeSuffic = "L" + full + ";";
229+
}
220230
ClassMapping cm = getClass(full);
221231
if (cm != null) {
222232
fill(read, type, cm);
@@ -297,6 +307,7 @@ private void readMember(IndexableStringReader read, String currentSimple, String
297307
}
298308
// Fetch the arg's desc representation
299309
String desc = null;
310+
boolean abstractEnd = false;
300311
if (ID_PRIMITIVES.contains(argType)) {
301312
desc = ID_PRIMITIVES_SYMBOL.get(ID_PRIMITIVES.indexOf(argType));
302313
} else {
@@ -316,6 +327,7 @@ private void readMember(IndexableStringReader read, String currentSimple, String
316327
// Fix for mis-interpreted ending arg for abstract
317328
// methods.
318329
desc = "";
330+
abstractEnd = true;
319331
}
320332
}
321333
// Add array level to arg in desc
@@ -326,14 +338,20 @@ private void readMember(IndexableStringReader read, String currentSimple, String
326338
// Append to method desc
327339
sbDesc.append(desc);
328340
arrayDepth = 0;
329-
String argName = read.nextWord();
330-
// Check if there are more args to parse or break the reader
331-
// loop if there are none.
332-
if (argName.endsWith(",")) {
333-
argType = read.nextWord();
334-
} else {
341+
if (abstractEnd) {
335342
break;
343+
} else {
344+
String argName = read.nextWord();
345+
// Check if there are more args to parse or break the reader
346+
// loop if there are none.
347+
if (argName.endsWith(",")) {
348+
argType = read.nextWord();
349+
} else {
350+
break;
351+
}
336352
}
353+
354+
337355
}
338356

339357
// Finish up the method descriptor and

0 commit comments

Comments
 (0)