• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FilePredicates类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: execute

import org.sonar.api.batch.fs.FilePredicates; //导入依赖的package包/类
@Override
public void execute(SensorContext context) {
	LOGGER.info("FramaCSensor is running...");
	FileSystem fs = context.fileSystem();
	LOGGER.info("FramaCSensor : file system base dir = " + fs.baseDir());
	FilePredicates p = fs.predicates();
	LOGGER.info("FramaCSensor : file system base dir = " + fs.hasFiles(p.all()));
	
	readPluginSettings(context);
	
	// Only "main" files, but not "tests"
	String[] aMatchingPatterns = matchingPatterns();
	Iterable<InputFile> filesC = fs.inputFiles(fs.predicates().matchesPathPatterns(aMatchingPatterns));
	for (InputFile file : filesC) {
		LOGGER.debug("FramaCSensor : current input file = " + file.absolutePath());

		// Check for report out
		String fileRelativePathNameReportOut = outReportFileName(file);

		// Analyse report out
		analyseReportOut(context, file, fileRelativePathNameReportOut);
	}
	LOGGER.info("FramaCSensor done!");
}
 
开发者ID:lequal,项目名称:sonar-frama-c-plugin,代码行数:25,代码来源:FramaCMetricsSensor.java


示例2: execute

import org.sonar.api.batch.fs.FilePredicates; //导入依赖的package包/类
@Override
  public void execute(SensorContext context) {
    this.context = context;
    Map<InputFile, Set<Integer>> linesOfCode = new HashMap<>();

    PuppetConfiguration conf = createConfiguration();

    List<SquidAstVisitor<Grammar>> visitors = Lists.newArrayList(checks.all());
    visitors.add(new FileLinesVisitor(fileLinesContextFactory, context.fileSystem(), linesOfCode, conf.getIgnoreHeaderComments()));
    visitors.add(new PuppetHighlighter(context));
    scanner = PuppetAstScanner.create(conf, visitors.toArray(new SquidAstVisitor[visitors.size()]));
    FilePredicates p = context.fileSystem().predicates();
    scanner.scanFiles(Lists.newArrayList(context.fileSystem().files(p.and(p.hasType(InputFile.Type.MAIN), p.hasLanguage(Puppet.KEY)))));

    Collection<SourceCode> squidSourceFiles = scanner.getIndex().search(new QueryByType(SourceFile.class));
    save(squidSourceFiles);
    new ProjectChecks(context).reportProjectIssues();
//    savePreciseIssues(
//      visitors
//        .stream()
//        .filter(v -> v instanceof PuppetCheck)
//        .map(v -> (PuppetCheck) v)
//        .collect(Collectors.toList()));

//    (new PuppetCoverageSensor()).execute(context, linesOfCode);
  }
 
开发者ID:iwarapter,项目名称:sonar-puppet,代码行数:27,代码来源:PuppetSquidSensor.java


示例3: execute

import org.sonar.api.batch.fs.FilePredicates; //导入依赖的package包/类
@Override
public void execute(SensorContext context) {
  FileSystem fileSystem = context.fileSystem();
  FilePredicates predicates = fileSystem.predicates();
  List<SquidAstVisitor<LexerlessGrammar>> visitors = new ArrayList<>(checks.all());
  visitors.add(new FileLinesVisitor(fileLinesContextFactory, fileSystem));
  LuaConfiguration configuration = new LuaConfiguration(fileSystem.encoding());

  scanner = LuaAstScanner.create(configuration, visitors);

  Iterable<java.io.File> files = fileSystem.files(
    predicates.and(
      predicates.hasType(InputFile.Type.MAIN),
      predicates.hasLanguage(Lua.KEY),
      inputFile -> !inputFile.absolutePath().endsWith("mxml")
    ));
  scanner.scanFiles(ImmutableList.copyOf(files));

  Collection<SourceCode> squidSourceFiles = scanner.getIndex().search(new QueryByType(SourceFile.class));
  save(context, squidSourceFiles);
}
 
开发者ID:SonarQubeCommunity,项目名称:sonar-lua,代码行数:22,代码来源:LuaSquidSensor.java


示例4: shouldExecuteOnProject

import org.sonar.api.batch.fs.FilePredicates; //导入依赖的package包/类
@Override
public boolean shouldExecuteOnProject(Project project) {
    final FilePredicates predicates = fileSystem.predicates();
    final Iterable<File> mainFiles = fileSystem
            .files(predicates.and(predicates.hasLanguage(CheckstyleConstants.JAVA_KEY),
                    predicates.hasType(Type.MAIN)));
    final boolean mainFilesIsEmpty = !mainFiles.iterator().hasNext();
    return !mainFilesIsEmpty
            && !profile.getActiveRulesByRepository(CheckstyleConstants.REPOSITORY_KEY)
                    .isEmpty();
}
 
开发者ID:checkstyle,项目名称:sonar-checkstyle,代码行数:12,代码来源:CheckstyleSensor.java


示例5: getSourceFiles

import org.sonar.api.batch.fs.FilePredicates; //导入依赖的package包/类
public List<File> getSourceFiles() {
    final FilePredicates predicates = fileSystem.predicates();
    final Iterable<File> files = fileSystem.files(predicates.and(
            predicates.hasLanguage(CheckstyleConstants.JAVA_KEY),
            predicates.hasType(InputFile.Type.MAIN)));
    final List<File> fileList = new ArrayList<>();
    for (File file : files) {
        fileList.add(file);
    }
    return fileList;
}
 
开发者ID:checkstyle,项目名称:sonar-checkstyle,代码行数:12,代码来源:CheckstyleConfiguration.java


示例6: execute

import org.sonar.api.batch.fs.FilePredicates; //导入依赖的package包/类
@Override
public void execute(final SensorContext context) {
	final FileSystem fileSystem = context.fileSystem();
	final FilePredicates predicates = fileSystem.predicates();
	for (final InputFile inputFile : context.fileSystem().inputFiles(
			predicates.and(predicates.hasLanguage(Rules.LANGUAGE_JAVA), predicates.hasType(Type.MAIN)))) {
		if (inputFile.relativePath().endsWith("/package-info.java")) {
			addMetric(context, inputFile, PackagesMetrics.PACKAGE_INFO_COUNT);
		}
		addMetric(context, inputFile, PackagesMetrics.JAVA_COUNT);
	}
}
 
开发者ID:willemsrb,项目名称:sonar-jdepend-plugin,代码行数:13,代码来源:PackagesSensor.java


示例7: ApexSquidSensor

import org.sonar.api.batch.fs.FilePredicates; //导入依赖的package包/类
/**
 * Default construct to initialize the variables.
 *
 * @param fileSystem source files.
 * @param perspectives perspective from resources.
 * @param checkFactory factory to create a check.
 */
public ApexSquidSensor(FileSystem fileSystem, ResourcePerspectives perspectives, CheckFactory checkFactory) {
    this.checks = checkFactory
            .<SquidAstVisitor<Grammar>>create(CheckList.REPOSITORY_KEY)
            .addAnnotatedChecks(CheckList.getChecks());
    this.fileSystem = fileSystem;
    this.resourcePerspectives = perspectives;

    FilePredicates predicates = fileSystem.predicates();
    filePredicate = predicates.and(
            predicates.hasType(InputFile.Type.MAIN),
            predicates.hasLanguage(Apex.KEY));
}
 
开发者ID:fundacionjala,项目名称:enforce-sonarqube-plugin,代码行数:20,代码来源:ApexSquidSensor.java


示例8: analyse

import org.sonar.api.batch.fs.FilePredicates; //导入依赖的package包/类
@Override
public void analyse(Project project, SensorContext context) {
	this.context = context;
	logger.debug( "** FLowSquidSensor analyse called on project: " +project.getName());
    
	List<SquidAstVisitor<Grammar>> visitors = Lists.newArrayList(checks.all());	
    visitors.add(new FlowLinesOfCodeVisitor<Grammar>(FlowMetric.LINES_OF_CODE));
    logger.debug("** * Visiters: " + visitors.toString());
    
    this.scanner = FlowAstScanner.create(createConfiguration(), visitors.toArray(new SquidAstVisitor[visitors.size()]));
    
    FilePredicates p = fileSystem.predicates();
    logger.debug("** * FilePredicates: " + p.toString() );
    
	ArrayList<File> fileList = Lists.newArrayList(fileSystem.files(p.and(p.hasType(InputFile.Type.MAIN), p.hasLanguage(FlowLanguage.KEY), p.matchesPathPattern("**/flow.xml"))));
	for (File flowFile : fileList)
	{
		try {
			logger.debug("** * Scanning File: "+flowFile.getPath());
			scanner.scanFile(flowFile);
		} catch (Exception e)
		{
			if(settings.getBoolean(FlowPlugin.FAIL_ON_SCANERROR))
				throw e;
			else
				logger.error("** * Exception while scanning file, skipping.",e);
		}
	}
    Collection<SourceCode> squidSourceFiles = scanner.getIndex().search(new QueryByType(SourceFile.class));
    logger.debug("** Done Scanning");

	// Process sourceFiles
	logger.debug("** Getting Interface Files");
	getInterfaceFiles(squidSourceFiles);
	logger.debug("** Setting Top Level Services");
	setTopLevelServices(squidSourceFiles);
	logger.debug("** Saving Source Files");
	save(squidSourceFiles);
}
 
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:40,代码来源:FlowSquidSensor.java


示例9: getInterfaceFiles

import org.sonar.api.batch.fs.FilePredicates; //导入依赖的package包/类
private void getInterfaceFiles(Collection<SourceCode> squidSourceFiles) {
	// Scan node.ndf files
	List<SquidAstVisitor<Grammar>> visitors = Lists.newArrayList(nodeChecks.all());
	AstScanner<Grammar> scanner = NodeAstScanner.create(createConfiguration(), visitors.toArray(new SquidAstVisitor[visitors.size()]));
	FilePredicates p = fileSystem.predicates();
	logger.debug("Scanning Interface Files");
	ArrayList<File> interfaceList = Lists.newArrayList(fileSystem.files(p.and(p.hasType(InputFile.Type.MAIN), p.hasLanguage(FlowLanguage.KEY), p.matchesPathPattern("**/node.ndf"))));
	for (File interfaceFile: interfaceList)
	{
		try {
			logger.debug("** * Scanning File: "+interfaceFile.getPath());
			scanner.scanFile(interfaceFile);
		} catch (Exception e)
		{
			if(settings.getBoolean(FlowPlugin.FAIL_ON_SCANERROR))
				throw e;
			else
				logger.error("** * Exception while scanning file, skipping.",e);
		}
	}
    Collection<SourceCode> nodeFiles = scanner.getIndex().search(new QueryByType(SourceFile.class));
    logger.debug("*NODE* nodes found:" + nodeFiles.size() + " *");
    for(SourceCode squidSourceFile : squidSourceFiles){
    	for(SourceCode nodeFile : nodeFiles){
    		if((new File(nodeFile.getKey())).getParent().equals((new File(squidSourceFile.getKey())).getParent())){
    			squidSourceFile.addChild(nodeFile);
    			String relativePath = pathResolver.relativePath(fileSystem.baseDir(), new java.io.File(nodeFile.getKey()));
    			InputFile inputFile = fileSystem.inputFile(fileSystem.predicates().hasRelativePath(relativePath));
    			saveViolations(inputFile, (SourceFile) nodeFile);
    		}
    		
    	}
    }
}
 
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:35,代码来源:FlowSquidSensor.java


示例10: analyze

import org.sonar.api.batch.fs.FilePredicates; //导入依赖的package包/类
@VisibleForTesting
void analyze(SensorContext context, Coverage coverage) {
  coverageAggregator.aggregate(wildcardPatternFileProvider, coverage);

  for (String filePath : coverage.files()) {
    FilePredicates p = context.fileSystem().predicates();
    InputFile inputFile = context.fileSystem().inputFile(p.and(p.hasType(Type.MAIN), p.hasAbsolutePath(filePath)));

    if (inputFile == null) {
      LOG.debug("Code coverage will not be imported for the following file outside of SonarQube: " + filePath);
      continue;
    }

    if (!coverageConf.languageKey().equals(inputFile.language())) {
      continue;
    }

    NewCoverage newCoverage = context.newCoverage()
      .onFile(inputFile)
      .ofType(isIntegrationTest ? CoverageType.IT : CoverageType.UNIT);

    for (Map.Entry<Integer, Integer> entry : coverage.hits(filePath).entrySet()) {
      newCoverage.lineHits(entry.getKey(), entry.getValue());
    }

    newCoverage.save();
  }
}
 
开发者ID:SonarSource,项目名称:sonar-dotnet-tests-library,代码行数:29,代码来源:CoverageReportImportSensor.java


示例11: collectFileMeasures

import org.sonar.api.batch.fs.FilePredicates; //导入依赖的package包/类
private static void collectFileMeasures(SensorContext context, SMInputCursor clazz) throws XMLStreamException {
  FileSystem fileSystem = context.fileSystem();
  FilePredicates predicates = fileSystem.predicates();
  Map<String, InputFile> inputFileByFilename = new HashMap<>();
  while (clazz.getNext() != null) {
    String fileName = clazz.getAttrValue("filename");

    InputFile inputFile;
    // mxml files are not supported by the plugin
    if (inputFileByFilename.containsKey(fileName)) {
      inputFile = inputFileByFilename.get(fileName);
    } else {
      String key = fileName.startsWith(File.separator) ? fileName : (File.separator + fileName);
      inputFile = fileSystem.inputFile(predicates.and(
        predicates.matchesPathPattern("file:**" + key.replace(File.separator, "/")),
        predicates.hasType(InputFile.Type.MAIN),
        predicates.hasLanguage(Lua.KEY)));
      inputFileByFilename.put(fileName, inputFile);
      if (inputFile == null && !fileName.endsWith(".mxml")) {
        LOG.warn("Cannot save coverage result for file: {}, because resource not found.", fileName);
      }
    }
    if (inputFile != null) {
      collectFileData(
        clazz,
        context.newCoverage()
          .onFile(inputFile)
          .ofType(CoverageType.UNIT)
      );
    } else {
      SMInputCursor line = clazz.childElementCursor("lines").advance().childElementCursor("line");
      while (line.getNext() != null) {
        // advance
      }
    }
  }
}
 
开发者ID:SonarQubeCommunity,项目名称:sonar-lua,代码行数:38,代码来源:CoberturaReportParser.java


示例12: execute

import org.sonar.api.batch.fs.FilePredicates; //导入依赖的package包/类
@Override
public void execute(SensorContext sensorContext) {
  // configure the lexer
  final PageLexer lexer = new PageLexer();

  FileSystem fileSystem = sensorContext.fileSystem();

  // configure page scanner and the visitors
  final HtmlAstScanner scanner = setupScanner(sensorContext);

  FilePredicates predicates = fileSystem.predicates();
  Iterable<InputFile> inputFiles = fileSystem.inputFiles(
    predicates.and(
      predicates.hasType(InputFile.Type.MAIN),
      predicates.hasLanguage(WebConstants.LANGUAGE_KEY))
  );

  for (InputFile inputFile : inputFiles) {
    WebSourceCode sourceCode = new WebSourceCode(inputFile);

    try (FileReader reader = new FileReader(inputFile.file())) {
      scanner.scan(lexer.parse(reader), sourceCode, fileSystem.encoding());
      saveMetrics(sensorContext, sourceCode);
      saveLineLevelMeasures(inputFile, sourceCode);

    } catch (Exception e) {
      LOG.error("Cannot analyze file " + inputFile.file().getAbsolutePath(), e);
    }
  }
}
 
开发者ID:SonarSource,项目名称:sonar-web,代码行数:31,代码来源:WebSensor.java


示例13: predicates

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GestureLibrary类代码示例发布时间:2022-05-21
下一篇:
Java Property类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap