Package com.intellij.psi

Examples of com.intellij.psi.PsiFile


      if (bugInstanceNode.getPsiFile() == null) {
        return; // no problem here
      }

      final PsiFile psiFile = bugInstanceNode.getPsiFile();
      if (psiFile != null) {
        final Document document = PsiDocumentManager.getInstance(_project).getDocument(psiFile);
        if (document != null) {
          final Editor editor = createEditor(bugInstanceNode, document);
          _parent.setPreviewEditor(editor, psiFile);
View Full Code Here


    final int lineStart = bugInstanceNode.getSourceLines()[0] - 1;
    final int lineEnd = bugInstanceNode.getSourceLines()[1];
    PsiElement element = null;
   
    final PsiFile psiFile = bugInstanceNode.getPsiFile();
    if(lineStart < 0 && lineEnd < 0) {   // find anonymous classes
      final PsiElement psiElement = IdeaUtilImpl.findAnonymousClassPsiElement(bugInstanceNode, _project);
      if (psiElement != null) {
        element = psiElement;
      }
View Full Code Here


  @SuppressWarnings({"TypeMayBeWeakened"})
  @Nullable
  public static VirtualFile getVirtualFile(@NotNull final PsiClass psiClass) {
    final PsiFile containingFile = psiClass.getContainingFile();
    if (containingFile != null) {
      return containingFile.getVirtualFile();
    }
    return null;
  }
View Full Code Here

      throw new NullPointerException("Expected not null Editor");
    }
    if (project == null) {
      throw new NullPointerException("Expected not null project");
    }
    final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(selectedEditor.getDocument());

    //noinspection ZeroLengthArrayAllocation
    PsiClass[] clazzes = new PsiClass[0];
    if (psiFile instanceof PsiJavaFile) {
      clazzes = ((PsiJavaFile) psiFile).getClasses();
View Full Code Here

    // Try through editor + PsiFile
    //final Editor editor = (Editor) dataContext.getData(DataConstants.EDITOR);// DataConstants.EDITOR
    final Editor editor = DataKeys.EDITOR.getData(dataContext);


    final PsiFile psiFile = getPsiFile(dataContext);
    if (editor != null && psiFile != null) {
      return psiFile.findElementAt(editor.getCaretModel().getOffset());
    }
    // Unable to find currentElement
    return null;
  }
View Full Code Here

  }


  @Nullable
  private static PsiFile getPsiFile(@NotNull final Project project, @NotNull final ExtendedProblemDescriptor problem) {
    final PsiFile file = problem.getPsiFile();
    return file == null ? null : PsiManager.getInstance(project).findFile(file.getVirtualFile());
  }
View Full Code Here


  @SuppressWarnings("UnusedDeclaration")
  @Nullable
  public static Document getDocument(@NotNull final Project project, @NotNull final ExtendedProblemDescriptor issue) {
    final PsiFile psiFile = getPsiFile(project, issue);
    return psiFile == null ? null : PsiDocumentManager.getInstance(project).getDocument(psiFile);
  }
View Full Code Here

  }


  @Nullable
  public static PsiElement findAnonymousClassPsiElement(@NotNull final BugInstanceNode bugInstanceNode, @NotNull final Project project) {
    final PsiFile psiFile = bugInstanceNode.getPsiFile();
    return findAnonymousClassPsiElement(psiFile, bugInstanceNode, project);
  }
View Full Code Here

  @Nullable
  protected PsiDocCommentOwner getContainer(final PsiElement context) {
    if (context == null || !context.getManager().isInProject(context)) {
      return null;
    }
    final PsiFile containingFile = context.getContainingFile();
    if (containingFile == null) {
      // for PsiDirectory
      return null;
    }
    if (!containingFile.getLanguage().isKindOf(JavaLanguage.INSTANCE) || context instanceof PsiFile) {
      return null;
    }
    PsiElement container = context;
    while (container instanceof PsiAnonymousClass || !(container instanceof PsiDocCommentOwner) || container instanceof PsiTypeParameter) {
      container = PsiTreeUtil.getParentOfType(container, PsiDocCommentOwner.class);
View Full Code Here

    if (!IdeaUtilImpl.isValidFileType(virtualFile.getFileType())) {
      return;
    }

    final PsiFile psiFile = PsiManager.getInstance(_project).findFile(virtualFile);

    if (psiFile instanceof PsiJavaFile) {
      final PsiClassOwner psiJavaFile = (PsiJavaFile) psiFile;
      final PsiClass[] psiClasses = psiJavaFile.getClasses();
View Full Code Here

TOP

Related Classes of com.intellij.psi.PsiFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.