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


Java NewCpdTokens类代码示例

本文整理汇总了Java中org.sonar.api.batch.sensor.cpd.NewCpdTokens的典型用法代码示例。如果您正苦于以下问题:Java NewCpdTokens类的具体用法?Java NewCpdTokens怎么用?Java NewCpdTokens使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NewCpdTokens类属于org.sonar.api.batch.sensor.cpd包,在下文中一共展示了NewCpdTokens类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: consumeFor

import org.sonar.api.batch.sensor.cpd.NewCpdTokens; //导入依赖的package包/类
@Override
void consumeFor(InputFile inputFile, CopyPasteTokenInfo message) {
  NewCpdTokens cpdTokens = context.newCpdTokens().onFile(inputFile);

  for (SonarAnalyzer.CopyPasteTokenInfo.TokenInfo tokenInfo : message.getTokenInfoList()) {
    cpdTokens.addToken(toTextRange(inputFile, tokenInfo.getTextRange()), tokenInfo.getTokenValue());
  }
  cpdTokens.save();
}
 
开发者ID:SonarSource,项目名称:sonar-dotnet-shared-library,代码行数:10,代码来源:CPDTokensImporter.java

示例2: addCpdToken

import org.sonar.api.batch.sensor.cpd.NewCpdTokens; //导入依赖的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

示例3: visitFile

import org.sonar.api.batch.sensor.cpd.NewCpdTokens; //导入依赖的package包/类
@Override
public void visitFile(@Nullable AstNode astNode) {
  NewHighlighting highlighting = context.newHighlighting();
  File file = getContext().getFile();
  InputFile inputFile = context.fileSystem().inputFile(context.fileSystem().predicates().is(file));
  highlighting.onFile(inputFile);

  NewCpdTokens cpdTokens = context.newCpdTokens();
  cpdTokens.onFile(inputFile);

  Iterator<Token> iterator = lexer.lex(file).iterator();
 

  while (iterator.hasNext()) {
    Token token = iterator.next();
    TokenType tokenType = token.getType();
    
       if (!tokenType.equals(GenericTokenType.EOF)) {
      TokenLocation tokenLocation = new TokenLocation(token);
      cpdTokens.addToken(tokenLocation.startLine(), tokenLocation.startCharacter(), tokenLocation.endLine(), tokenLocation.endCharacter(), getTokenImage(token));
    }
    if (tokenType.equals(LuaTokenType.NUMBER)) {
      highlight(highlighting, token, TypeOfText.CONSTANT);
    } else if (tokenType.equals(GenericTokenType.LITERAL)) {
      highlight(highlighting, token, TypeOfText.STRING);
    } else if (KEYWORDS.contains(tokenType)) {
      highlight(highlighting, token, TypeOfText.KEYWORD);
    }
    for (Trivia trivia : token.getTrivia()) {
      highlight(highlighting, trivia.getToken(), TypeOfText.COMMENT);
    }
  }

  highlighting.save();
  cpdTokens.save();
}
 
开发者ID:SonarQubeCommunity,项目名称:sonar-lua,代码行数:37,代码来源:LuaTokensVisitor.java

示例4: newCpdTokens

import org.sonar.api.batch.sensor.cpd.NewCpdTokens; //导入依赖的package包/类
@Override
public NewCpdTokens newCpdTokens() {
  return NO_OP_NEW_CPD_TOKENS;
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:5,代码来源:DefaultSensorContext.java


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