public SourceFunction(SourceFile sourceFile, String functionSignature, int startAtLine) { super(sourceFile.getKey() + "#" + functionSignature, functionSignature); setStartAtLine(startAtLine); } }
public SourceMethod(SourceClass peekParentClass, String methodSignature, int startAtLine) { super(peekParentClass.getKey() + "#" + methodSignature, methodSignature); setStartAtLine(startAtLine); }
public SourceProject decorateSourceCodeTreeWith(MetricDef... metrics) { SourceCodeTreeDecorator decorator = new SourceCodeTreeDecorator(project); decorator.decorateWith(metrics); return project; }
private static TreeMultimap<Integer, String> collectIssues(final SourceCode sourceCode) { final TreeMultimap<Integer, String> issues = TreeMultimap.create(); for (final CheckMessage checkMessage : sourceCode.getCheckMessages()) { Integer line = checkMessage.getLine(); if (line == null) { line = 0; } issues.put(line, checkMessage.getText(Locale.US)); } return issues; } }
private void saveClassComplexity(org.sonar.api.resources.File sonarFile, SourceFile squidFile) { double complexityInClasses = 0; Set<SourceCode> children = squidFile.getChildren(); if (children != null) { for (SourceCode sourceCode : squidFile.getChildren()) { if (sourceCode.isType(SourceClass.class)) { complexityInClasses += sourceCode.getDouble(EcmaScriptMetric.COMPLEXITY); } } } context.saveMeasure(sonarFile, CoreMetrics.COMPLEXITY_IN_CLASSES, complexityInClasses); }
public <S extends SourceCode> S getAncestor(Class<S> withClass) { S ancestor = getParent(withClass); if (ancestor != null) { S parentAncestor = ancestor.getAncestor(withClass); if (parentAncestor != null) { ancestor = parentAncestor; } } return ancestor; }
@Override public boolean match(SourceCode unit) { return unit.isType(resourceType); }
@Override public void accept(CodeVisitor visitor) { if (visitor instanceof BytecodeVisitor) { super.accept(visitor); } }
public SourceCodeEdge(SourceCode from, SourceCode to, SourceCodeEdgeUsage usage, @Nullable SourceCodeEdge rootEdge) { this.hashcode = from.hashCode() * 31 + to.hashCode() + usage.hashCode(); // NOSONAR even if this basic algorithm could be improved this.from = from; this.to = to; this.usage = usage; addRootEdge(rootEdge); }
public boolean hasAmongParents(SourceCode expectedParent) { if (parent == null) { return false; } return parent.equals(expectedParent) || parent.hasAmongParents(expectedParent); } }
@Override public String getText(Locale locale) { return formatDefaultMessage(); }
/** * {@inheritDoc} */ @Override public int getInt(MetricDef metric) { return (int) getMeasure(metric); }
@Override public boolean match(SourceCode unit) { return unit.hasAmongParents(parent); } }
/** * {@inheritDoc} */ @Override public void setMeasure(MetricDef metric, int measure) { setMeasure(metric, (double) measure); }
private boolean isSquidUnitMatchQueries(SourceCode unit, Query... queries) { boolean match; for (Query query : queries) { match = query.match(unit); if (!match) { return false; } } return true; }
private void index(SourceCode sourceCode) { if (indexer != null) { indexer.index(sourceCode); } }
@Override public void accept(CodeVisitor visitor) { if (visitor instanceof BytecodeVisitor) { super.accept(visitor); } }
/** * {@inheritDoc} */ @Override public double getDouble(MetricDef metric) { return getMeasure(metric); }