Java Code Examples for com.intellij.openapi.vfs.VirtualFile#getNameWithoutExtension()
The following examples show how to use
com.intellij.openapi.vfs.VirtualFile#getNameWithoutExtension() .
These examples are extracted from open source projects.
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 Project: idea-php-typo3-plugin File: JavaScriptUtil.java License: MIT License | 6 votes |
@Nullable public static String calculateModuleName(@NotNull PsiFile file) { String extensionKey = ExtensionUtility.findExtensionKeyFromFile(file); if (extensionKey == null) { return null; } VirtualFile virtualFile = file.getVirtualFile(); String modLocalName = virtualFile.getPath(); String nameWithoutExtension = virtualFile.getNameWithoutExtension(); String[] pathSplit = modLocalName.split(SIGNIFICANT_PATH); if (pathSplit.length <= 1) { return null; } String[] nameSplit = pathSplit[1].split(nameWithoutExtension); if (nameSplit.length <= 1) { return null; } return MODULE_PREFIX + normalizeExtensionKeyForJs(extensionKey) + "/" + nameSplit[0] + nameWithoutExtension; }
Example 2
Source Project: intellij-awesome-console File: AwesomeProjectFilesIterator.java License: MIT License | 6 votes |
@Override public boolean processFile(final VirtualFile file) { if (!file.isDirectory()) { /* cache for full file name */ final String filename = file.getName(); if (!fileCache.containsKey(filename)) { fileCache.put(filename, new ArrayList<VirtualFile>()); } fileCache.get(filename).add(file); /* cache for basename (fully qualified class names) */ final String basename = file.getNameWithoutExtension(); if (0 >= basename.length()) { return true; } if (!fileBaseCache.containsKey(basename)) { fileBaseCache.put(basename, new ArrayList<VirtualFile>()); } fileBaseCache.get(basename).add(file); } return true; }
Example 3
Source Project: intellij-haxe File: HaxeReferenceImpl.java License: Apache License 2.0 | 6 votes |
private void addChildClassVariants(Set<HaxeComponentName> variants, HaxeClass haxeClass) { if (haxeClass != null) { PsiFile psiFile = haxeClass.getContainingFile(); VirtualFile virtualFile = psiFile.getVirtualFile(); if (virtualFile != null) { String nameWithoutExtension = virtualFile.getNameWithoutExtension(); String name = haxeClass.getName(); if (name != null && name.equals(nameWithoutExtension)) { List<HaxeClass> haxeClassList = HaxeResolveUtil.findComponentDeclarations(psiFile); for (HaxeClass aClass : haxeClassList) { if (!aClass.getName().equals(nameWithoutExtension)) { variants.add(aClass.getComponentName()); } } } } } }
Example 4
Source Project: intellij-haxe File: UsefulPsiTreeUtil.java License: Apache License 2.0 | 6 votes |
private static void populateClassesList(List<HaxeClass> classList, Project project, VirtualFile file) { VirtualFile[] files = file.getChildren(); for (VirtualFile virtualFile : files) { if (virtualFile.getFileType().equals(HaxeFileType.HAXE_FILE_TYPE)) { PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile); String nameWithoutExtension = virtualFile.getNameWithoutExtension(); List<HaxeClass> haxeClassList = HaxeResolveUtil.findComponentDeclarations(psiFile); for (HaxeClass haxeClass : haxeClassList) { if (Objects.equals(haxeClass.getName(), nameWithoutExtension)) { classList.add(haxeClass); } } } } }
Example 5
Source Project: consulo File: SaveFileAsTemplateAction.java License: Apache License 2.0 | 6 votes |
@RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e){ Project project = e.getRequiredData(CommonDataKeys.PROJECT); String fileText = e.getData(PlatformDataKeys.FILE_TEXT); VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE); String extension = file.getExtension(); String nameWithoutExtension = file.getNameWithoutExtension(); AllFileTemplatesConfigurable fileTemplateOptions = new AllFileTemplatesConfigurable(project); ConfigureTemplatesDialog dialog = new ConfigureTemplatesDialog(project, fileTemplateOptions); PsiFile psiFile = e.getData(LangDataKeys.PSI_FILE); for(SaveFileAsTemplateHandler handler: Extensions.getExtensions(SaveFileAsTemplateHandler.EP_NAME)) { String textFromHandler = handler.getTemplateText(psiFile, fileText, nameWithoutExtension); if (textFromHandler != null) { fileText = textFromHandler; break; } } fileTemplateOptions.createNewTemplate(nameWithoutExtension, extension, fileText); dialog.show(); }
Example 6
Source Project: reasonml-idea-plugin File: FileModuleData.java License: MIT License | 5 votes |
public FileModuleData(@NotNull VirtualFile file, @NotNull String namespace, String moduleName, boolean isOCaml, boolean isInterface, boolean isComponent) { m_namespace = namespace; m_moduleName = moduleName; m_isOCaml = isOCaml; m_isInterface = isInterface; m_isComponent = isComponent; m_path = file.getPath(); String filename = file.getNameWithoutExtension(); m_fullname = namespace.isEmpty() ? filename : filename + "-" + namespace; }
Example 7
Source Project: idea-php-typo3-plugin File: TranslationIndex.java License: MIT License | 5 votes |
private static String extractLanguageKeyFromFile(VirtualFile inputData) { String languageKey = "en"; String nameWithoutExtension = inputData.getNameWithoutExtension(); if (nameWithoutExtension.indexOf(".") == 2) { String[] split = nameWithoutExtension.split(Pattern.quote(".")); if (split.length != 0) { languageKey = split[0]; } } return languageKey; }
Example 8
Source Project: intellij File: BlazeResolveConfiguration.java License: Apache License 2.0 | 5 votes |
@Nullable private VirtualFile getSourceFileForHeaderFile(VirtualFile headerFile) { Collection<VirtualFile> roots = OCImportGraphCompat.getAllHeaderRoots(project, headerFile); final String headerNameWithoutExtension = headerFile.getNameWithoutExtension(); for (VirtualFile root : roots) { if (root.getNameWithoutExtension().equals(headerNameWithoutExtension)) { return root; } } return null; }
Example 9
Source Project: intellij-pants-plugin File: JarMappings.java License: Apache License 2.0 | 5 votes |
public Optional<String> findTargetForClassJar(VirtualFile jar) { if (!isProjectInternalDependency(jar)) { return Optional.empty(); } String jarName = jar.getNameWithoutExtension(); String targetAddress = targetAddressFromSanitizedFileName(jarName); return Optional.of(targetAddress); }
Example 10
Source Project: consulo-unity3d File: UnityScriptSourceLineResolver.java License: Apache License 2.0 | 5 votes |
@RequiredReadAction @Nullable @Override public String resolveParentVmQName(@Nonnull PsiElement element) { Module rootModule = Unity3dModuleExtensionUtil.getRootModule(element.getProject()); if(rootModule == null) { return null; } VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element); return virtualFile == null ? null : virtualFile.getNameWithoutExtension(); }
Example 11
Source Project: consulo-unity3d File: Unity3dProjectViewNodeDecorator.java License: Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void decorate(ProjectViewNode node, PresentationData data) { Project project = node.getProject(); if(project == null) { return; } VirtualFile virtualFile = node.getVirtualFile(); if(virtualFile == null || virtualFile.getFileType() != Unity3dMetaFileType.INSTANCE) { return; } Unity3dRootModuleExtension rootModuleExtension = Unity3dModuleExtensionUtil.getRootModuleExtension(project); if(rootModuleExtension == null) { return; } if(Unity3dMetaFileProjectViewProvider.haveOwnerFile(virtualFile)) { return; } data.clearText(); data.addText(virtualFile.getName(), SimpleTextAttributes.GRAYED_BOLD_ATTRIBUTES); String nameWithoutExtension = virtualFile.getNameWithoutExtension(); data.setTooltip("File(directory) '" + nameWithoutExtension + "' is not exists, meta file can be deleted."); }
Example 12
Source Project: consulo File: FileNameWithoutExtension.java License: Apache License 2.0 | 5 votes |
@Override public String expand(DataContext dataContext) { VirtualFile file = dataContext.getData(PlatformDataKeys.VIRTUAL_FILE); if (file == null) { return null; } return file.getNameWithoutExtension(); }
Example 13
Source Project: mule-intellij-plugins File: SOAPKitScaffoldingAction.java License: Apache License 2.0 | 4 votes |
@Override public void actionPerformed(AnActionEvent anActionEvent) { final VirtualFile selectedWsdlFile = CommonDataKeys.VIRTUAL_FILE.getData(anActionEvent.getDataContext()); final Project project = anActionEvent.getProject(); PsiFile psiFile = anActionEvent.getData(CommonDataKeys.PSI_FILE); final VirtualFile moduleContentRoot = ProjectRootManager.getInstance(project).getFileIndex().getContentRootForFile(selectedWsdlFile); final VirtualFile appsRoot = moduleContentRoot.findFileByRelativePath(MuleConfigUtils.CONFIG_RELATIVE_PATH); String appPath = appsRoot.getPath(); String wsdlPath = selectedWsdlFile.getPath(); logger.debug("*** WSDL PATH IS " + wsdlPath); logger.debug("*** APP PATH IS " + appPath); Definition wsdlDefinition = WsdlUtils.parseWSDL(wsdlPath); List<String> configFiles = MuleDeployProperties.getConfigFileNames(appPath); final SoapKitDialog form = new SoapKitDialog(wsdlDefinition, configFiles); form.show(); boolean isOk = form.getExitCode() == DialogWrapper.OK_EXIT_CODE; if (!isOk) return; final String service = form.getService().getSelectedItem().toString(); final String port = form.getPort().getSelectedItem().toString(); String muleXml = form.getConfigFile().getSelectedItem().toString(); logger.debug("*** SERVICE " + service); logger.debug("*** PORT " + port); logger.debug("*** muleXml " + muleXml); logger.debug("*** wsdlPath " + wsdlPath); if (SoapKitDialog.NEW_FILE.equals(muleXml)) { File muleXmlFile = null; int i = 0; do { muleXml = selectedWsdlFile.getNameWithoutExtension() + (i > 0 ? "-" + i : "") + ".xml"; muleXmlFile = new File(appPath, muleXml); i++; } while (muleXmlFile.exists()); } final String muleXmlConfigFileName = muleXml; try { new WriteCommandAction.Simple(project, psiFile) { @Override protected void run() throws Throwable { VirtualFile vMuleXmlFile = appsRoot.findOrCreateChildData(this, muleXmlConfigFileName); Element resultElement = SCAFFOLDER.scaffold(wsdlPath, wsdlPath, service, port, ""); writeMuleXmlFile(resultElement, vMuleXmlFile); } }.execute(); } catch (Exception e) { Notification notification = MuleUIUtils.MULE_NOTIFICATION_GROUP.createNotification("Unable to generate flows from WSDL File", "Error Message : " + e, NotificationType.ERROR, null); Notifications.Bus.notify(notification, project); } moduleContentRoot.refresh(false, true); }
Example 14
Source Project: react-templates-plugin File: RTMergerTreeStructureProvider.java License: MIT License | 4 votes |
public static String getJSControllerName(VirtualFile rtFile) { return rtFile.getNameWithoutExtension() + ".js"; }
Example 15
Source Project: react-templates-plugin File: RTMergerTreeStructureProvider.java License: MIT License | 4 votes |
public static String getTSControllerName(VirtualFile rtFile) { return rtFile.getNameWithoutExtension() + ".ts"; }
Example 16
Source Project: react-templates-plugin File: RTMergerTreeStructureProvider.java License: MIT License | 4 votes |
public static String getJSControllerName(VirtualFile rtFile) { return rtFile.getNameWithoutExtension() + ".js"; }
Example 17
Source Project: react-templates-plugin File: RTMergerTreeStructureProvider.java License: MIT License | 4 votes |
public static String getTSControllerName(VirtualFile rtFile) { return rtFile.getNameWithoutExtension() + ".ts"; }
Example 18
Source Project: consulo-unity3d File: Unity3dMetaFileProjectViewProvider.java License: Apache License 2.0 | 4 votes |
public static boolean haveOwnerFile(VirtualFile virtualFile) { String nameWithoutExtension = virtualFile.getNameWithoutExtension(); VirtualFile parent = virtualFile.getParent(); return parent.findChild(nameWithoutExtension) != null; }
Example 19
Source Project: CppTools File: CompileCppAction.java License: Apache License 2.0 | 4 votes |
String getOutputFileName(VirtualFile file, CompileCppOptions compileOptions) { final String fileName = compileOptions.getOutputFileName(); return fileName != null ? fileName:file.getNameWithoutExtension() + ".exe"; }
Example 20
Source Project: consulo File: FileNameWithoutExtensionMacro.java License: Apache License 2.0 | 4 votes |
@Override protected TextResult calculateResult(@Nonnull VirtualFile virtualFile) { return new TextResult(virtualFile.getNameWithoutExtension()); }