use of net.sourceforge.pmd.lang.dfa.DFAGraphMethod in project pmd by pmd.
the class DFAPanel method resetTo.
public void resetTo(List<DFAGraphMethod> newNodes, LineGetter lines) {
dfaCanvas.setCode(lines);
nodes.clear();
for (DFAGraphMethod md : newNodes) {
nodes.addElement(new ElementWrapper(md));
}
nodeList.setSelectedIndex(0);
dfaCanvas.setMethod(newNodes.get(0));
repaint();
}
use of net.sourceforge.pmd.lang.dfa.DFAGraphMethod in project Gargoyle by callakrsos.
the class DFAPanelFx method resetTo.
public void resetTo(List<DFAGraphMethod> newNodes, LineGetter lines) {
dfaCanvas.setCode(lines);
nodes.clear();
for (DFAGraphMethod md : newNodes) {
nodes.addElement(new ElementWrapper(md));
}
nodeList.setSelectedIndex(0);
dfaCanvas.setMethod(newNodes.get(0));
dfaCanvas.repaint();
}
use of net.sourceforge.pmd.lang.dfa.DFAGraphMethod in project pmd-eclipse-plugin by pmd.
the class AbstractStructureInspectorPage method getPMDMethods.
/**
* Gets a List of all PMD-Methods.
*
* @return an List of ASTMethodDeclarations
*/
private List<ASTMethodDeclaration> getPMDMethods() {
List<ASTMethodDeclaration> methodList = new ArrayList<ASTMethodDeclaration>();
// PMD needs this Resource as a String
try {
DFAGraphRule dfaGraphRule = new JavaDFAGraphRule();
RuleSet rs = RuleSetUtil.newSingle(dfaGraphRule);
RuleContext ctx = new RuleContext();
ctx.setSourceCodeFilename("[scratchpad]");
// StringReader reader = new StringReader(getDocument().get());
// run PMD using the DFAGraphRule and the Text of the Resource
// new PMDEngine().processFile(reader, rs, ctx);
byte[] bytes = getDocument().get().getBytes();
InputStream input = new ByteArrayInputStream(bytes);
RuleSets rSets = new RuleSets(rs);
new SourceCodeProcessor(new PMDConfiguration()).processSourceCode(input, rSets, ctx);
// the Rule then can give us the Methods
for (DFAGraphMethod m : dfaGraphRule.getMethods()) {
if (m instanceof ASTMethodDeclaration) {
methodList.add((ASTMethodDeclaration) m);
}
}
Collections.sort(methodList, ASTUtil.METHOD_COMPARATOR);
} catch (PMDException pmde) {
logError(StringKeys.ERROR_PMD_EXCEPTION + toString(), pmde);
}
return methodList;
}
Aggregations