当前位置: 首页>>代码示例>>Java>>正文


Java TextPointer类代码示例

本文整理汇总了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());
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:17,代码来源:AnalysisErrorTranslatorTest.java

示例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;
    }
  };
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:21,代码来源:AnalysisErrorTranslatorTest.java

示例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());
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:9,代码来源:ResponseMessage.java

示例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();
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:14,代码来源:ResponseMessage.java

示例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]);
	}
}
 
开发者ID:gretard,项目名称:sonar-tsql-plugin,代码行数:33,代码来源:AntrlFileTest.java

示例6: AnalysisErrorImpl

import org.sonar.api.batch.fs.TextPointer; //导入依赖的package包/类
public AnalysisErrorImpl(@Nullable String message, @Nullable TextPointer location) {
  this.message = message;
  this.location = location;
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:5,代码来源:AnalysisErrorImpl.java

示例7: location

import org.sonar.api.batch.fs.TextPointer; //导入依赖的package包/类
@CheckForNull
@Override
public TextPointer location() {
  return location;
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:6,代码来源:AnalysisErrorImpl.java

示例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);
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:6,代码来源:AnalysisErrorTranslatorTest.java

示例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);
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:6,代码来源:AnalysisErrorTranslatorTest.java

示例10: getTextPointer

import org.sonar.api.batch.fs.TextPointer; //导入依赖的package包/类
public TextPointer getTextPointer() {
    return new DefaultTextPointer(line, column);
}
 
开发者ID:stryker-mutator,项目名称:sonar-stryker-plugin,代码行数:4,代码来源:Position.java

示例11: handle

import org.sonar.api.batch.fs.TextPointer; //导入依赖的package包/类
void handle(@Nullable String message, @Nullable TextPointer location); 
开发者ID:instalint-org,项目名称:instalint,代码行数:2,代码来源:AnalysisErrorsListener.java


注:本文中的org.sonar.api.batch.fs.TextPointer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。