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


Java ArtifactUtil类代码示例

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


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

示例1: getUsagesInElement

import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
@Override
public List<ProjectStructureElementUsage> getUsagesInElement() {
  final Artifact artifact = myArtifactsStructureContext.getArtifactModel().getArtifactByOriginal(myOriginalArtifact);
  final List<ProjectStructureElementUsage> usages = new ArrayList<ProjectStructureElementUsage>();
  final CompositePackagingElement<?> rootElement = myArtifactsStructureContext.getRootElement(artifact);
  ArtifactUtil.processPackagingElements(rootElement, null, new PackagingElementProcessor<PackagingElement<?>>() {
    @Override
    public boolean process(@NotNull PackagingElement<?> packagingElement, @NotNull PackagingElementPath path) {
      ProjectStructureElement element = getProjectStructureElementFor(packagingElement, ArtifactProjectStructureElement.this.myContext,
                                                                      ArtifactProjectStructureElement.this.myArtifactsStructureContext);
      if (element != null) {
        usages.add(createUsage(packagingElement, element, path.getPathStringFrom("/", rootElement)));
      }
      return true;
    }
  }, myArtifactsStructureContext, false, artifact.getArtifactType());
  return usages;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ArtifactProjectStructureElement.java

示例2: getNotAddedLibraries

import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
private static List<? extends Library> getNotAddedLibraries(@NotNull final ArtifactEditorContext context, @NotNull Artifact artifact,
                                                           List<Library> librariesList) {
  final Set<VirtualFile> roots = new HashSet<VirtualFile>();
  ArtifactUtil.processPackagingElements(artifact, PackagingElementFactoryImpl.FILE_COPY_ELEMENT_TYPE, new Processor<FileCopyPackagingElement>() {
    @Override
    public boolean process(FileCopyPackagingElement fileCopyPackagingElement) {
      final VirtualFile root = fileCopyPackagingElement.getLibraryRoot();
      if (root != null) {
        roots.add(root);
      }
      return true;
    }
  }, context, true);
  final List<Library> result = new ArrayList<Library>();
  for (Library library : librariesList) {
    if (!roots.containsAll(Arrays.asList(library.getFiles(OrderRootType.CLASSES)))) {
      result.add(library);
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ModulesAndLibrariesSourceItemsProvider.java

示例3: getSourceItems

import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
@NotNull
@Override
public Collection<? extends PackagingSourceItem> getSourceItems(@NotNull ArtifactEditorContext editorContext, @NotNull Artifact artifact,
                                                                @Nullable PackagingSourceItem parent) {
  if (parent instanceof ModuleSourceItemGroup) {
    final Module module = ((ModuleSourceItemGroup)parent).getModule();
    final Set<F> facets = new HashSet<F>(editorContext.getFacetsProvider().getFacetsByType(module, myFacetTypeId));
    ArtifactUtil.processPackagingElements(artifact, myElementType, new Processor<E>() {
      @Override
      public boolean process(E e) {
        F facet = getFacet(e);
        if (facet != null) {
          facets.remove(facet);
        }
        return true;
      }
    }, editorContext, true);

    if (!facets.isEmpty()) {
      return Collections.singletonList(new FacetBasedSourceItem<F>(this, facets.iterator().next()));
    }
  }
  return Collections.emptyList();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:FacetBasedPackagingSourceItemsProvider.java

示例4: updateOutputPath

import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
public void updateOutputPath(@NotNull String oldArtifactName, @NotNull final String newArtifactName) {
  final String oldDefaultPath = ArtifactUtil.getDefaultArtifactOutputPath(oldArtifactName, myProject);
  if (Comparing.equal(oldDefaultPath, getConfiguredOutputPath())) {
    setOutputPath(ArtifactUtil.getDefaultArtifactOutputPath(newArtifactName, myProject));
  }
  final CompositePackagingElement<?> root = getRootElement();
  if (root instanceof ArchivePackagingElement) {
    String oldFileName = ArtifactUtil.suggestArtifactFileName(oldArtifactName);
    final String name = ((ArchivePackagingElement)root).getArchiveFileName();
    final String fileName = FileUtil.getNameWithoutExtension(name);
    final String extension = FileUtilRt.getExtension(name);
    if (fileName.equals(oldFileName) && extension.length() > 0) {
      myLayoutTreeComponent.editLayout(new Runnable() {
        @Override
        public void run() {
          ((ArchivePackagingElement)getRootElement()).setArchiveFileName(ArtifactUtil.suggestArtifactFileName(newArtifactName) + "." + extension);
        }
      });
      myLayoutTreeComponent.updateRootNode();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ArtifactEditorImpl.java

示例5: collectIncludedArtifacts

import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
private static void collectIncludedArtifacts(Artifact artifact, final PackagingElementResolvingContext context,
                                             final Set<Artifact> processed, final Set<Artifact> result, final boolean withOutputPathOnly) {
  if (!processed.add(artifact)) {
    return;
  }
  if (!withOutputPathOnly || !StringUtil.isEmpty(artifact.getOutputPath())) {
    result.add(artifact);
  }

  ArtifactUtil.processPackagingElements(artifact, ArtifactElementType.ARTIFACT_ELEMENT_TYPE, new Processor<ArtifactPackagingElement>() {
      @Override
      public boolean process(ArtifactPackagingElement element) {
        Artifact included = element.findArtifact(context);
        if (included != null) {
          collectIncludedArtifacts(included, context, processed, result, withOutputPathOnly);
        }
        return true;
      }
    }, context, false);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ArtifactCompileScope.java

示例6: findOrCreateWebArtifact

import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
@NotNull
private static Artifact findOrCreateWebArtifact(AppEngineFacet appEngineFacet) {
  Module module = appEngineFacet.getModule();
  ArtifactType webArtifactType = AppEngineWebIntegration.getInstance().getAppEngineWebArtifactType();
  final Collection<Artifact> artifacts = ArtifactUtil.getArtifactsContainingModuleOutput(module);
  for (Artifact artifact : artifacts) {
    if (webArtifactType.equals(artifact.getArtifactType())) {
      return artifact;
    }
  }
  ArtifactManager artifactManager = ArtifactManager.getInstance(module.getProject());
  PackagingElementFactory elementFactory = PackagingElementFactory.getInstance();
  ArtifactRootElement<?> root = elementFactory.createArtifactRootElement();
  elementFactory.getOrCreateDirectory(root, "WEB-INF/classes").addOrFindChild(elementFactory.createModuleOutput(module));
  return artifactManager.addArtifact(module.getName(), webArtifactType, root);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AppEngineSupportProvider.java

示例7: findClass

import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
@Override
protected PsiClass findClass(String className) {
  final Set<Module> modules = ApplicationManager.getApplication().runReadAction(new Computable<Set<Module>>() {
    @Override
    public Set<Module> compute() {
      return ArtifactUtil.getModulesIncludedInArtifacts(Collections.singletonList(myArtifact), getProject());
    }
  });
  for (Module module : modules) {
    final PsiClass aClass = JavaExecutionUtil.findMainClass(getProject(), className, GlobalSearchScope.moduleScope(module));
    if (aClass != null) {
      return aClass;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:JavaFxApplicationClassBrowser.java

示例8: findOrCreateWebArtifact

import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
@NotNull
static Artifact findOrCreateWebArtifact(AppEngineStandardFacet appEngineStandardFacet) {
  Module module = appEngineStandardFacet.getModule();
  ArtifactType webArtifactType =
      AppEngineStandardWebIntegration.getInstance().getAppEngineWebArtifactType();
  final Collection<Artifact> artifacts = ArtifactUtil.getArtifactsContainingModuleOutput(module);
  for (Artifact artifact : artifacts) {
    if (webArtifactType.equals(artifact.getArtifactType())) {
      return artifact;
    }
  }
  ArtifactManager artifactManager = ArtifactManager.getInstance(module.getProject());
  PackagingElementFactory elementFactory = PackagingElementFactory.getInstance();
  ArtifactRootElement<?> root = elementFactory.createArtifactRootElement();
  elementFactory
      .getOrCreateDirectory(root, "WEB-INF/classes")
      .addOrFindChild(elementFactory.createModuleOutput(module));
  return artifactManager.addArtifact(module.getName(), webArtifactType, root);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:20,代码来源:AppEngineStandardSupportProvider.java

示例9: findOneAppEngineStandardArtifact

import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
/**
 * Returns the only app engine standard artifact found for the given module or null if there
 * aren't any or more than one.
 */
@Nullable
public static Artifact findOneAppEngineStandardArtifact(@NotNull Module module) {
  Collection<Artifact> artifacts = ArtifactUtil.getArtifactsContainingModuleOutput(module);
  Collection<Artifact> appEngineStandardArtifacts = Lists.newArrayList();
  appEngineStandardArtifacts.addAll(
      artifacts
          .stream()
          .filter(
              artifact ->
                  AppEngineProjectService.getInstance().isAppEngineStandardArtifactType(artifact))
          .collect(toList()));

  return appEngineStandardArtifacts.size() == 1
      ? appEngineStandardArtifacts.iterator().next()
      : null;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:21,代码来源:AppEngineUtil.java

示例10: updateOutputPath

import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
public void updateOutputPath(@NotNull String oldArtifactName, @NotNull final String newArtifactName) {
  final String oldDefaultPath = ArtifactUtil.getDefaultArtifactOutputPath(oldArtifactName, myProject);
  if (Comparing.equal(oldDefaultPath, getConfiguredOutputPath())) {
    setOutputPath(ArtifactUtil.getDefaultArtifactOutputPath(newArtifactName, myProject));
    final CompositePackagingElement<?> root = getRootElement();
    if (root instanceof ArchivePackagingElement) {
      String oldFileName = ArtifactUtil.suggestArtifactFileName(oldArtifactName);
      final String name = ((ArchivePackagingElement)root).getArchiveFileName();
      final String fileName = FileUtil.getNameWithoutExtension(name);
      final String extension = FileUtilRt.getExtension(name);
      if (fileName.equals(oldFileName) && extension.length() > 0) {
        myLayoutTreeComponent.editLayout(new Runnable() {
          @Override
          public void run() {
            ((ArchivePackagingElement)getRootElement()).setArchiveFileName(ArtifactUtil.suggestArtifactFileName(newArtifactName) + "." + extension);
          }
        });
        myLayoutTreeComponent.updateRootNode();
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:ArtifactEditorImpl.java

示例11: findOrCreateArtifact

import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
@NotNull
private static Artifact findOrCreateArtifact(AppEngineFacet appEngineFacet) {
  Module module = appEngineFacet.getModule();
  ArtifactType artifactType = AppEngineWebIntegration.getInstance().getAppEngineTargetArtifactType();
  final Collection<Artifact> artifacts = ArtifactUtil.getArtifactsContainingModuleOutput(module);
  for (Artifact artifact : artifacts) {
    if (artifactType.equals(artifact.getArtifactType())) {
      return artifact;
    }
  }
  ArtifactManager artifactManager = ArtifactManager.getInstance(module.getProject());
  PackagingElementFactory elementFactory = PackagingElementFactory.getInstance();
  ArtifactRootElement<?> root = elementFactory.createArtifactRootElement();
  elementFactory.getOrCreateDirectory(root, "WEB-INF/classes").addOrFindChild(elementFactory.createModuleOutput(module));
  return artifactManager.addArtifact(module.getName(), artifactType, root);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:AppEngineSupportProvider.java

示例12: collectIncludedArtifacts

import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
private static void collectIncludedArtifacts(Artifact artifact, final PackagingElementResolvingContext context,
                                             final Set<Artifact> processed, final Set<Artifact> result, final boolean withOutputPathOnly) {
  if (!processed.add(artifact)) {
    return;
  }
  if (!withOutputPathOnly || !StringUtil.isEmpty(artifact.getOutputPath())) {
    result.add(artifact);
  }

  ArtifactUtil.processPackagingElements(artifact, ArtifactElementType.getInstance(), new Processor<ArtifactPackagingElement>() {
    @Override
    public boolean process(ArtifactPackagingElement element) {
      Artifact included = element.findArtifact(context);
      if (included != null) {
        collectIncludedArtifacts(included, context, processed, result, withOutputPathOnly);
      }
      return true;
    }
  }, context, false);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:ArtifactCompileScope.java

示例13: getUsagesInElement

import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
@Override
public List<ProjectStructureElementUsage> getUsagesInElement() {
  final Artifact artifact = myArtifactsStructureContext.getArtifactModel().getArtifactByOriginal(myOriginalArtifact);
  final List<ProjectStructureElementUsage> usages = new ArrayList<ProjectStructureElementUsage>();
  final CompositePackagingElement<?> rootElement = myArtifactsStructureContext.getRootElement(artifact);
  ArtifactUtil.processPackagingElements(rootElement, null, new PackagingElementProcessor<PackagingElement<?>>() {
    @Override
    public boolean process(@Nonnull PackagingElement<?> packagingElement, @Nonnull PackagingElementPath path) {
      ProjectStructureElement element = getProjectStructureElementFor(packagingElement, ArtifactProjectStructureElement.this.myContext,
                                                                      ArtifactProjectStructureElement.this.myArtifactsStructureContext);
      if (element != null) {
        usages.add(createUsage(packagingElement, element, path.getPathStringFrom("/", rootElement)));
      }
      return true;
    }
  }, myArtifactsStructureContext, false, artifact.getArtifactType());
  return usages;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:ArtifactProjectStructureElement.java

示例14: getNotAddedLibraries

import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
private static List<? extends Library> getNotAddedLibraries(@Nonnull final ArtifactEditorContext context,
                                                            @Nonnull Artifact artifact,
                                                            List<Library> librariesList) {
  final Set<VirtualFile> roots = new HashSet<VirtualFile>();
  ArtifactUtil
    .processPackagingElements(artifact, FileCopyElementType.getInstance(), new Processor<FileCopyPackagingElement>() {
      @Override
      public boolean process(FileCopyPackagingElement fileCopyPackagingElement) {
        final VirtualFile root = fileCopyPackagingElement.getLibraryRoot();
        if (root != null) {
          roots.add(root);
        }
        return true;
      }
    }, context, true);
  final List<Library> result = new ArrayList<Library>();
  for (Library library : librariesList) {
    if (!roots.containsAll(Arrays.asList(library.getFiles(BinariesOrderRootType.getInstance())))) {
      result.add(library);
    }
  }
  return result;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:ModulesAndLibrariesSourceItemsProvider.java

示例15: updateOutputPath

import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
public void updateOutputPath(@Nonnull String oldArtifactName, @Nonnull final String newArtifactName) {
  final String oldDefaultPath = ArtifactUtil.getDefaultArtifactOutputPath(oldArtifactName, myProject);
  if (Comparing.equal(oldDefaultPath, getConfiguredOutputPath())) {
    setOutputPath(ArtifactUtil.getDefaultArtifactOutputPath(newArtifactName, myProject));
    final CompositePackagingElement<?> root = getRootElement();
    if (root instanceof ArchivePackagingElement) {
      String oldFileName = ArtifactUtil.suggestArtifactFileName(oldArtifactName);
      final String name = ((ArchivePackagingElement)root).getArchiveFileName();
      final String fileName = FileUtil.getNameWithoutExtension(name);
      final String extension = FileUtilRt.getExtension(name);
      if (fileName.equals(oldFileName) && extension.length() > 0) {
        myLayoutTreeComponent.editLayout(new Runnable() {
          @Override
          public void run() {
            ((ArchivePackagingElement)getRootElement()).setArchiveFileName(ArtifactUtil.suggestArtifactFileName(newArtifactName) + "." + extension);
          }
        });
        myLayoutTreeComponent.updateRootNode();
      }
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:ArtifactEditorImpl.java


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