Java Code Examples for com.intellij.openapi.vfs.VirtualFile#getNameWithoutExtension()
The following examples show how to use
com.intellij.openapi.vfs.VirtualFile#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: SaveFileAsTemplateAction.java From consulo with 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 2
Source File: JavaScriptUtil.java From idea-php-typo3-plugin with 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 3
Source File: UsefulPsiTreeUtil.java From intellij-haxe with 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 4
Source File: HaxeReferenceImpl.java From intellij-haxe with 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 5
Source File: AwesomeProjectFilesIterator.java From intellij-awesome-console with 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 6
Source File: JarMappings.java From intellij-pants-plugin with 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 7
Source File: FileNameWithoutExtension.java From consulo with 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 8
Source File: Unity3dProjectViewNodeDecorator.java From consulo-unity3d with 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 9
Source File: UnityScriptSourceLineResolver.java From consulo-unity3d with 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 10
Source File: FileModuleData.java From reasonml-idea-plugin with 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 11
Source File: BlazeResolveConfiguration.java From intellij with 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 12
Source File: TranslationIndex.java From idea-php-typo3-plugin with 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 13
Source File: RTMergerTreeStructureProvider.java From react-templates-plugin with MIT License | 4 votes |
public static String getTSControllerName(VirtualFile rtFile) { return rtFile.getNameWithoutExtension() + ".ts"; }
Example 14
Source File: RTMergerTreeStructureProvider.java From react-templates-plugin with MIT License | 4 votes |
public static String getJSControllerName(VirtualFile rtFile) { return rtFile.getNameWithoutExtension() + ".js"; }
Example 15
Source File: Unity3dMetaFileProjectViewProvider.java From consulo-unity3d with 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 16
Source File: RTMergerTreeStructureProvider.java From react-templates-plugin with MIT License | 4 votes |
public static String getTSControllerName(VirtualFile rtFile) { return rtFile.getNameWithoutExtension() + ".ts"; }
Example 17
Source File: RTMergerTreeStructureProvider.java From react-templates-plugin with MIT License | 4 votes |
public static String getJSControllerName(VirtualFile rtFile) { return rtFile.getNameWithoutExtension() + ".js"; }
Example 18
Source File: CompileCppAction.java From CppTools with 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 19
Source File: FileNameWithoutExtensionMacro.java From consulo with Apache License 2.0 | 4 votes |
@Override protected TextResult calculateResult(@Nonnull VirtualFile virtualFile) { return new TextResult(virtualFile.getNameWithoutExtension()); }
Example 20
Source File: SOAPKitScaffoldingAction.java From mule-intellij-plugins with 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); }