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


Java TextRange类代码示例

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

示例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();
}
 
开发者ID:SonarSource,项目名称:sonar-dotnet-shared-library,代码行数:26,代码来源:IssuesImporterTest.java

示例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());
	}
}
 
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:20,代码来源:XanitizerSensor.java

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

示例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);
}
 
开发者ID:willemsrb,项目名称:sonar-packageanalyzer-plugin,代码行数:9,代码来源:BaseRuleTest.java

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

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

示例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());
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:15,代码来源:CpdVisitor.java

示例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);
}
 
开发者ID:SonarSource,项目名称:sonar-dotnet-shared-library,代码行数:8,代码来源:SensorContextUtils.java

示例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);

		}

	}
}
 
开发者ID:gretard,项目名称:sonar-tsql-plugin,代码行数:13,代码来源:AntlrHighlighter.java

示例11: getAt

import org.sonar.api.batch.fs.TextRange; //导入依赖的package包/类
public TextRange getAt() {
	return at;
}
 
开发者ID:willemsrb,项目名称:sonar-packageanalyzer-plugin,代码行数:4,代码来源:Location.java

示例12: newSymbol

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

示例13: newReference

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

示例14: addToken

import org.sonar.api.batch.fs.TextRange; //导入依赖的package包/类
@Override
public NoOpNewCpdTokens addToken(TextRange range, String image) {
  // Do nothing
  return this;
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:6,代码来源:NoOpNewCpdTokens.java

示例15: highlight

import org.sonar.api.batch.fs.TextRange; //导入依赖的package包/类
@Override
public NoOpNewHighlighting highlight(TextRange range, TypeOfText typeOfText) {
  // Do nothing
  return this;
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:6,代码来源:NoOpNewHighlighting.java


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