Search in sources :

Example 1 with PsiDisjunctionType

use of com.intellij.psi.PsiDisjunctionType in project intellij-community by JetBrains.

the class GrDisjunctionTypeElementImpl method getType.

@NotNull
@Override
public PsiType getType() {
    PsiType cachedType = myCachedType;
    if (cachedType != null)
        return myCachedType;
    final GrTypeElement[] typeElements = getTypeElements();
    final ArrayList<PsiType> types = new ArrayList<>();
    for (GrTypeElement typeElement : typeElements) {
        types.add(typeElement.getType());
    }
    cachedType = new PsiDisjunctionType(types, getManager());
    myCachedType = cachedType;
    return cachedType;
}
Also used : GrTypeElement(org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement) PsiDisjunctionType(com.intellij.psi.PsiDisjunctionType) ArrayList(java.util.ArrayList) PsiType(com.intellij.psi.PsiType) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with PsiDisjunctionType

use of com.intellij.psi.PsiDisjunctionType in project intellij-community by JetBrains.

the class PsiTypeTokenizer method tokenize.

@Override
public void tokenize(@NotNull PsiTypeElement element, TokenConsumer consumer) {
    final PsiType type = element.getType();
    if (type instanceof PsiDisjunctionType) {
        tokenizeComplexType(element, consumer);
        return;
    }
    final PsiClass psiClass = PsiUtil.resolveClassInType(type);
    if (psiClass == null || psiClass.getContainingFile() == null || psiClass.getContainingFile().getVirtualFile() == null) {
        return;
    }
    final String name = psiClass.getName();
    if (name == null) {
        return;
    }
    final VirtualFile virtualFile = psiClass.getContainingFile().getVirtualFile();
    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(element.getProject()).getFileIndex();
    final boolean isInSource = (virtualFile != null) && fileIndex.isInContent(virtualFile);
    if (isInSource) {
        final String elementText = element.getText();
        if (elementText.contains(name)) {
            consumer.consumeToken(element, elementText, true, 0, getRangeToCheck(elementText, name), IdentifierSplitter.getInstance());
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiDisjunctionType(com.intellij.psi.PsiDisjunctionType) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) PsiClass(com.intellij.psi.PsiClass) PsiType(com.intellij.psi.PsiType)

Aggregations

PsiDisjunctionType (com.intellij.psi.PsiDisjunctionType)2 PsiType (com.intellij.psi.PsiType)2 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiClass (com.intellij.psi.PsiClass)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1 GrTypeElement (org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement)1