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


Java VirtualFile.isValid方法代碼示例

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


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

示例1: getDictionaryFileFromInclude

import com.intellij.openapi.vfs.VirtualFile; //導入方法依賴的package包/類
@Nullable
private static XmlFile getDictionaryFileFromInclude(@NotNull Project project, IncludedXmlTag xmlIncludeTag) {
  XmlFile xmlFile = null;
  XmlElement origXmlElement = xmlIncludeTag.getOriginal();
  PsiFile origPsiFile = origXmlElement != null ? origXmlElement.getContainingFile() : null;
  if (origPsiFile instanceof XmlFile) {
    xmlFile = (XmlFile) origPsiFile;
    AppleScriptSystemDictionaryRegistryService dictionaryService = ServiceManager.getService(AppleScriptSystemDictionaryRegistryService
        .class);
    VirtualFile vFile = origPsiFile.getVirtualFile();
    DictionaryInfo dInfo = dictionaryService.getDictionaryInfoByApplicationPath(vFile.getPath());
    if (dInfo != null) {
      File ioFile = dInfo.getDictionaryFile();
      if (ioFile.exists()) {
        vFile = LocalFileSystem.getInstance().findFileByIoFile(ioFile);
        if (vFile == null || !vFile.isValid()) return null;

        PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile);
        xmlFile = (XmlFile) psiFile;
      }
    }
  }
  return xmlFile;
}
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:25,代碼來源:SDEF_Parser.java

示例2: createDictionaryFromInfo

import com.intellij.openapi.vfs.VirtualFile; //導入方法依賴的package包/類
@Nullable
private ApplicationDictionary createDictionaryFromInfo(final @NotNull DictionaryInfo dInfo) {
  if (!dInfo.isInitialized()) {
    //dictionary terms must be ridden from the dictionary file before creating a PSI for it
    LOG.error("Attempt to create dictionary for not initialized Dictionary Info for application" + dInfo.getApplicationName());
    return null;
  }
  String applicationName = dInfo.getApplicationName();
  VirtualFile vFile = LocalFileSystem.getInstance().findFileByIoFile(dInfo.getDictionaryFile());
  if (vFile != null && vFile.isValid()) {
    PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile);
    XmlFile xmlFile = (XmlFile) psiFile;
    if (xmlFile != null) {
      ApplicationDictionary dictionary = new ApplicationDictionaryImpl(project, xmlFile, applicationName, dInfo.getApplicationFile());
      dictionaryMap.put(applicationName, dictionary);
      return dictionary;
    }
  }
  LOG.warn("Failed to create dictionary from info for application: " + applicationName + ". Reason: file is null");
  return null;
}
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:22,代碼來源:AppleScriptProjectDictionaryService.java

示例3: processIncludes

import com.intellij.openapi.vfs.VirtualFile; //導入方法依賴的package包/類
private static void processIncludes(@NotNull ApplicationDictionary parsedDictionary, @Nullable XmlTag[] includes) {
    if (includes == null) return;
    for (XmlTag include : includes) {
      String hrefIncl = include.getAttributeValue("href");
      if (!StringUtil.isEmpty(hrefIncl)) {
        hrefIncl = hrefIncl.replace("file://localhost", "");
        File includedFile = new File(hrefIncl);
//        ((IncludedXmlTag) suiteTag).getOriginal().getContainingFile();
        //as there is assertion error (java.lang.AssertionError: File accessed outside allowed roots),
        // we are trying to find if the dictionary file for this included dictionary was already generated
        AppleScriptSystemDictionaryRegistryService dictionarySystemRegistry = ServiceManager
            .getService(AppleScriptSystemDictionaryRegistryService.class);
        VirtualFile vFile;
        File ioFile = null;
        DictionaryInfo dInfo = dictionarySystemRegistry.getDictionaryInfoByApplicationPath(includedFile.getPath());
        if (dInfo != null) {
          ioFile = dInfo.getDictionaryFile();
        } else if (includedFile.isFile()) {
          String fName = includedFile.getName();
          int index = fName.lastIndexOf('.');
          fName = index < 0 ? fName : fName.substring(0, index);
          ioFile = dictionarySystemRegistry.getDictionaryFile(fName);
        }
        if (ioFile == null || !ioFile.exists()) ioFile = includedFile;
        if (ioFile.exists()) {
          vFile = LocalFileSystem.getInstance().findFileByIoFile(ioFile);
          if (vFile == null || !vFile.isValid()) continue;

          PsiFile psiFile = PsiManager.getInstance(parsedDictionary.getProject()).findFile(vFile);
          XmlFile xmlFile = (XmlFile) psiFile;
          if (xmlFile != null) {
            parsedDictionary.processInclude(xmlFile);
          }
        }
      }
    }
  }
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:38,代碼來源:SDEF_Parser.java

示例4: extractVirtualFile

import com.intellij.openapi.vfs.VirtualFile; //導入方法依賴的package包/類
private VirtualFile extractVirtualFile() {
    for (SeedStackSimpleNode each : getSelectedNodes(SeedStackSimpleNode.class)) {
        VirtualFile file = each.getVirtualFile();
        if (file != null && file.isValid()) return file;
    }
    return null;
}
 
開發者ID:seedstack,項目名稱:intellij-plugin,代碼行數:8,代碼來源:SeedStackNavigatorPanel.java

示例5: extractVirtualFiles

import com.intellij.openapi.vfs.VirtualFile; //導入方法依賴的package包/類
private Object extractVirtualFiles() {
    final List<VirtualFile> files = new ArrayList<>();
    for (SeedStackSimpleNode each : getSelectedNodes(SeedStackSimpleNode.class)) {
        VirtualFile file = each.getVirtualFile();
        if (file != null && file.isValid()) files.add(file);
    }
    return files.isEmpty() ? null : VfsUtil.toVirtualFileArray(files);
}
 
開發者ID:seedstack,項目名稱:intellij-plugin,代碼行數:9,代碼來源:SeedStackNavigatorPanel.java

示例6: createNavigatableForFile

import com.intellij.openapi.vfs.VirtualFile; //導入方法依賴的package包/類
@Nullable
public static Navigatable createNavigatableForFile(final Project project, final VirtualFile file) {
    if (file != null && file.isValid()) {
        final PsiFile result = PsiManager.getInstance(project).findFile(file);
        return result == null ? null : new NavigatableAdapter() {
            public void navigate(boolean requestFocus) {
                navigate(project, file, 0, requestFocus);
            }
        };
    } else {
        return null;
    }
}
 
開發者ID:seedstack,項目名稱:intellij-plugin,代碼行數:14,代碼來源:NavigatorUtil.java

示例7: isInterfaceMadeStructuralByExtension

import com.intellij.openapi.vfs.VirtualFile; //導入方法依賴的package包/類
private boolean isInterfaceMadeStructuralByExtension( PsiClass psiInterface, ManModule module )
{
  final String fqn = psiInterface.getQualifiedName();
  ManModule manModule = ManProject.getModule( module.getIjModule() );
  for( ITypeManifold sp : manModule.getTypeManifolds() )
  {
    if( sp.getProducerKind() == Supplemental )
    {
      if( sp.isType( fqn ) )
      {
        List<IFile> files = sp.findFilesForType( fqn );
        for( IFile file : files )
        {
          VirtualFile vExtensionClassFile = ((IjFile)file).getVirtualFile();
          if( !vExtensionClassFile.isValid() )
          {
            continue;
          }

          PsiJavaFile psiExtClassJavaFile =
            (PsiJavaFile)PsiManager.getInstance( module.getIjModule().getProject() ).findFile( vExtensionClassFile );
          PsiClass[] classes = psiExtClassJavaFile.getClasses();
          if( classes.length > 0 )
          {
            PsiClass psiExtClass = classes[0];
            if( psiExtClass.getModifierList().findAnnotation( Structural.class.getName() ) != null )
            {
              return true;
            }
          }
        }
      }
    }
  }
  return false;
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:37,代碼來源:ExtensionClassAnnotator.java

示例8: markTemporaryWritable

import com.intellij.openapi.vfs.VirtualFile; //導入方法依賴的package包/類
/**
 * Requests to temporary ignore the read-only status provided by this provider.
 * Does nothing if read-only status is for some other reason
 */
public void markTemporaryWritable(@NotNull VirtualFile vFile) {
    if (vFile.isValid() && !isPotentiallyWritable(vFile)) {
        vFile.putUserData(KEY_TEMPORARY_WRITABLE, true);
    }
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:10,代碼來源:HybrisWritingAccessProvider.java

示例9: unmarkTemporaryWritable

import com.intellij.openapi.vfs.VirtualFile; //導入方法依賴的package包/類
/**
 * Clears any possible flag marked by {@link #markTemporaryWritable(VirtualFile)} call
 */
public static void unmarkTemporaryWritable(@NotNull VirtualFile vFile) {
    if (vFile.isValid()) {
        vFile.putUserData(KEY_TEMPORARY_WRITABLE, null);
    }
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:9,代碼來源:HybrisWritingAccessProvider.java

示例10: addMethods

import com.intellij.openapi.vfs.VirtualFile; //導入方法依賴的package包/類
private void addMethods( String fqn, PsiClass psiClass, List<PsiElement> augFeatures, Module start, Module module )
{
  ManModule manModule = ManProject.getModule( module );
  for( ITypeManifold sp : manModule.getTypeManifolds() )
  {
    if( sp.getProducerKind() == Supplemental )
    {
      if( sp.isType( fqn ) )
      {
        List<IFile> files = sp.findFilesForType( fqn );
        for( IFile file : files )
        {
          VirtualFile vFile = ((IjFile)file).getVirtualFile();
          if( !vFile.isValid() )
          {
            continue;
          }

          PsiFile psiFile = PsiManager.getInstance( module.getProject() ).findFile( vFile );
          PsiJavaFile psiJavaFile = (PsiJavaFile)psiFile;
          PsiClass[] classes = psiJavaFile.getClasses();
          if( classes.length > 0 )
          {
            SrcClass srcExtClass = new StubBuilder().make( classes[0].getQualifiedName(), manModule );
            SrcClass scratchClass = new SrcClass( psiClass.getQualifiedName(), psiClass.isInterface() ? SrcClass.Kind.Interface : SrcClass.Kind.Class );
            for( PsiTypeParameter tv : psiClass.getTypeParameters() )
            {
              scratchClass.addTypeVar( new SrcType( StubBuilder.makeTypeVar( tv ) ) );
            }
            for( AbstractSrcMethod m : srcExtClass.getMethods() )
            {
              SrcMethod srcMethod = addExtensionMethod( scratchClass, m, psiClass );
              if( srcMethod != null )
              {
                PsiMethod extMethod = makePsiMethod( srcMethod, psiClass );
                if( extMethod != null )
                {
                  PsiMethod plantedMethod = plantMethodInPsiClass( extMethod, psiClass, classes[0] );
                  augFeatures.add( plantedMethod );
                }
              }
            }
          }
        }
      }
    }
  }
  for( Dependency d : manModule.getDependencies() )
  {
    if( module == start || d.isExported() )
    {
      addMethods( fqn, psiClass, augFeatures, start, ((ManModule)d.getModule()).getIjModule() );
    }
  }
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:56,代碼來源:ManAugmentProvider.java


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