Search in sources :

Example 1 with XmlLocation

use of org.sonar.maven.model.XmlLocation in project sonar-java by SonarSource.

the class PomCheckContextImplTest method fakeLocatedTreeWithUnknownColumn.

private static LocatedTree fakeLocatedTreeWithUnknownColumn(int line) {
    LocatedTreeImpl tree = new LocatedTreeImpl() {
    };
    tree.setStartLocation(new XmlLocation(line, 0));
    tree.setEndLocation(new XmlLocation(line, 0));
    return tree;
}
Also used : LocatedTreeImpl(org.sonar.maven.model.LocatedTreeImpl) XmlLocation(org.sonar.maven.model.XmlLocation)

Example 2 with XmlLocation

use of org.sonar.maven.model.XmlLocation in project sonar-java by SonarSource.

the class PomCheckContextImpl method getSecondaryAnalyzerMessage.

@VisibleForTesting
AnalyzerMessage getSecondaryAnalyzerMessage(JavaCheck check, File file, Location location) {
    TextSpan ts;
    if (location.onLine()) {
        ts = textSpanForLine(file, location.line);
    } else {
        XmlLocation startLocation = location.tree.startLocation();
        XmlLocation endLocation = location.tree.endLocation();
        ts = new TextSpan(startLocation.line(), offsetFromColumn(startLocation.column()), endLocation.line(), offsetFromColumn(endLocation.column()));
        if (ts.isEmpty()) {
            ts = textSpanForLine(file, startLocation.line());
        }
    }
    return new AnalyzerMessage(check, file, ts, location.msg, 0);
}
Also used : TextSpan(org.sonar.java.AnalyzerMessage.TextSpan) XmlLocation(org.sonar.maven.model.XmlLocation) AnalyzerMessage(org.sonar.java.AnalyzerMessage) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 3 with XmlLocation

use of org.sonar.maven.model.XmlLocation in project sonar-java by SonarSource.

the class PomCheckContextImplTest method fakeLocatedTree.

private static LocatedTree fakeLocatedTree(int line, int column, int size) {
    LocatedTreeImpl tree = new LocatedTreeImpl() {
    };
    tree.setStartLocation(new XmlLocation(line, column, 0));
    tree.setEndLocation(new XmlLocation(line, column + size, size));
    return tree;
}
Also used : LocatedTreeImpl(org.sonar.maven.model.LocatedTreeImpl) XmlLocation(org.sonar.maven.model.XmlLocation)

Aggregations

XmlLocation (org.sonar.maven.model.XmlLocation)3 LocatedTreeImpl (org.sonar.maven.model.LocatedTreeImpl)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 AnalyzerMessage (org.sonar.java.AnalyzerMessage)1 TextSpan (org.sonar.java.AnalyzerMessage.TextSpan)1