本文整理汇总了Java中org.sonar.api.batch.fs.TextPointer类的典型用法代码示例。如果您正苦于以下问题:Java TextPointer类的具体用法?Java TextPointer怎么用?Java TextPointer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextPointer类属于org.sonar.api.batch.fs包,在下文中一共展示了TextPointer类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: should_translate_parse_errors
import org.sonar.api.batch.fs.TextPointer; //导入依赖的package包/类
@Test
public void should_translate_parse_errors() {
int line = 2;
int column = 14;
String originalMessage = String.format("Parse error at line %d column %d:whatever", line, column);
String expectedMessage = String.format("Parse error at line %d column %d", line, column);
AnalysisError parseError = newAnalysisError(originalMessage, mock(TextPointer.class));
AnalysisError expected = newAnalysisError(expectedMessage, new DefaultTextPointer(line, column - 1));
AnalysisError translated = translator.translate(parseError);
assertThat(translated.message()).isEqualTo(expected.message());
TextPointer location = translated.location();
assertThat(location.line()).isEqualTo(expected.location().line());
assertThat(location.lineOffset()).isEqualTo(expected.location().lineOffset());
}
示例2: newAnalysisError
import org.sonar.api.batch.fs.TextPointer; //导入依赖的package包/类
private AnalysisError newAnalysisError(@Nullable String message, TextPointer location) {
return new AnalysisError() {
@Override
public InputFile inputFile() {
// TODO create new interface that removes this unnecessary field
return null;
}
@CheckForNull
@Override
public String message() {
return message;
}
@Override
public TextPointer location() {
return location;
}
};
}
示例3: appendRange
import org.sonar.api.batch.fs.TextPointer; //导入依赖的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());
}
示例4: writeErrors
import org.sonar.api.batch.fs.TextPointer; //导入依赖的package包/类
private void writeErrors(JsonWriter json) {
json.name("errors");
json.beginArray();
analyzerResult.errors().stream().map(analysisErrorTranslator::translate).forEach(error -> {
TextPointer location = error.location();
json
.beginObject().prop("message", error.message())
.prop("line", location.line())
.prop("lineOffset", location.lineOffset())
.endObject();
});
json.endArray();
}
示例5: compareWithDefaultInputFile
import org.sonar.api.batch.fs.TextPointer; //导入依赖的package包/类
@Test
public void compareWithDefaultInputFile() throws IOException {
String s = "select " + "*" + "from dbo.test\r\nselect 1";
File ff = folder.newFile("test.sql");
FileUtils.write(ff, s);
DefaultInputFile f = new DefaultInputFile("test", "test.sql");
f.initMetadata(s);
f.setLanguage(TSQLLanguage.KEY);
AntrlResult result = Antlr4Utils.getFull(s);
SourceLinesProvider p = new SourceLinesProvider();
SourceLine[] lines = p.getLines(new FileInputStream(ff), Charset.defaultCharset());
FillerRequest file = new FillerRequest(null, null, result.getTree(), lines);
for (SourceLine l : lines) {
System.out.println(l);
}
for (Token t : result.getStream().getTokens()) {
if (t.getType() == Token.EOF) {
continue;
}
int[] start = file.getLineAndColumn(t.getStartIndex());
int[] end = file.getLineAndColumn(t.getStopIndex());
TextPointer p1 = f.newPointer(t.getStartIndex());
TextPointer p2 = f.newPointer(t.getStopIndex());
Assert.assertNotNull(start);
Assert.assertNotNull(end);
Assert.assertEquals(p1.line(), start[0]);
Assert.assertEquals(p1.lineOffset(), start[1]);
Assert.assertEquals(p2.line(), end[0]);
Assert.assertEquals(p2.lineOffset(), end[1]);
}
}
示例6: AnalysisErrorImpl
import org.sonar.api.batch.fs.TextPointer; //导入依赖的package包/类
public AnalysisErrorImpl(@Nullable String message, @Nullable TextPointer location) {
this.message = message;
this.location = location;
}
示例7: location
import org.sonar.api.batch.fs.TextPointer; //导入依赖的package包/类
@CheckForNull
@Override
public TextPointer location() {
return location;
}
示例8: should_do_nothing_if_message_is_null
import org.sonar.api.batch.fs.TextPointer; //导入依赖的package包/类
@Test
public void should_do_nothing_if_message_is_null() {
AnalysisError notParseError = newAnalysisError(null, mock(TextPointer.class));
assertThat(translator.translate(notParseError)).isEqualTo(notParseError);
}
示例9: should_do_nothing_if_not_parse_error
import org.sonar.api.batch.fs.TextPointer; //导入依赖的package包/类
@Test
public void should_do_nothing_if_not_parse_error() {
AnalysisError notParseError = newAnalysisError("not a parse error", mock(TextPointer.class));
assertThat(translator.translate(notParseError)).isEqualTo(notParseError);
}
示例10: getTextPointer
import org.sonar.api.batch.fs.TextPointer; //导入依赖的package包/类
public TextPointer getTextPointer() {
return new DefaultTextPointer(line, column);
}
示例11: handle
import org.sonar.api.batch.fs.TextPointer; //导入依赖的package包/类
void handle(@Nullable String message, @Nullable TextPointer location);