Java Code Examples for com.intellij.openapi.util.io.FileUtilRt#extensionEquals()

The following examples show how to use com.intellij.openapi.util.io.FileUtilRt#extensionEquals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlazeLibrary.java    From intellij with Apache License 2.0 6 votes vote down vote up
protected static String pathToUrl(File path) {
  String name = path.getName();
  boolean isJarFile =
      FileUtilRt.extensionEquals(name, "jar")
          || FileUtilRt.extensionEquals(name, "srcjar")
          || FileUtilRt.extensionEquals(name, "zip");
  // .jar files require an URL with "jar" protocol.
  String protocol =
      isJarFile
          ? StandardFileSystems.JAR_PROTOCOL
          : VirtualFileSystemProvider.getInstance().getSystem().getProtocol();
  String filePath = FileUtil.toSystemIndependentName(path.getPath());
  String url = VirtualFileManager.constructUrl(protocol, filePath);
  if (isJarFile) {
    url += URLUtil.JAR_SEPARATOR;
  }
  return url;
}
 
Example 2
Source File: PantsUtil.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
public static boolean isGeneratableFile(@NotNull String path) {
  // todo(fkorotkov): make it configurable or get it from patns.
  // maybe mark target as a target that generates sources and
  // we need to refresh the project for any change in the corresponding module
  // https://github.com/pantsbuild/intellij-pants-plugin/issues/13
  return FileUtilRt.extensionEquals(path, PantsConstants.THRIFT_EXT) ||
         FileUtilRt.extensionEquals(path, PantsConstants.ANTLR_EXT) ||
         FileUtilRt.extensionEquals(path, PantsConstants.ANTLR_4_EXT) ||
         FileUtilRt.extensionEquals(path, PantsConstants.PROTOBUF_EXT);
}
 
Example 3
Source File: NMEBuildDirectoryInspection.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
  final boolean isNmml = FileUtilRt.extensionEquals(file.getName(), NMMLFileType.DEFAULT_EXTENSION);
  if (!isNmml || !(file instanceof XmlFile)) {
    return ProblemDescriptor.EMPTY_ARRAY;
  }
  MyVisitor visitor = new MyVisitor();
  file.accept(visitor);

  if (ContainerUtil.exists(visitor.getResult(), new Condition<XmlTag>() {
    @Override
    public boolean value(XmlTag tag) {
      final XmlAttribute ifAttribute = tag.getAttribute("if");
      return "debug".equals(ifAttribute != null ? ifAttribute.getValue() : null);
    }
  })) {
    // all good
    return ProblemDescriptor.EMPTY_ARRAY;
  }

  final XmlTag lastTag = ContainerUtil.iterateAndGetLastItem(visitor.getResult());

  if (lastTag == null) {
    return ProblemDescriptor.EMPTY_ARRAY;
  }

  final ProblemDescriptor descriptor = manager.createProblemDescriptor(
    lastTag,
    HaxeBundle.message("haxe.inspections.nme.build.directory.descriptor"),
    new AddTagFix(),
    ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
    isOnTheFly
  );

  return new ProblemDescriptor[]{descriptor};
}
 
Example 4
Source File: VcsConfiguration.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void acceptLastCreatedPatchName(final String string) {
  if (StringUtil.isEmptyOrSpaces(string)) return;
  if (FileUtilRt.extensionEquals(string, DIFF)) {
    DEFAULT_PATCH_EXTENSION = DIFF;
  }
  else if (FileUtilRt.extensionEquals(string, PATCH)) {
    DEFAULT_PATCH_EXTENSION = PATCH;
  }
}
 
Example 5
Source File: NMMLSchemaProvider.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isAvailable(final @NotNull XmlFile file) {
  return FileUtilRt.extensionEquals(file.getName(), NMMLFileType.INSTANCE.getDefaultExtension());
}