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

Java CompileContext类代码示例

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

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



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

示例1: instrument

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
@Nullable
@Override
protected BinaryContent instrument(final CompileContext context,
                                   final CompiledClass compiled,
                                   final ClassReader reader,
                                   final ClassWriter writer,
                                   final InstrumentationClassFinder finder) {
  final long ms = System.currentTimeMillis();
  String className = compiled.getClassName();
  if (className == null) {
    LOG.debug("class name is empty for " + compiled.getOutputFile().getAbsolutePath());
  }
  else {
    className = className.replace('.', '/');
    for (final ClassFilesIndexWriter index : myIndexWriters) {
      index.update(className, reader);
    }
  }
  myMs.addAndGet(System.currentTimeMillis() - ms);
  myFilesCount.incrementAndGet();
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ClassFilesIndicesBuilder.java


示例2: build

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
@Override
public void build(CompileContext context) throws ProjectBuildException {
  final Set<JpsSdk<?>> sdks = context.getProjectDescriptor().getProjectJavaSdks();
  JpsSdk javaSdk = null;
  for (JpsSdk<?> sdk : sdks) {
    final JpsSdkType<? extends JpsElement> sdkType = sdk.getSdkType();
    if (sdkType instanceof JpsJavaSdkType) {
      javaSdk = sdk;
      break;
    }
  }
  if (javaSdk == null) {
    context.processMessage(new CompilerMessage(COMPILER_NAME, BuildMessage.Kind.ERROR, "Java version 7 or higher is required to build JavaFX package"));
    return;
  }
  new JpsJavaFxPackager(myProps, context, myArtifact).buildJavaFxArtifact(javaSdk.getHomePath());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JpsJavaFxArtifactBuildTaskProvider.java


示例3: instrument

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
@Override
@Nullable
protected BinaryContent instrument(CompileContext context,
                                   CompiledClass compiledClass,
                                   ClassReader reader,
                                   ClassWriter writer,
                                   InstrumentationClassFinder finder) {
  try {
    if (NotNullVerifyingInstrumenter.processClassFile(reader, writer)) {
      return new BinaryContent(writer.toByteArray());
    }
  }
  catch (Throwable e) {
    final StringBuilder msg = new StringBuilder();
    msg.append("@NotNull instrumentation failed ");
    final File sourceFile = compiledClass.getSourceFile();
    msg.append(" for ").append(sourceFile.getName());
    msg.append(": ").append(e.getMessage());
    context.processMessage(new CompilerMessage(getPresentableName(), BuildMessage.Kind.ERROR, msg.toString(), sourceFile.getPath()));
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:NotNullInstrumentingBuilder.java


示例4: isTargetDirty

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
public boolean isTargetDirty(CompileContext context) {
  final String currentState = getCurrentState(context);
  if (!currentState.equals(myConfiguration)) {
    LOG.debug(myTarget + " configuration was changed:");
    LOG.debug("Old:");
    LOG.debug(myConfiguration);
    LOG.debug("New:");
    LOG.debug(currentState);
    LOG.debug(myTarget + " will be recompiled");
    if (myTarget instanceof ModuleBuildTarget) {
      final JpsModule module = ((ModuleBuildTarget)myTarget).getModule();
      synchronized (MODULES_WITH_TARGET_CONFIG_CHANGED_KEY) {
        Set<JpsModule> modules = MODULES_WITH_TARGET_CONFIG_CHANGED_KEY.get(context);
        if (modules == null) {
          MODULES_WITH_TARGET_CONFIG_CHANGED_KEY.set(context, modules = new THashSet<JpsModule>());
        }
        modules.add(module);
      }
    }
    return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:BuildTargetConfiguration.java


示例5: save

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
public void save(CompileContext context) {
  try {
    File configFile = getConfigFile();
    FileUtil.createParentDirs(configFile);
    Writer out = new BufferedWriter(new FileWriter(configFile));
    try {
      String current = getCurrentState(context);
      out.write(current);
      myConfiguration = current;
    }
    finally {
      out.close();
    }
  }
  catch (IOException e) {
    LOG.info("Cannot save configuration of " + myConfiguration, e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:BuildTargetConfiguration.java


示例6: storeNonexistentOutputRoots

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
public void storeNonexistentOutputRoots(CompileContext context) throws IOException {
  Collection<File> outputRoots = myTarget.getOutputRoots(context);
  List<String> nonexistentOutputRoots = new SmartList<String>();
  for (File root : outputRoots) {
    if (!root.exists()) {
      nonexistentOutputRoots.add(root.getAbsolutePath());
    }
  }
  File file = getNonexistentOutputsFile();
  if (nonexistentOutputRoots.isEmpty()) {
    file.delete();
  }
  else {
    FileUtil.writeToFile(file, StringUtil.join(nonexistentOutputRoots, "\n"));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:BuildTargetConfiguration.java


示例7: findParentDescriptor

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
@Override
@Nullable
public <R extends BuildRootDescriptor> R findParentDescriptor(@NotNull File file, @NotNull Collection<? extends BuildTargetType<? extends BuildTarget<R>>> types,
                                                              @Nullable CompileContext context) {
  File current = file;
  int depth = 0;
  while (current != null) {
    final List<R> descriptors = filterDescriptorsByFile(getRootDescriptors(current, types, context), file, depth);
    if (!descriptors.isEmpty()) {
      return descriptors.get(0);
    }
    current = FileUtilRt.getParentFile(current);
    depth++;
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:BuildRootIndexImpl.java


示例8: findAllParentDescriptors

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
@Override
@NotNull
public <R extends BuildRootDescriptor> Collection<R> findAllParentDescriptors(@NotNull File file,
                                                                              @Nullable Collection<? extends BuildTargetType<? extends BuildTarget<R>>> types,
                                                                              @Nullable CompileContext context) {
  File current = file;
  List<R> result = null;
  int depth = 0;
  while (current != null) {
    List<R> descriptors = filterDescriptorsByFile(getRootDescriptors(current, types, context), file, depth);
    if (!descriptors.isEmpty()) {
      if (result == null) {
        result = descriptors;
      }
      else {
        result = new ArrayList<R>(result);
        result.addAll(descriptors);
      }
    }
    current = FileUtilRt.getParentFile(current);
    depth++;
  }
  return result != null ? result : Collections.<R>emptyList();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:BuildRootIndexImpl.java


示例9: instrument

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
@Nullable
@Override
protected BinaryContent instrument(CompileContext context, CompiledClass compiled, ClassReader reader, ClassWriter writer, InstrumentationClassFinder finder) {
  final JpsIntelliLangConfiguration config =
    JpsIntelliLangExtensionService.getInstance().getConfiguration(context.getProjectDescriptor().getModel().getGlobal());
  final PatternInstrumenter instrumenter =
    new PatternInstrumenter(config.getPatternAnnotationClass(), writer, config.getInstrumentationType(), finder);
  try {
    reader.accept(instrumenter, 0);
    if (instrumenter.instrumented()) {
      return new BinaryContent(writer.toByteArray());
    }
  }
  catch (InstrumentationException e) {
    context.processMessage(new CompilerMessage(getPresentableName(), BuildMessage.Kind.ERROR, e.getMessage()));
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PatternValidatorBuilder.java


示例10: buildTarget

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
@Override
protected void buildTarget(@NotNull AndroidResourcePackagingBuildTarget target,
                           @NotNull DirtyFilesHolder<BuildRootDescriptor, AndroidResourcePackagingBuildTarget> holder,
                           @NotNull BuildOutputConsumer outputConsumer,
                           @NotNull CompileContext context) throws ProjectBuildException, IOException {
  final boolean releaseBuild = AndroidJpsUtil.isReleaseBuild(context);
  final AndroidPackagingStateStorage packagingStateStorage =
    context.getProjectDescriptor().dataManager.getStorage(target, AndroidPackagingStateStorage.Provider.INSTANCE);

  if (!holder.hasDirtyFiles() && !holder.hasRemovedFiles()) {
    final AndroidPackagingStateStorage.MyState savedState = packagingStateStorage.read();

    if (savedState != null && savedState.isRelease() == releaseBuild) {
      return;
    }
  }
  assert !AndroidJpsUtil.isLightBuild(context);

  if (!packageResources(target, context, outputConsumer, releaseBuild)) {
    throw new StopBuildException();
  }
  packagingStateStorage.saveState(new AndroidPackagingStateStorage.MyState(releaseBuild));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AndroidResourcePackagingBuilder.java


示例11: getOutputRoots

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
@NotNull
@Override
public Collection<File> getOutputRoots(CompileContext context) {
  final File moduleOutputDir = ProjectPaths.getModuleOutputDir(myModule, false);
  final JpsAndroidModuleExtension extension = AndroidJpsUtil.getExtension(myModule);

  if (moduleOutputDir == null || extension == null) {
    return Collections.emptyList();
  }
  final String outputPath = AndroidJpsUtil.getApkPath(extension, moduleOutputDir);

  if (outputPath == null) {
    return Collections.emptyList();
  }
  return Collections.singletonList(new File(outputPath));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AndroidPackagingBuildTarget.java


示例12: copyFile

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
public void copyFile(File file, Ref<File> targetFileRef, ResourceRootConfiguration rootConfiguration, CompileContext context,
                     FileFilter filteringFilter) throws IOException {
  boolean shouldFilter = rootConfiguration.isFiltered && !rootConfiguration.filters.isEmpty() && filteringFilter.accept(file);
  if (shouldFilter && file.length() > FILTERING_SIZE_LIMIT) {
    context.processMessage(new CompilerMessage(
      GradleResourcesBuilder.BUILDER_NAME, BuildMessage.Kind.WARNING,
      "File is too big to be filtered. Most likely it is a binary file and should be excluded from filtering", file.getPath())
    );
    shouldFilter = false;
  }
  if (shouldFilter) {
    copyWithFiltering(file, targetFileRef, rootConfiguration.filters, context);
  }
  else {
    FileUtil.copyContent(file, targetFileRef.get());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GradleResourceFileProcessor.java


示例13: copyWithFiltering

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
private static void copyWithFiltering(File file, Ref<File> outputFileRef, List<ResourceRootFilter> filters, CompileContext context)
  throws IOException {
  final FileInputStream originalInputStream = new FileInputStream(file);
  try {
    final InputStream inputStream = transform(filters, originalInputStream, outputFileRef, context);
    FileUtil.createIfDoesntExist(outputFileRef.get());
    FileOutputStream outputStream = new FileOutputStream(outputFileRef.get());
    try {
      FileUtil.copy(inputStream, outputStream);
    }
    finally {
      StreamUtil.closeStream(inputStream);
      StreamUtil.closeStream(outputStream);
    }
  }
  finally {
    StreamUtil.closeStream(originalInputStream);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GradleResourceFileProcessor.java


示例14: getOutputRoots

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
@NotNull
@Override
public Collection<File> getOutputRoots(CompileContext context) {
  MavenModuleResourceConfiguration configuration =
    getModuleResourcesConfiguration(context.getProjectDescriptor().dataManager.getDataPaths());
  if (configuration == null) return Collections.emptyList();

  final Set<File> result = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY);
  final File moduleOutput = getModuleOutputDir();
  for (ResourceRootConfiguration resConfig : getRootConfigurations(configuration)) {
    final File output = getOutputDir(moduleOutput, resConfig, configuration.outputDirectory);
    if (output != null) {
      result.add(output);
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:MavenResourcesTarget.java


示例15: build

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
@Override
public void build(CompileContext context) throws ProjectBuildException {
  BuildDataPaths dataPaths = context.getProjectDescriptor().dataManager.getDataPaths();
  MavenProjectConfiguration projectConfiguration = JpsMavenExtensionService.getInstance().getMavenProjectConfiguration(dataPaths);
  if (projectConfiguration == null) return;

  final MavenModuleResourceConfiguration moduleResourceConfiguration = projectConfiguration.moduleConfigurations.get(getModuleName(myArtifact.getName()));
  if (moduleResourceConfiguration != null && StringUtil.isNotEmpty(moduleResourceConfiguration.manifest)) {
    try {
      File output = new File(myArtifact.getOutputPath(), JarFile.MANIFEST_NAME);
      FileUtil.writeToFile(output, Base64.decode(moduleResourceConfiguration.manifest));
      handleSkinnyWars(context, projectConfiguration, moduleResourceConfiguration);
    }
    // do not fail the whole 'Make' if there is an invalid manifest cached (e.g. non encoded string generated by previous IDEA version)
    catch (Exception e) {
      LOG.debug(e);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:MavenManifestGenerationBuildTaskProvider.java


示例16: copyFile

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
public void copyFile(File file, File targetFile, ResourceRootConfiguration rootConfiguration, CompileContext context,
                     FileFilter filteringFilter) throws IOException {
  boolean shouldFilter = rootConfiguration.isFiltered && !myFilteringExcludedExtensions.contains(FileUtilRt.getExtension(file.getName()))
                         && filteringFilter.accept(file);
  if (shouldFilter && file.length() > FILTERING_SIZE_LIMIT) {
    context.processMessage(new CompilerMessage("MavenResources", BuildMessage.Kind.WARNING,
                                               "File is too big to be filtered. Most likely it is a binary file and should be excluded from filtering",
                                               file.getPath()));
    shouldFilter = false;
  }
  if (shouldFilter) {
    copyWithFiltering(file, targetFile);
  }
  else {
    FileUtil.copyContent(file, targetFile);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:MavenResourceFileProcessor.java


示例17: buildStarted

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void buildStarted(final CompileContext context) {
  super.buildStarted(context);
  final boolean isEnabled = isEnabled();
  LOG.info("class files data index " + (isEnabled ? "enabled" : "disabled"));
  if (!isEnabled) {
    return;
  }
  final Set<String> enabledIndicesBuilders = ContainerUtil.newHashSet(System.getProperty(PROPERTY_NAME).split(";"));
  final boolean forcedRecompilation = JavaBuilderUtil.isForcedRecompilationAllJavaModules(context);
  final Iterable<ClassFileIndexerFactory> extensions = JpsServiceManager.getInstance().getExtensions(ClassFileIndexerFactory.class);
  int newIndicesCount = 0;
  for (final ClassFileIndexerFactory builder : extensions) {
    if (enabledIndicesBuilders.contains(builder.getClass().getName())) {
      final ClassFilesIndexWriter indexWriter = new ClassFilesIndexWriter(builder.create(), context);
      if (!indexWriter.isEmpty()) {
        myIndexWriters.add(indexWriter);
      }
      else if (forcedRecompilation) {
        newIndicesCount++;
        myIndexWriters.add(indexWriter);
      }
      else {
        indexWriter.close(context);
      }
    }
  }
  if (forcedRecompilation) {
    LOG.info(String.format("class files indexing: %d indices, %d new", myIndexWriters.size(), newIndicesCount));
  }
  else {
    LOG.info(String.format("class files indexing: %d indices", myIndexWriters.size()));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:ClassFilesIndicesBuilder.java


示例18: buildFinished

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
@Override
public void buildFinished(final CompileContext context) {
  super.buildFinished(context);
  if (!isEnabled()) {
    return;
  }
  final long ms = System.currentTimeMillis();
  for (final ClassFilesIndexWriter index : myIndexWriters) {
    index.close(context);
  }
  myIndexWriters.clear();
  myMs.addAndGet(System.currentTimeMillis() - ms);
  LOG.info("class files indexing finished for " + myFilesCount.get() + " files in " + myMs.get() + "ms");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ClassFilesIndicesBuilder.java


示例19: ClassFilesIndexWriter

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
protected ClassFilesIndexWriter(final ClassFileIndexer<K, V> indexer, final CompileContext compileContext) {
  myIndexer = indexer;
  final File storageDir = getIndexRoot(compileContext);
  final Set<String> containingFileNames = listFiles(storageDir);
  if (!containingFileNames.contains("version") || !containingFileNames.contains(IndexState.STATE_FILE_NAME)) {
    throw new IllegalStateException("version or state file for index " + indexer.getIndexCanonicalName() + " not found in " + storageDir.getAbsolutePath());
  }
  ClassFilesIndexStorageWriter<K, V> index = null;
  IOException exception = null;
  LOG.debug("start open... " + indexer.getIndexCanonicalName());
  myMappings = compileContext.getProjectDescriptor().dataManager.getMappings();
  for (int attempt = 0; attempt < 2; attempt++) {
    try {
      index = new ClassFilesIndexStorageWriter<K, V>(storageDir,
                                                     myIndexer.getKeyDescriptor(),
                                                     myIndexer.getDataExternalizer(),
                                                     myMappings);
      break;
    }
    catch (final IOException e) {
      exception = e;
      PersistentHashMap.deleteFilesStartingWith(ClassFilesIndexStorageBase.getIndexFile(storageDir));
    }
  }
  LOG.debug("opened " + indexer.getIndexCanonicalName());
  if (index == null) {
    throw new RuntimeException(exception);
  }
  myIndex = index;
  myEmpty = IndexState.EXIST != IndexState.load(storageDir) || exception != null;
  IndexState.CORRUPTED.save(storageDir);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:ClassFilesIndexWriter.java


示例20: getCompilationUnitPatchers

import org.jetbrains.jps.incremental.CompileContext; //导入依赖的package包/类
@NotNull
@Override
public Collection<String> getCompilationUnitPatchers(@NotNull CompileContext context, @NotNull ModuleChunk chunk) {
  for (JpsModule module : chunk.getModules()) {
    if (shouldInjectGriffon(module)) {
      return Collections.singleton("org.jetbrains.groovy.compiler.rt.GriffonInjector");
    }
  }
  return Collections.emptyList();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:GriffonBuilderExtension.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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