Java 类com.intellij.psi.impl.PsiFileEx 实例源码

项目:intellij-ce-playground    文件:TextEditorBackgroundHighlighter.java   
private void renewFile() {
  if (myFile == null || !myFile.isValid()) {
    myFile = PsiDocumentManager.getInstance(myProject).getPsiFile(myDocument);
    myCompiled = myFile instanceof PsiCompiledFile;
    if (myCompiled) {
      myFile = ((PsiCompiledFile)myFile).getDecompiledPsiFile();
    }
    if (myFile != null && !myFile.isValid()) {
      myFile = null;
    }
  }

  if (myFile != null) {
    myFile.putUserData(PsiFileEx.BATCH_REFERENCE_PROCESSING, Boolean.TRUE);
  }
}
项目:intellij-ce-playground    文件:DomServiceImpl.java   
@NotNull
private static XmlFileHeader calcXmlFileHeader(final XmlFile file) {

  if (file instanceof PsiFileEx && ((PsiFileEx)file).isContentsLoaded() && file.getNode().isParsed()) {
    return computeHeaderByPsi(file);
  }

  if (!XmlUtil.isStubBuilding() && file.getFileType() == XmlFileType.INSTANCE) {
    VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile instanceof VirtualFileWithId) {
      ObjectStubTree tree = StubTreeLoader.getInstance().readFromVFile(file.getProject(), virtualFile);
      if (tree != null) {
        Stub root = tree.getRoot();
        if (root instanceof FileStub) {
          return ((FileStub)root).getHeader();
        }
      }
    }
  }

  if (!file.isValid()) return XmlFileHeader.EMPTY;

  return NanoXmlUtil.parseHeader(file);
}
项目:tools-idea    文件:TextEditorBackgroundHighlighter.java   
private void renewFile() {
  if (myFile == null || !myFile.isValid()) {
    myFile = PsiDocumentManager.getInstance(myProject).getPsiFile(myDocument);
    myCompiled = myFile instanceof PsiCompiledFile;
    if (myCompiled) {
      myFile = ((PsiCompiledFile)myFile).getDecompiledPsiFile();
    }
    if (myFile != null && !myFile.isValid()) {
      myFile = null;
    }
  }

  if (myFile != null) {
    myFile.putUserData(PsiFileEx.BATCH_REFERENCE_PROCESSING, Boolean.TRUE);
  }
}
项目:lua-for-idea    文件:InferenceUtil.java   
public static void requeueIfPossible(InferenceCapable element) {
    final Boolean userData = ObjectUtils.notNull(element.getContainingFile().getUserData(PsiFileEx.BATCH_REFERENCE_PROCESSING), false);
    if (!userData && !PsiTreeUtil.hasErrorElements(element)) {
        final Project project = element.getProject();
        if (project != null)
            LuaPsiManager.getInstance(project).queueInferences(element);
    }
}
项目:intellij-ce-playground    文件:DependenciesBuilder.java   
public static void analyzeFileDependencies(@NotNull PsiFile file,
                                           @NotNull DependencyProcessor processor,
                                           @NotNull DependencyVisitorFactory.VisitorOptions options) {
  file.putUserData(PsiFileEx.BATCH_REFERENCE_PROCESSING, Boolean.TRUE);
  file.accept(DependencyVisitorFactory.createVisitor(file, processor, options));
  file.putUserData(PsiFileEx.BATCH_REFERENCE_PROCESSING, null);
}
项目:intellij-ce-playground    文件:XsltSupport.java   
public CachedValueProvider.Result<XsltChecker.LanguageLevel> compute(PsiFile psiFile) {
  if (!(psiFile instanceof XmlFile)) {
    return CachedValueProvider.Result.create(XsltChecker.LanguageLevel.NONE, PsiModificationTracker.MODIFICATION_COUNT);
  }

  final XmlFile xmlFile = (XmlFile)psiFile;
  if (psiFile instanceof PsiFileEx) {
    if (((PsiFileEx)psiFile).isContentsLoaded()) {
      final XmlDocument doc = xmlFile.getDocument();
      if (doc != null) {
        final XmlTag rootTag = doc.getRootTag();
        if (rootTag != null) {
          XmlAttribute v;
          XsltChecker.LanguageLevel level;
          if (isXsltRootTag(rootTag)) {
            v = rootTag.getAttribute("version");
            level = v != null ? XsltChecker.getLanguageLevel(v.getValue()) : XsltChecker.LanguageLevel.NONE;
          }
          else {
            v = rootTag.getAttribute("version", XSLT_NS);
            level = v != null ? XsltChecker.getLanguageLevel(v.getValue()) : XsltChecker.LanguageLevel.NONE;
          }
          return CachedValueProvider.Result.create(level, rootTag);
        }
      }
    }
  }

  final XsltChecker xsltChecker = new XsltChecker();
  NanoXmlUtil.parseFile(psiFile, xsltChecker);
  return CachedValueProvider.Result.create(xsltChecker.getLanguageLevel(), psiFile);
}
项目:intellij-ce-playground    文件:XsltBasicTest.java   
private void configure() throws Throwable {
  final String fileName = getTestFileName();
  String path = fileName.replaceAll("_.*$", "") + ".xsl";
  final VirtualFile file = myFixture.copyFileToProject(path);
  myFixture.openFileInEditor(file);
  if (fileName.endsWith("_Loaded")) {
    ((XmlFile)myFixture.getFile()).getDocument();
    assertTrue(((PsiFileEx)myFixture.getFile()).isContentsLoaded());
  } else {
    assertFalse(((PsiFileEx)myFixture.getFile()).isContentsLoaded());
  }
}
项目:tools-idea    文件:CacheUtil.java   
public static PsiFile createFileCopy(FileContent content, PsiFile psiFile) {
  VirtualFile vFile = psiFile.getVirtualFile();
  if (vFile == null) return psiFile; // It's already a copy created via PsiManager.getFile(FileContent). Usually happens on initial startup.

  if (psiFile instanceof PsiFileEx) {
    return ((PsiFileEx)psiFile).cacheCopy(content);
  }

  return psiFile;
}
项目:tools-idea    文件:DomServiceImpl.java   
@NotNull
private static XmlFileHeader calcXmlFileHeader(final XmlFile file) {

  if (file instanceof PsiFileEx && ((PsiFileEx)file).isContentsLoaded() && file.getNode().isParsed()) {
    return computeHeaderByPsi(file);
  }

  if (!XmlUtil.isStubBuilding() && file.getFileType() == XmlFileType.INSTANCE) {
    VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile instanceof VirtualFileWithId) {
      ObjectStubTree tree = StubTreeLoader.getInstance().readFromVFile(file.getProject(), virtualFile);
      if (tree != null) {
        Stub root = tree.getRoot();
        if (root instanceof FileStub) {
          return ((FileStub)root).getHeader();
        }
      }
    }
  }

  if (!file.isValid()) return XmlFileHeader.EMPTY;

  if (XmlUtil.isStubBuilding() && file.getFileType() == XmlFileType.INSTANCE) {
    FileContent fileContent = file.getUserData(DomStubBuilder.CONTENT_FOR_DOM_STUBS);
    if (fileContent != null) {
      //noinspection IOResourceOpenedButNotSafelyClosed
      return NanoXmlUtil.parseHeader(new CharSequenceReader(fileContent.getContentAsText()));
    }
  }
  return NanoXmlUtil.parseHeader(file);
}
项目:tools-idea    文件:XsltSupport.java   
public CachedValueProvider.Result<XsltChecker.LanguageLevel> compute(PsiFile psiFile) {
  if (!(psiFile instanceof XmlFile)) {
    return CachedValueProvider.Result.create(XsltChecker.LanguageLevel.NONE);
  }

  final XmlFile xmlFile = (XmlFile)psiFile;
  if (psiFile instanceof PsiFileEx) {
    if (((PsiFileEx)psiFile).isContentsLoaded()) {
      final XmlDocument doc = xmlFile.getDocument();
      if (doc != null) {
        final XmlTag rootTag = doc.getRootTag();
        if (rootTag != null) {
          XmlAttribute v;
          XsltChecker.LanguageLevel level;
          if (isXsltRootTag(rootTag)) {
            v = rootTag.getAttribute("version");
            level = v != null ? XsltChecker.getLanguageLevel(v.getValue()) : XsltChecker.LanguageLevel.NONE;
          }
          else {
            v = rootTag.getAttribute("version", XSLT_NS);
            level = v != null ? XsltChecker.getLanguageLevel(v.getValue()) : XsltChecker.LanguageLevel.NONE;
          }
          return CachedValueProvider.Result.create(level, rootTag);
        }
      }
    }
  }

  final XsltChecker xsltChecker = new XsltChecker();
  NanoXmlUtil.parseFile(psiFile, xsltChecker);
  return CachedValueProvider.Result.create(xsltChecker.getLanguageLevel(), psiFile);
}
项目:tools-idea    文件:XsltBasicTest.java   
private void configure() throws Throwable {
  final String fileName = getTestFileName();
  myFixture.configureByFile(fileName.replaceAll("_.*$", "") + ".xsl");
  if (fileName.endsWith("_Loaded")) {
    ((XmlFile)myFixture.getFile()).getDocument();
    assertTrue(((PsiFileEx)myFixture.getFile()).isContentsLoaded());
  } else {
    assertFalse(((PsiFileEx)myFixture.getFile()).isContentsLoaded());
  }
}
项目:consulo-lua    文件:InferenceUtil.java   
public static void requeueIfPossible(InferenceCapable element) {
    final Boolean userData = ObjectUtils.notNull(element.getContainingFile().getUserData(PsiFileEx.BATCH_REFERENCE_PROCESSING), false);
    if (!userData && !PsiTreeUtil.hasErrorElements(element)) {
        final Project project = element.getProject();
        if (project != null)
            LuaPsiManager.getInstance(project).queueInferences(element);
    }
}
项目:consulo    文件:SingleRootFileViewProvider.java   
@Override
@Nullable
protected PsiFile getPsiInner(@Nonnull Language target) {
  if (target != getBaseLanguage()) {
    return null;
  }
  PsiFile psiFile = myPsiFile.get();
  if (psiFile == null) {
    psiFile = createFile();
    if (psiFile == null) {
      psiFile = PsiUtilCore.NULL_PSI_FILE;
    }
    boolean set = myPsiFile.compareAndSet(null, psiFile);
    if (!set && psiFile != PsiUtilCore.NULL_PSI_FILE) {
      PsiFile alreadyCreated = myPsiFile.get();
      if (alreadyCreated == psiFile) {
        LOG.error(this + ".createFile() must create new file instance but got the same: " + psiFile);
      }
      if (psiFile instanceof PsiFileEx) {
        PsiFile finalPsiFile = psiFile;
        DebugUtil.performPsiModification("invalidating throw-away copy", () ->
                ((PsiFileEx)finalPsiFile).markInvalidated()
        );
      }
      psiFile = alreadyCreated;
    }
  }
  return psiFile == PsiUtilCore.NULL_PSI_FILE ? null : psiFile;
}
项目:consulo    文件:SingleRootFileViewProvider.java   
public final void forceCachedPsi(@Nonnull PsiFile psiFile) {
  PsiFile prev = myPsiFile.getAndSet(psiFile);
  if (prev != null && prev != psiFile && prev instanceof PsiFileEx) {
    ((PsiFileEx)prev).markInvalidated();
  }
  getManager().getFileManager().setViewProvider(getVirtualFile(), this);
}
项目:consulo    文件:SingleRootFileViewProvider.java   
@Override
public final void markInvalidated() {
  PsiFile psiFile = getCachedPsi(getBaseLanguage());
  if (psiFile instanceof PsiFileEx) {
    ((PsiFileEx)psiFile).markInvalidated();
  }
  super.markInvalidated();
}
项目:consulo    文件:TextEditorBackgroundHighlighter.java   
private void renewFile() {
  if (myFile == null || !myFile.isValid()) {
    myFile = PsiDocumentManager.getInstance(myProject).getPsiFile(myDocument);
    if (myFile != null && !myFile.isValid()) {
      myFile = null;
    }
  }

  if (myFile != null) {
    myFile.putUserData(PsiFileEx.BATCH_REFERENCE_PROCESSING, Boolean.TRUE);
  }
}
项目:consulo-xslt    文件:XsltSupport.java   
public CachedValueProvider.Result<XsltChecker.LanguageLevel> compute(PsiFile psiFile) {
  if (!(psiFile instanceof XmlFile)) {
    return CachedValueProvider.Result.create(XsltChecker.LanguageLevel.NONE);
  }

  final XmlFile xmlFile = (XmlFile)psiFile;
  if (psiFile instanceof PsiFileEx) {
    if (((PsiFileEx)psiFile).isContentsLoaded()) {
      final XmlDocument doc = xmlFile.getDocument();
      if (doc != null) {
        final XmlTag rootTag = doc.getRootTag();
        if (rootTag != null) {
          XmlAttribute v;
          XsltChecker.LanguageLevel level;
          if (isXsltRootTag(rootTag)) {
            v = rootTag.getAttribute("version");
            level = v != null ? XsltChecker.getLanguageLevel(v.getValue()) : XsltChecker.LanguageLevel.NONE;
          } else {
            v = rootTag.getAttribute("version", XSLT_NS);
            level = v != null ? XsltChecker.getLanguageLevel(v.getValue()) : XsltChecker.LanguageLevel.NONE;
          }
          return CachedValueProvider.Result.create(level, rootTag);
        }
      }
    }
  }

  final XsltChecker xsltChecker = new XsltChecker();
  NanoXmlUtil.parseFile(psiFile, xsltChecker);
  return CachedValueProvider.Result.create(xsltChecker.getLanguageLevel(), psiFile);
}
项目:consulo-xml    文件:DomServiceImpl.java   
@NotNull
private static XmlFileHeader calcXmlFileHeader(final XmlFile file) {

  if (file instanceof PsiFileEx && ((PsiFileEx)file).isContentsLoaded() && file.getNode().isParsed()) {
    return computeHeaderByPsi(file);
  }

  if (!XmlUtil.isStubBuilding() && file.getFileType() == XmlFileType.INSTANCE) {
    VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile instanceof VirtualFileWithId) {
      ObjectStubTree tree = StubTreeLoader.getInstance().readFromVFile(file.getProject(), virtualFile);
      if (tree != null) {
        Stub root = tree.getRoot();
        if (root instanceof FileStub) {
          return ((FileStub)root).getHeader();
        }
      }
    }
  }

  if (!file.isValid()) return XmlFileHeader.EMPTY;

  if (XmlUtil.isStubBuilding() && file.getFileType() == XmlFileType.INSTANCE) {
    FileContent fileContent = file.getUserData(DomStubBuilder.CONTENT_FOR_DOM_STUBS);
    if (fileContent != null) {
      //noinspection IOResourceOpenedButNotSafelyClosed
      return NanoXmlUtil.parseHeader(new CharSequenceReader(fileContent.getContentAsText()));
    }
  }
  return NanoXmlUtil.parseHeader(file);
}
项目:intellij-ce-playground    文件:FileDescriptionCachedValueProvider.java   
private boolean isFileParsed() {
  return myXmlFile instanceof PsiFileEx && ((PsiFileEx)myXmlFile).isContentsLoaded();
}
项目:tools-idea    文件:DependenciesBuilder.java   
public static void analyzeFileDependencies(PsiFile file, DependencyProcessor processor) {
  file.putUserData(PsiFileEx.BATCH_REFERENCE_PROCESSING, Boolean.TRUE);
  file.accept(DependenciesVisitorFactory.getInstance().createVisitor(processor));
  file.putUserData(PsiFileEx.BATCH_REFERENCE_PROCESSING, null);
}
项目:tools-idea    文件:FileDescriptionCachedValueProvider.java   
private boolean isFileParsed() {
  return myXmlFile instanceof PsiFileEx && ((PsiFileEx)myXmlFile).isContentsLoaded();
}
项目:consulo    文件:DependenciesBuilder.java   
public static void analyzeFileDependencies(PsiFile file, DependencyProcessor processor) {
  file.putUserData(PsiFileEx.BATCH_REFERENCE_PROCESSING, Boolean.TRUE);
  file.accept(DependenciesVisitorFactory.getInstance().createVisitor(processor));
  file.putUserData(PsiFileEx.BATCH_REFERENCE_PROCESSING, null);
}
项目:consulo-xml    文件:FileDescriptionCachedValueProvider.java   
private boolean isFileParsed()
{
    return myXmlFile instanceof PsiFileEx && ((PsiFileEx) myXmlFile).isContentsLoaded();
}