本文整理汇总了Java中org.sonar.api.batch.fs.TextRange类的典型用法代码示例。如果您正苦于以下问题:Java TextRange类的具体用法?Java TextRange怎么用?Java TextRange使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextRange类属于org.sonar.api.batch.fs包,在下文中一共展示了TextRange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeSymbolRefs
import org.sonar.api.batch.fs.TextRange; //导入依赖的package包/类
private void writeSymbolRefs(JsonWriter json) {
json.name("symbolRefs");
json.beginArray();
for (Map.Entry<TextRange, Set<TextRange>> entry : analyzerResult.symbolRefs().entrySet()) {
json.beginObject();
json.name("symbol").beginObject();
appendRange(json, entry.getKey());
json.endObject();
json.name("locations").beginArray();
for (TextRange range : entry.getValue()) {
json.beginObject();
appendRange(json, range);
json.endObject();
}
json.endArray();
json.endObject();
}
json.endArray();
}
示例2: test_issues_get_imported
import org.sonar.api.batch.fs.TextRange; //导入依赖的package包/类
@Test
public void test_issues_get_imported() throws FileNotFoundException {
SensorContextTester tester = SensorContextTester.create(TEST_DATA_DIR);
DefaultInputFile inputFile = new DefaultInputFile("dummyKey", TEST_FILE_PATH)
.initMetadata(new FileMetadata().readMetadata(new FileReader(TEST_FILE)));
tester.fileSystem().add(inputFile);
File protobuf = new File(TEST_DATA_DIR, ISSUES_OUTPUT_PROTOBUF_NAME);
assertThat(protobuf.isFile()).withFailMessage("no such file: " + protobuf).isTrue();
new IssuesImporter(tester, "dummy", f -> true).accept(protobuf.toPath());
Collection<Issue> issues = tester.allIssues();
assertThat(issues).hasSize(6);
assertThat(issues.stream().map(p -> p.ruleKey().rule()).collect(Collectors.toList()))
.containsOnly("S1186", "S1172", "S1118", "S101", "S101", "S105");
TextRange exactLocation = issues.stream().filter(i -> i.ruleKey().rule().equals("S1186")).findFirst().get().primaryLocation().textRange();
assertThat(exactLocation.start().line() != exactLocation.end().line() || exactLocation.start().lineOffset() != exactLocation.end().lineOffset()).isTrue();
exactLocation = issues.stream().filter(i -> i.ruleKey().rule().equals("S105")).findFirst().get().primaryLocation().textRange();
assertThat(exactLocation).isNull();
}
示例3: addSecondaryLocation
import org.sonar.api.batch.fs.TextRange; //导入依赖的package包/类
private void addSecondaryLocation(final NewIssue issue, final XMLReportFinding xanFinding,
final SensorContext sensorContext) {
final InputFile secondaryFile = mkInputFileOrNull(xanFinding.getSecondaryLocationOrNull(),
sensorContext);
if (secondaryFile != null) {
final NewIssueLocation secondaryLocation = issue.newLocation();
secondaryLocation.on(secondaryFile);
secondaryLocation.message(xanFinding.getSecondaryLocationMessage());
final int secondaryLine = normalizeLineNo(
xanFinding.getSecondaryLocationOrNull().getLineNoOrMinus1());
if (secondaryLine <= secondaryFile.lines()) {
final TextRange textRange = secondaryFile.selectLine(secondaryLine);
secondaryLocation.at(textRange);
}
issue.addLocation(secondaryLocation);
LOG.debug("Added secondary location for finding " + xanFinding.getFindingID());
}
}
示例4: addHighlighting
import org.sonar.api.batch.fs.TextRange; //导入依赖的package包/类
private void addHighlighting(final NewHighlighting newHighlightning, final Token token, final InputFile file,
final TextRange range) {
try {
if (token.getType() == TSqlParser.COMMENT || token.getType() == TSqlParser.LINE_COMMENT) {
newHighlightning.highlight(range, TypeOfText.COMMENT);
}
if (token.getType() == TSqlParser.STRING) {
newHighlightning.highlight(range, TypeOfText.STRING);
}
if (this.keywordsProvider.isKeyword(TSqlParser.VOCABULARY.getSymbolicName(token.getType()))) {
newHighlightning.highlight(range, TypeOfText.KEYWORD);
}
} catch (final Throwable e) {
if (LOGGER.isDebugEnabled()) {
LOGGER.warn(format("Unexpected error adding highlighting on file %s", file.absolutePath()), e);
}
}
}
示例5: location
import org.sonar.api.batch.fs.TextRange; //导入依赖的package包/类
public Location location(final String relativePath) {
final DefaultIndexedFile indexedFile = new DefaultIndexedFile(PROJECT_KEY, MODULE_BASE_DIR, relativePath);
final Metadata metadata = new Metadata(1, 1, "hash", new int[] { 10 }, 20);
final DefaultInputFile on = new DefaultInputFile(indexedFile, null);
on.setMetadata(metadata);
final TextRange at = new DefaultTextRange(new DefaultTextPointer(1,0), new DefaultTextPointer(1, 1));
return new Location(on, at);
}
示例6: DefaultClientIssue
import org.sonar.api.batch.fs.TextRange; //导入依赖的package包/类
public DefaultClientIssue(String severity, @Nullable String type, ActiveRule activeRule, Rule rule, String primaryMessage, @Nullable TextRange textRange,
@Nullable ClientInputFile clientInputFile, List<org.sonar.api.batch.sensor.issue.Issue.Flow> flows) {
super(textRange);
this.severity = severity;
this.type = type;
this.activeRule = activeRule;
this.rule = rule;
this.primaryMessage = primaryMessage;
this.clientInputFile = clientInputFile;
this.flows = flows.stream().map(f -> new DefaultFlow(f.locations())).collect(Collectors.toList());
}
示例7: appendRange
import org.sonar.api.batch.fs.TextRange; //导入依赖的package包/类
private void appendRange(JsonWriter json, TextRange range) {
TextPointer start = range.start();
TextPointer end = range.end();
json.prop("startLine", start.line())
.prop("endLine", end.line())
.prop("startOffset", start.lineOffset())
.prop("endOffset", end.lineOffset());
}
示例8: visitNode
import org.sonar.api.batch.fs.TextRange; //导入依赖的package包/类
@Override
public void visitNode(Tree tree) {
if (((InternalSyntaxToken) tree).isEOF()) {
return;
}
if (((InternalSyntaxToken) tree).isBOM()) {
return;
}
SyntaxToken token = (SyntaxToken) tree;
TextRange range = inputFile.newRange(token.line(), token.column(), token.endLine(), token.endColumn());
cpdTokens.addToken(range, token.text());
}
示例9: toTextRange
import org.sonar.api.batch.fs.TextRange; //导入依赖的package包/类
public static TextRange toTextRange(InputFile inputFile, SonarAnalyzer.TextRange pbTextRange) {
int startLine = pbTextRange.getStartLine();
int startLineOffset = pbTextRange.getStartOffset();
int endLine = pbTextRange.getEndLine();
int endLineOffset = pbTextRange.getEndOffset();
return inputFile.newRange(startLine, startLineOffset, endLine, endLineOffset);
}
示例10: addCpdToken
import org.sonar.api.batch.fs.TextRange; //导入依赖的package包/类
private static void addCpdToken(final NewCpdTokens cpdTokens, InputFile file, final Token token,
final TextRange range) {
try {
cpdTokens.addToken(range, token.getText());
} catch (Throwable e) {
if (LOGGER.isDebugEnabled()) {
LOGGER.warn(format("Unexpected error adding cpd tokens on file %s", file.absolutePath()), e);
}
}
}
示例11: getAt
import org.sonar.api.batch.fs.TextRange; //导入依赖的package包/类
public TextRange getAt() {
return at;
}
示例12: newSymbol
import org.sonar.api.batch.fs.TextRange; //导入依赖的package包/类
@Override
public NoOpNewSymbolTable newSymbol(TextRange range) {
// Do nothing
return this;
}
示例13: newReference
import org.sonar.api.batch.fs.TextRange; //导入依赖的package包/类
@Override
public NoOpNewSymbolTable newReference(TextRange range) {
// Do nothing
return this;
}
示例14: addToken
import org.sonar.api.batch.fs.TextRange; //导入依赖的package包/类
@Override
public NoOpNewCpdTokens addToken(TextRange range, String image) {
// Do nothing
return this;
}
示例15: highlight
import org.sonar.api.batch.fs.TextRange; //导入依赖的package包/类
@Override
public NoOpNewHighlighting highlight(TextRange range, TypeOfText typeOfText) {
// Do nothing
return this;
}