當前位置: 首頁>>代碼示例>>Java>>正文


Java PsiFile.getVirtualFile方法代碼示例

本文整理匯總了Java中com.intellij.psi.PsiFile.getVirtualFile方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiFile.getVirtualFile方法的具體用法?Java PsiFile.getVirtualFile怎麽用?Java PsiFile.getVirtualFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.psi.PsiFile的用法示例。


在下文中一共展示了PsiFile.getVirtualFile方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setupConfigurationFromContext

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@Override
protected boolean setupConfigurationFromContext(AppleScriptRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
  PsiElement elem = context.getPsiLocation();
  PsiFile file = elem != null ? elem.getContainingFile() : null;
  if (file == null) return false;
  boolean shouldSetUp = file.getFileType() == AppleScriptFileType.INSTANCE;
  VirtualFile vFile = file.getVirtualFile();
  String scriptPath = vFile != null ? file.getVirtualFile().getPath() : null;
  if (scriptPath != null) {
    configuration.setScriptPath(scriptPath);
    String[] parts = scriptPath.split("/");
    if (parts.length > 0) {
      configuration.setName(parts[parts.length - 1]);
    }
  }
  return shouldSetUp;
}
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:18,代碼來源:AppleScriptConfigurationProducer.java

示例2: collectSlowLineMarkers

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@Override
public void collectSlowLineMarkers(@NotNull List<PsiElement> list, @NotNull Collection<LineMarkerInfo> collection) {
    for (PsiElement element : list) {
        PsiFile file = element.getContainingFile();
        if (file == null) {
            continue;
        }
        VirtualFile virtualFile  = file.getVirtualFile();
        if (virtualFile == null) {
            continue;
        }
        String controllerName = CakeUtil.controllerBaseNameFromControllerFileName(virtualFile.getNameWithoutExtension());
        if (controllerName == null) {
            continue;
        }
        LineMarkerInfo info = getRelatedFiles(file, controllerName, element);
        addLineMarkerUnique(collection, info);
        PsiElement[] children = element.getChildren();
        for (PsiElement child : children) {
            info = getRelatedFiles(file, controllerName, child);
            addLineMarkerUnique(collection, info);
        }
    }
}
 
開發者ID:dmeybohm,項目名稱:chocolate-cakephp,代碼行數:25,代碼來源:ControllerMethodLineMarker.java

示例3: doGetExternalModel

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@NotNull
private TSMetaModelImpl doGetExternalModel(final @NotNull PsiFile contextFile) {
    final PsiFile originalFile = contextFile.getOriginalFile();
    final VirtualFile vFile = originalFile.getVirtualFile();
    final Project project = originalFile.getProject();
    CachedValue<TSMetaModelImpl> externalModelCache = originalFile.getUserData(EXTERNAL_MODEL_CACHE_KEY);

    if (externalModelCache == null) {

        externalModelCache = CachedValuesManager.getManager(project).createCachedValue(
            () -> ApplicationManager.getApplication().runReadAction(
                (Computable<CachedValueProvider.Result<TSMetaModelImpl>>) () -> {

                    final List<VirtualFile> excludes = vFile == null
                        ? Collections.emptyList()
                        : Collections.singletonList(vFile);

                    final TSMetaModelBuilder builder = new TSMetaModelBuilder(project, excludes);
                    final TSMetaModelImpl model = builder.buildModel();
                    return CachedValueProvider.Result.create(model, builder.getFiles());

                }), false);
        originalFile.putUserData(EXTERNAL_MODEL_CACHE_KEY, externalModelCache);
    }
    return externalModelCache.getValue();
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:27,代碼來源:TSMetaModelAccessImpl.java

示例4: modifyChildNode

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@Nullable
@Override
public AbstractTreeNode modifyChildNode(AbstractTreeNode childNode) {
  Object value = childNode.getValue();
  if (value instanceof PsiDirectory && !((PsiDirectory)value).getName().equals(EduNames.SRC)) {
    return createChildDirectoryNode(null, (PsiDirectory)value);
  }
  if (value instanceof PsiElement) {
    PsiFile psiFile = ((PsiElement) value).getContainingFile();
    if (psiFile == null) return null;
    VirtualFile virtualFile = psiFile.getVirtualFile();
    if (virtualFile == null) {
      return null;
    }
    return StudyUtils.getTaskFile(myProject, virtualFile) != null ? childNode : null;
  }
  return null;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:19,代碼來源:TaskDirectoryNode.java

示例5: modifyChildNode

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@Nullable
@Override
public AbstractTreeNode modifyChildNode(AbstractTreeNode childNode) {
  Object value = childNode.getValue();
  if (value instanceof PsiDirectory) {
    return createChildDirectoryNode(null, (PsiDirectory)value);
  }
  if (value instanceof PsiElement) {
    PsiFile psiFile = ((PsiElement) value).getContainingFile();
    if (psiFile == null) return null;
    VirtualFile virtualFile = psiFile.getVirtualFile();
    if (virtualFile == null) {
      return null;
    }
    return StudyUtils.getTaskFile(myProject, virtualFile) != null ? childNode : null;
  }
  return null;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:19,代碼來源:DirectoryNode.java

示例6: getAnswerPlaceholder

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@Nullable
private static AnswerPlaceholder getAnswerPlaceholder(PsiElement e, int offset) {
  PsiFile file = e.getContainingFile();
  if (file == null) {
    return null;
  }
  VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile == null) {
    return null;
  }
  TaskFile taskFile = StudyUtils.getTaskFile(e.getProject(), virtualFile);
  if (taskFile == null) {
    return null;
  }
  Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
  if (document == null) {
    return null;
  }
  Editor editor = FileEditorManager.getInstance(e.getProject()).getSelectedTextEditor();
  return editor == null ? null : taskFile.getAnswerPlaceholder(offset);
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:22,代碼來源:StudyAnswerPlaceholderExtendWordHandler.java

示例7: modifyChildNode

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@Nullable
@Override
public AbstractTreeNode modifyChildNode(AbstractTreeNode childNode) {
  final AbstractTreeNode node = super.modifyChildNode(childNode);
  if (node != null) return node;
  Object value = childNode.getValue();
  if (value instanceof PsiElement) {
    PsiFile psiFile = ((PsiElement) value).getContainingFile();
    VirtualFile virtualFile = psiFile.getVirtualFile();

    Course course = StudyTaskManager.getInstance(myProject).getCourse();
    if (course == null) {
      return null;
    }
    EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(course.getLanguageById());
    if (configurator == null) {
      return new CCStudentInvisibleFileNode(myProject, psiFile, myViewSettings);
    }
    if (!CCUtils.isTestsFile(myProject, virtualFile)) {
      return new CCStudentInvisibleFileNode(myProject, psiFile, myViewSettings);
    }
  }
  return null;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:25,代碼來源:CCDirectoryNode.java

示例8: ViewLookupElement

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
ViewLookupElement(PsiFile psiFile) {
    myFile = psiFile;
    VirtualFile file = psiFile.getVirtualFile();

    if (file.getNameWithoutExtension().contains(".")) {
        myName = file.getName();
        myTail = null;
    } else {
        myName = file.getNameWithoutExtension();
        myTail = "." + file.getExtension();
    }
}
 
開發者ID:nvlad,項目名稱:yii2support,代碼行數:13,代碼來源:ViewLookupElement.java

示例9: toVirtualFile

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
public static VirtualFile toVirtualFile( PsiFile file )
{
  VirtualFile vfile = file.getUserData( IndexingDataKeys.VIRTUAL_FILE );
  if( vfile == null )
  {
    vfile = file.getVirtualFile();
    if( vfile == null )
    {
      vfile = file.getOriginalFile().getVirtualFile();
      if( vfile == null )
      {
        vfile = file.getViewProvider().getVirtualFile();
      }
    }
    else if( vfile instanceof LightVirtualFile )
    {
      PsiFile containingFile = file.getContainingFile();
      if( containingFile != null && containingFile != file )
      {
        PsiFile originalFile = containingFile.getOriginalFile();
        SmartPsiElementPointer owningFile = originalFile.getUserData( FileContextUtil.INJECTED_IN_ELEMENT );
        if( owningFile != null )
        {
          vfile = owningFile.getVirtualFile();
        }
      }
    }
  }
  return vfile;
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:31,代碼來源:FileUtil.java

示例10: isConfigurationFromContext

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@Override
public boolean isConfigurationFromContext(AppleScriptRunConfiguration configuration, ConfigurationContext context) {
  PsiElement elem = context.getPsiLocation();
  PsiFile file = elem != null ? elem.getContainingFile() : null;
  if (file == null) return false;
  VirtualFile currentFile = file.getVirtualFile();

  boolean isSameFile = false;
  if (currentFile != null) {
    isSameFile = currentFile.getPath().equals(configuration.getScriptPath());
  }
  return isSameFile;
}
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:14,代碼來源:AppleScriptConfigurationProducer.java

示例11: findExtEmConf

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
private static VirtualFile findExtEmConf(@NotNull PsiDirectory extensionRootDirectory) {
    PsiFile file = extensionRootDirectory.findFile("ext_emconf.php");
    if (file == null) {
        return null;
    }

    return file.getVirtualFile();
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:9,代碼來源:ExtensionUtility.java

示例12: findComposerManifest

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
private static VirtualFile findComposerManifest(@NotNull PsiDirectory extensionRootDirectory) {
    PsiFile file = extensionRootDirectory.findFile("composer.json");
    if (file == null) {
        return null;
    }

    return file.getVirtualFile();
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:9,代碼來源:ExtensionUtility.java

示例13: getGotoDeclarationTargets

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@Nullable
@Override
public PsiElement[] getGotoDeclarationTargets(@Nullable PsiElement psiElement, int i, Editor editor) {
    if (psiElement == null) {
        return PsiElement.EMPTY_ARRAY;
    }
    Project project = psiElement.getProject();
    if (!PlatformPatterns
            .psiElement(StringLiteralExpression.class)
            .withLanguage(PhpLanguage.INSTANCE)
            .accepts(psiElement.getContext())
    ) {
        return PsiElement.EMPTY_ARRAY;
    }
    PsiFile containingFile = psiElement.getContainingFile();
    VirtualFile virtualFile = containingFile.getVirtualFile();
    String filename = virtualFile.getNameWithoutExtension();
    String controllerName = CakeUtil.controllerBaseNameFromControllerFileName(filename);
    if (controllerName == null) {
        return PsiElement.EMPTY_ARRAY;
    }

    PsiDirectory appDir = PsiUtil.getAppDirectoryFromFile(containingFile);
    String templatePath = String.format("View/%s/%s.ctp", controllerName, psiElement.getText());
    VirtualFile relativeFile = VfsUtil.findRelativeFile(appDir, templatePath);
    if (relativeFile != null) {
        Collection<VirtualFile> files = new HashSet<>();
        files.add(relativeFile);
        return PsiUtil.convertVirtualFilesToPsiFiles(project, files).toArray(new PsiElement[files.size()]);
    }
    return PsiElement.EMPTY_ARRAY;
}
 
開發者ID:dmeybohm,項目名稱:chocolate-cakephp,代碼行數:33,代碼來源:TemplateGotoDeclarationHandler.java

示例14: getFileNameWithoutExtension

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@Nullable
public static String getFileNameWithoutExtension(@NotNull PsiElement psiElement) {
    PsiFile file = psiElement.getContainingFile();
    if (file == null) {
        return null;
    }
    VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile == null) {
        return null;
    }
    return virtualFile.getNameWithoutExtension();
}
 
開發者ID:dmeybohm,項目名稱:chocolate-cakephp,代碼行數:13,代碼來源:PsiUtil.java

示例15: process

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@SuppressWarnings("ParameterNameDiffersFromOverriddenParameter")
@Override
public boolean process(final PsiFile psiFile) {
    final VirtualFile vFile = psiFile.getVirtualFile();

    if (vFile == null || myFilesToExclude.contains(vFile)) {
        return true;
    }
    myFiles.add(psiFile);
    final DomFileElement<Items> rootWrapper = myDomManager.getFileElement((XmlFile) psiFile, Items.class);
    final Items items = Optional.ofNullable(rootWrapper).map(DomFileElement::getRootElement).orElse(null);

    if (items != null) {
        items.getItemTypes().getItemTypes().forEach(this::processItemType);
        items.getItemTypes().getTypeGroups().stream()
             .flatMap(tg -> tg.getItemTypes().stream())
             .forEach(this::processItemType);

        items.getEnumTypes().getEnumTypes().forEach(this::processEnumType);
        items.getAtomicTypes().getAtomicTypes().forEach(this::processAtomicType);
        items.getCollectionTypes().getCollectionTypes().forEach(this::processCollectionType);
        items.getRelations().getRelations().forEach(myResult::createReference);
    }

    //continue visiting
    return true;
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:28,代碼來源:TSMetaModelBuilder.java


注:本文中的com.intellij.psi.PsiFile.getVirtualFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。