use of com.intellij.codeInspection.offline.OfflineProblemDescriptor in project intellij-community by JetBrains.
the class OfflineViewParseUtil method parse.
public static Map<String, Set<OfflineProblemDescriptor>> parse(final String problems) {
final TObjectIntHashMap<String> fqName2IdxMap = new TObjectIntHashMap<>();
final Map<String, Set<OfflineProblemDescriptor>> package2Result = new THashMap<>();
final XppReader reader = new XppReader(new StringReader(problems));
try {
while (reader.hasMoreChildren()) {
//problem
reader.moveDown();
final OfflineProblemDescriptor descriptor = new OfflineProblemDescriptor();
boolean added = false;
while (reader.hasMoreChildren()) {
reader.moveDown();
if (SmartRefElementPointerImpl.ENTRY_POINT.equals(reader.getNodeName())) {
descriptor.setType(reader.getAttribute(SmartRefElementPointerImpl.TYPE_ATTR));
final String fqName = reader.getAttribute(SmartRefElementPointerImpl.FQNAME_ATTR);
descriptor.setFQName(fqName);
if (!fqName2IdxMap.containsKey(fqName)) {
fqName2IdxMap.put(fqName, 0);
}
int idx = fqName2IdxMap.get(fqName);
descriptor.setProblemIndex(idx);
fqName2IdxMap.put(fqName, idx + 1);
}
if (DESCRIPTION.equals(reader.getNodeName())) {
descriptor.setDescription(reader.getValue());
}
if (LINE.equals(reader.getNodeName())) {
descriptor.setLine(Integer.parseInt(reader.getValue()));
}
if (MODULE.equals(reader.getNodeName())) {
descriptor.setModule(reader.getValue());
}
if (HINTS.equals(reader.getNodeName())) {
while (reader.hasMoreChildren()) {
reader.moveDown();
List<String> hints = descriptor.getHints();
if (hints == null) {
hints = new ArrayList<>();
descriptor.setHints(hints);
}
hints.add(reader.getAttribute("value"));
reader.moveUp();
}
}
if (PACKAGE.equals(reader.getNodeName())) {
appendDescriptor(package2Result, reader.getValue(), descriptor);
added = true;
}
while (reader.hasMoreChildren()) {
reader.moveDown();
if (PACKAGE.equals(reader.getNodeName())) {
appendDescriptor(package2Result, reader.getValue(), descriptor);
added = true;
}
reader.moveUp();
}
reader.moveUp();
}
if (!added)
appendDescriptor(package2Result, "", descriptor);
reader.moveUp();
}
} finally {
reader.close();
}
return package2Result;
}
use of com.intellij.codeInspection.offline.OfflineProblemDescriptor in project intellij-community by JetBrains.
the class OfflineInspectionResultViewTest method parse.
private Map<String, Map<String, Set<OfflineProblemDescriptor>>> parse() throws IOException {
final String moduleName = getModule().getName();
final File res = new File(PathManagerEx.getTestDataPath(), getTestPath() + File.separator + "res");
final File[] files = res.listFiles();
assert files != null;
final Map<String, Map<String, Set<OfflineProblemDescriptor>>> map = new HashMap<>();
for (File file : files) {
final String problems = FileUtil.loadFile(file);
final Map<String, Set<OfflineProblemDescriptor>> descriptors = OfflineViewParseUtil.parse(problems);
for (Set<OfflineProblemDescriptor> problemDescriptors : descriptors.values()) {
for (OfflineProblemDescriptor descriptor : problemDescriptors) {
descriptor.setModule(moduleName);
}
}
final String name = file.getName();
map.put(name.substring(0, name.lastIndexOf('.')), descriptors);
}
return map;
}
Aggregations