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

The following examples show how to use com.intellij.openapi.util.io.FileUtilRt#getNameWithoutExtension() . 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: ORUtil.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
@NotNull
public static String fileNameToModuleName(@NotNull String filename) {
    String nameWithoutExtension = FileUtilRt.getNameWithoutExtension(filename);
    if (nameWithoutExtension.isEmpty()) {
        return "";
    }
    return nameWithoutExtension.substring(0, 1).toUpperCase(Locale.getDefault()) + nameWithoutExtension.substring(1);
}
 
Example 2
Source File: UniqueNameEditorTabTitleProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static String getEditorTabText(String result, String separator, boolean hideKnownExtensionInTabs) {
  if (hideKnownExtensionInTabs) {
    String withoutExtension = FileUtilRt.getNameWithoutExtension(result);
    if (StringUtil.isNotEmpty(withoutExtension) && !withoutExtension.endsWith(separator)) {
      return withoutExtension;
    }
  }
  return result;
}
 
Example 3
Source File: UnityScriptIndexer.java    From consulo-unity3d with Apache License 2.0 4 votes vote down vote up
@Override
public void indexFile(@Nonnull JSFileStub fileStub, @Nonnull IndexSink sink)
{
	String nameWithoutExtension = FileUtilRt.getNameWithoutExtension(fileStub.getName());
	sink.occurrence(UnityScriptIndexKeys.FILE_BY_NAME_INDEX, nameWithoutExtension);
}
 
Example 4
Source File: LocalizeManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void analyzeLibraryJar(String filePath) throws IOException {
  String localeString = null;
  File jarFile = new File(filePath);

  Map<String, LocalizeFileState> localizeFiles = new HashMap<>();

  try (ZipFile zipFile = new ZipFile(jarFile)) {
    Enumeration<? extends ZipEntry> entries = zipFile.entries();

    while (entries.hasMoreElements()) {
      ZipEntry zipEntry = entries.nextElement();

      final String name = zipEntry.getName();

      if (LOCALIZE_LIBRARY_MARKER.equals(name)) {
        try (InputStream inputStream = zipFile.getInputStream(zipEntry)) {
          byte[] bytes = StreamUtil.loadFromStream(inputStream);

          localeString = new String(bytes, StandardCharsets.UTF_8);
        }
      }
      else if (name.startsWith("localize/") && name.endsWith(".yaml")) {
        String pluginId = name.substring(name.indexOf('/') + 1, name.length());
        pluginId = pluginId.substring(0, pluginId.lastIndexOf('/'));
        pluginId = pluginId.replace('/', '.');

        URL localizeFileUrl = URLUtil.getJarEntryURL(jarFile, name);

        String fileName = StringUtil.getShortName(name, '/');
        String id = FileUtilRt.getNameWithoutExtension(fileName);

        String localizeId = pluginId + "." + id;
        localizeFiles.put(localizeId, new LocalizeFileState(localizeId, localizeFileUrl));
      }
    }
  }

  if (StringUtil.isEmptyOrSpaces(localeString)) {
    LOG.warn("There no locale file inside: " + filePath);
    return;
  }

  Locale locale = buildLocale(localeString);
  Map<String, LocalizeFileState> mapByLocalizeId = myLocalizes.computeIfAbsent(locale, l -> new HashMap<>());

  mapByLocalizeId.putAll(localizeFiles);
}