public void setDebugVarNames(Map<Integer, String> mapDebugVarNames) { if (varVersions == null) { return; } Map<Integer, Integer> mapOriginalVarIndices = varVersions.getMapOriginalVarIndices(); List<VarVersionPair> listVars = new ArrayList<>(mapVarNames.keySet()); listVars.sort(Comparator.comparingInt(o -> o.var)); Map<String, Integer> mapNames = new HashMap<>(); for (VarVersionPair pair : listVars) { String name = mapVarNames.get(pair); Integer index = mapOriginalVarIndices.get(pair.var); if (index != null) { String debugName = mapDebugVarNames.get(index); if (debugName != null && TextUtil.isValidIdentifier(debugName, method.getClassStruct().getBytecodeVersion())) { name = debugName; } } Integer counter = mapNames.get(name); mapNames.put(name, counter == null ? counter = 0 : ++counter); if (counter > 0) { name += String.valueOf(counter); } mapVarNames.put(pair, name); } }
public String getDebugName(StructMethod method) { StructLocalVariableTableAttribute attr = method.getLocalVariableAttr(); if (attr != null && processor != null) { Integer origIndex = processor.getVarOriginalIndex(index); if (origIndex != null) { String name = attr.getName(origIndex, visibleOffset); if (name != null && TextUtil.isValidIdentifier(name, method.getClassStruct().getBytecodeVersion())) { return name; } } } return null; }
public void setDebugVarNames(Map<Integer, String> mapDebugVarNames) { if (varVersions == null) { return; } Map<Integer, Integer> mapOriginalVarIndices = varVersions.getMapOriginalVarIndices(); List<VarVersionPair> listVars = new ArrayList<>(mapVarNames.keySet()); Collections.sort(listVars, Comparator.comparingInt(o -> o.var)); Map<String, Integer> mapNames = new HashMap<>(); for (VarVersionPair pair : listVars) { String name = mapVarNames.get(pair); Integer index = mapOriginalVarIndices.get(pair.var); if (index != null) { String debugName = mapDebugVarNames.get(index); if (debugName != null && TextUtil.isValidIdentifier(debugName, method.getClassStruct().getBytecodeVersion())) { name = debugName; } } Integer counter = mapNames.get(name); mapNames.put(name, counter == null ? counter = 0 : ++counter); if (counter > 0) { name += String.valueOf(counter); } mapVarNames.put(pair, name); } }
public String getDebugName(StructMethod method) { StructLocalVariableTableAttribute attr = method.getLocalVariableAttr(); if (attr != null && processor != null) { Integer origIndex = processor.getVarOriginalIndex(index); if (origIndex != null) { String name = attr.getName(origIndex, visibleOffset); if (name != null && TextUtil.isValidIdentifier(name, method.getClassStruct().getBytecodeVersion())) { return name; } } } return null; }