Java Code Examples for com.intellij.psi.PsiFile.getName()

The following are Jave code examples for showing how to use getName() of the com.intellij.psi.PsiFile class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: intellij-postfix-templates   File: CptPsiImplUtil.java   Source Code and License Vote up 6 votes
public static ItemPresentation getPresentation(final CptTemplate element) {
	return new ItemPresentation() {
		@Nullable
		@Override
		public String getPresentableText() {
			return element.getTemplateName();
		}

		@Nullable
		@Override
		public String getLocationString() {
			PsiFile containingFile = element.getContainingFile();
			return containingFile == null ? null : containingFile.getName();
		}

		@Nullable
		@Override
		public Icon getIcon(boolean unused) {
			return CptIcons.FILE;
		}
	};
}
 
Example 2
Project: intellij-postfix-templates   File: CptPsiImplUtil.java   Source Code and License Vote up 6 votes
public static ItemPresentation getPresentation(final CptMapping element) {
	return new ItemPresentation() {
		@Nullable
		@Override
		public String getPresentableText() {
			return element.getMatchingClass();
		}

		@Nullable
		@Override
		public String getLocationString() {
			PsiFile containingFile = element.getContainingFile();
			return containingFile == null ? null : containingFile.getName();
		}

		@Nullable
		@Override
		public Icon getIcon(boolean unused) {
			return CptIcons.FILE;
		}
	};
}
 
Example 3
Project: yii2support   File: Util.java   Source Code and License Vote up 5 votes
@Nullable
private static PsiDirectory getDirectory(PsiElement element) {
    PsiFile file = element.getContainingFile().getOriginalFile();
    String filename = file.getName();
    PsiDirectory directory = file.getParent();

    filename = filename.substring(0, filename.lastIndexOf("."));

    if (directory != null) {
        if (filename.endsWith("Controller")) {
            directory = directory.getParentDirectory();
        } else {
            PsiDirectory messageParent = directory.findSubdirectory("messages");
            while (messageParent == null) {
                directory = directory.getParentDirectory();
                if (directory == null) {
                    break;
                }
                messageParent = directory.findSubdirectory("messages");
            }
        }
    }
    if (directory != null) {
        directory = directory.findSubdirectory("messages");
        if (directory != null && directory.getSubdirectories().length > 0) {
            directory = directory.getSubdirectories()[0];
            return directory;
        }
    }

    return null;
}
 
Example 4
Project: yii2support   File: CategoryLookupElement.java   Source Code and License Vote up 5 votes
@Override
public void renderElement(LookupElementPresentation presentation) {
    super.renderElement(presentation);

    if (myCategory instanceof PsiFile) {
        PsiFile file = (PsiFile) myCategory;
        String filename = file.getName();
        presentation.setIcon(file.getIcon(0));
        presentation.setItemText(filename.substring(0, filename.lastIndexOf(".")));
    }
}
 
Example 5
Project: educational-plugin   File: CCStudentInvisibleFileNode.java   Source Code and License Vote up 4 votes
public CCStudentInvisibleFileNode(Project project,
                                  PsiFile value,
                                  ViewSettings viewSettings) {
  super(project, value, viewSettings);
  myName = value.getName();
}