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


Java Type类代码示例

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


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

示例1: create

import org.sonar.api.batch.fs.InputFile.Type; //导入依赖的package包/类
@CheckForNull
SonarLintInputFile create(ClientInputFile inputFile) {
  SonarLintInputFile defaultInputFile = new SonarLintInputFile(inputFile);
  defaultInputFile.setType(inputFile.isTest() ? Type.TEST : Type.MAIN);
  if (inputFile.language() != null) {
    LOG.debug("Language of file '{}' is set to '{}'", inputFile.getPath(), inputFile.language());
    defaultInputFile.setLanguage(inputFile.language());
  } else {
    defaultInputFile.setLanguage(langDetection.language(defaultInputFile));
  }

  Charset charset = inputFile.getCharset();
  InputStream stream;
  try {
    stream = inputFile.inputStream();
  } catch (IOException e) {
    throw new IllegalStateException("Failed to open a stream on file: " + inputFile.getPath(), e);
  }
  defaultInputFile.init(fileMetadata.readMetadata(stream, charset != null ? charset : Charset.defaultCharset(), inputFile.getPath()));
  return defaultInputFile;
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:22,代码来源:InputFileBuilder.java

示例2: testExecute

import org.sonar.api.batch.fs.InputFile.Type; //导入依赖的package包/类
@Test
public void testExecute() {
	// Sensor context
	final SensorContextTester sensorContext = SensorContextTester.create(new File("."));
	addFile(sensorContext, "/packagea/package-info.java", "java", Type.MAIN);
	addFile(sensorContext, "/packagea/ClassA.java", "java", Type.MAIN);
	addFile(sensorContext, "/packageb/package-info.java", "java", Type.TEST);
	addFile(sensorContext, "/packageb/ClassB.java", "java", Type.TEST);
	addFile(sensorContext, "/packagec/ClassC.pas", "pascal", Type.MAIN);

	// Execute
	final PackagesSensor subject = new PackagesSensor();
	subject.execute(sensorContext);

	// Check counts
	checkMetrics(sensorContext, "moduleKey:/packagea/package-info.java", 1, 1);
	checkMetrics(sensorContext, "moduleKey:/packagea/ClassA.java", null, 1);
	checkMetrics(sensorContext, "moduleKey:/packageb/package-info.java", null, null);
	checkMetrics(sensorContext, "moduleKey:/packageb/ClassB.java", null, null);
	checkMetrics(sensorContext, "moduleKey:/packagec/ClassC.pas", null, null);
}
 
开发者ID:willemsrb,项目名称:sonar-jdepend-plugin,代码行数:22,代码来源:PackagesSensorTest.java

示例3: JavaPropertiesSquidSensor

import org.sonar.api.batch.fs.InputFile.Type; //导入依赖的package包/类
public JavaPropertiesSquidSensor(FileSystem fileSystem, CheckFactory checkFactory, @Nullable CustomJavaPropertiesRulesDefinition[] customRulesDefinition) {
  this.fileSystem = fileSystem;

  this.charset = Charset.forName("ISO-8859-1");

  this.mainFilePredicate = fileSystem.predicates().and(
    fileSystem.predicates().hasType(InputFile.Type.MAIN),
    fileSystem.predicates().hasLanguage(JavaPropertiesLanguage.KEY));

  this.parser = JavaPropertiesParserBuilder.createParser(charset);

  this.checks = JavaPropertiesChecks.createJavaPropertiesChecks(checkFactory)
    .addChecks(GenericJavaPropertiesRulesDefinition.GENERIC_REPOSITORY_KEY, GenericJavaPropertiesRulesDefinition.getChecks())
    .addChecks(SonarScannerJavaPropertiesRulesDefinition.SONAR_SCANNER_REPOSITORY_KEY, SonarScannerJavaPropertiesRulesDefinition.getChecks())
    .addCustomChecks(customRulesDefinition);
}
 
开发者ID:racodond,项目名称:sonar-jproperties-plugin,代码行数:17,代码来源:JavaPropertiesSquidSensor.java

示例4: sensor_descriptor

import org.sonar.api.batch.fs.InputFile.Type; //导入依赖的package包/类
@Test
public void sensor_descriptor() {
    DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor();
    createSensor().describe(descriptor);

    assertThat(descriptor.name()).isEqualTo("1C 7.7 sensor");
    assertThat(descriptor.languages()).containsOnly("1c 7.7");
    assertThat(descriptor.type()).isEqualTo(Type.MAIN);
}
 
开发者ID:antowski,项目名称:sonar-onec,代码行数:10,代码来源:OneCSensorTest.java

示例5: buildModel

import org.sonar.api.batch.fs.InputFile.Type; //导入依赖的package包/类
@Override
protected Model<Location> buildModel(final SensorContext context) {
	// Result
	final Model<Location> model = new Model<>();
	final ModelCreatingTreeVisitor visitor = new ModelCreatingTreeVisitor(model);

	// Read all source files
	final ActionParser<Tree> parser = JavaParser.createParser();
	final JavaClasspath javaClassPath = new JavaClasspath(settings, context.fileSystem());
	final FileSystem fs = context.fileSystem();

	// Scan only main files for the 'current' language.
	final FilePredicate filesToScan = fs.predicates().and(fs.predicates().hasType(Type.MAIN),
			fs.predicates().hasLanguage(LANGUAGE));

	for (final InputFile file : fs.inputFiles(filesToScan)) {
		// Parse source
		LOGGER.debug("Analyzing source file: {}", file.relativePath());
		try {
			visitor.on(file);
			final Tree tree = parser.parse(file.contents());

			// Create semantic model
			LOGGER.debug("Creating semantic model ...");
			SemanticModel.createFor((CompilationUnitTree) tree, javaClassPath.getElements());

			// Read into model
			LOGGER.debug("Reading model ...");
			tree.accept(visitor);

		} catch (final IOException e) {
			LOGGER.warn("Could not read contents for {}", file.relativePath(), e);
		}
	}
	return model;
}
 
开发者ID:willemsrb,项目名称:sonar-packageanalyzer-plugin,代码行数:37,代码来源:JavaSensor.java

示例6: describe

import org.sonar.api.batch.fs.InputFile.Type; //导入依赖的package包/类
@Override
public void describe(SensorDescriptor descriptor) {
  descriptor
    .onlyOnLanguage(CssLanguage.KEY)
    .name("CSS Analyzer Sensor")
    .onlyOnFileType(Type.MAIN);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:8,代码来源:CssAnalyzerSensor.java

示例7: describe

import org.sonar.api.batch.fs.InputFile.Type; //导入依赖的package包/类
@Override
public void describe(SensorDescriptor descriptor) {
  descriptor
    .onlyOnLanguage(LessLanguage.KEY)
    .name("Less Analyzer Sensor")
    .onlyOnFileType(Type.MAIN);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:8,代码来源:LessAnalyzerSensor.java

示例8: describe

import org.sonar.api.batch.fs.InputFile.Type; //导入依赖的package包/类
@Override
public void describe(SensorDescriptor descriptor) {
  descriptor
    .onlyOnLanguage(ScssLanguage.KEY)
    .name("SCSS Analyzer Sensor")
    .onlyOnFileType(Type.MAIN);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:8,代码来源:ScssAnalyzerSensor.java

示例9: shouldExecuteOnProject

import org.sonar.api.batch.fs.InputFile.Type; //导入依赖的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

示例10: execute

import org.sonar.api.batch.fs.InputFile.Type; //导入依赖的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

示例11: addFile

import org.sonar.api.batch.fs.InputFile.Type; //导入依赖的package包/类
private void addFile(final SensorContextTester sensorContext, final String name, final String language,
		final Type type) {
	final DefaultInputFile file = new DefaultInputFile("moduleKey", name);
	file.setLanguage(language);
	file.setType(type);

	sensorContext.fileSystem().add(file);
}
 
开发者ID:willemsrb,项目名称:sonar-jdepend-plugin,代码行数:9,代码来源:PackagesSensorTest.java

示例12: describe

import org.sonar.api.batch.fs.InputFile.Type; //导入依赖的package包/类
@Override
public void describe(SensorDescriptor descriptor) {
  descriptor
    .onlyOnLanguage(PerlLanguage.KEY)
    .name("Perl Sensor")
    .onlyOnFileType(Type.MAIN);
}
 
开发者ID:sonar-perl,项目名称:sonar-perl,代码行数:8,代码来源:GlobalSensor.java

示例13: execute

import org.sonar.api.batch.fs.InputFile.Type; //导入依赖的package包/类
@Override
public void execute(SensorContext context) {
    FileSystem fileSystem = context.fileSystem();

    FilePredicate mainFilePredicate = fileSystem.predicates().and(
      fileSystem.predicates().hasType(InputFile.Type.MAIN),
      fileSystem.predicates().hasLanguage(PerlLanguage.KEY));

    List<InputFile> inputFiles = new ArrayList<>();
    fileSystem.inputFiles(mainFilePredicate).forEach(inputFiles::add);

    for (InputFile inputFile : inputFiles) {
        this.analyseFile(inputFile, fileSystem.encoding(), context);
    }
}
 
开发者ID:sonar-perl,项目名称:sonar-perl,代码行数:16,代码来源:GlobalSensor.java

示例14: describe

import org.sonar.api.batch.fs.InputFile.Type; //导入依赖的package包/类
@Override
public void describe(SensorDescriptor descriptor) {
    descriptor
    .onlyOnLanguage(PerlLanguage.KEY)
    .name("Perl Test::Harness Sensor")
    .onlyOnFileType(Type.TEST);
}
 
开发者ID:sonar-perl,项目名称:sonar-perl,代码行数:8,代码来源:TestHarnessLoaderSensor.java

示例15: getUnitTestInputFile

import org.sonar.api.batch.fs.InputFile.Type; //导入依赖的package包/类
/**
 * Gets the file pointed by the report.
 *
 * @param report the unit test report
 */
private InputFile getUnitTestInputFile(String filePath) {
  return fileSystem.inputFile(fileSystem.predicates().and(
    filePredicates.hasPath(filePath),
    filePredicates.hasType(InputFile.Type.TEST),
    filePredicates.hasLanguage(PerlLanguage.KEY)));
}
 
开发者ID:sonar-perl,项目名称:sonar-perl,代码行数:12,代码来源:TestHarnessLoaderSensor.java


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