当前位置: 首页>>代码示例>>Java>>正文


Java PhpReference类代码示例

本文整理汇总了Java中com.jetbrains.php.lang.psi.elements.PhpReference的典型用法代码示例。如果您正苦于以下问题:Java PhpReference类的具体用法?Java PhpReference怎么用?Java PhpReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PhpReference类属于com.jetbrains.php.lang.psi.elements包,在下文中一共展示了PhpReference类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getType

import com.jetbrains.php.lang.psi.elements.PhpReference; //导入依赖的package包/类
@Nullable
@Override
public PhpType getType(PsiElement psiElement) {
    if (DumbService.getInstance(psiElement.getProject()).isDumb()) {
        return null;
    }

    if (!(psiElement instanceof MethodReference) || !PhpElementsUtil.isMethodWithFirstStringOrFieldReference(psiElement, "get")) {
        return null;
    }

    MethodReference methodReference = (MethodReference) psiElement;
    if (methodReference.getParameters().length == 0) {
        return null;
    }

    PsiElement firstParam = methodReference.getParameters()[0];
    if (firstParam instanceof PhpReference) {
        PhpReference ref = (PhpReference) firstParam;
        if (ref.getText().toLowerCase().contains("::class")) {
            return new PhpType().add("#" + this.getKey() + ref.getSignature());
        }
    }

    return null;
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:27,代码来源:ObjectManagerTypeProvider.java

示例2: assertPhpReferenceResolveTo

import com.jetbrains.php.lang.psi.elements.PhpReference; //导入依赖的package包/类
public void assertPhpReferenceResolveTo(LanguageFileType languageFileType, String configureByText, ElementPattern<?> pattern) {
    myFixture.configureByText(languageFileType, configureByText);
    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());

    psiElement = PsiTreeUtil.getParentOfType(psiElement, PhpReference.class);
    if (psiElement == null) {
        fail("Element is not PhpReference.");
    }

    PsiElement resolve = ((PhpReference) psiElement).resolve();
    if(!pattern.accepts(resolve)) {
        fail(String.format("failed pattern matches element of '%s'", resolve == null ? "null" : resolve.toString()));
    }

    assertTrue(pattern.accepts(resolve));
}
 
开发者ID:Haehnchen,项目名称:idea-php-toolbox,代码行数:17,代码来源:SymfonyLightCodeInsightFixtureTestCase.java

示例3: assertPhpReferenceSignatureEquals

import com.jetbrains.php.lang.psi.elements.PhpReference; //导入依赖的package包/类
protected void assertPhpReferenceSignatureEquals(LanguageFileType languageFileType, @NotNull Class aClass, String configureByText, String typeSignature) {
    myFixture.configureByText(languageFileType, configureByText);
    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());

    psiElement = PsiTreeUtil.getParentOfType(psiElement, aClass);

    if (!(psiElement instanceof PhpReference)) {
        fail("Element is not PhpReference.");
    }

    PhpIndex phpIndex = PhpIndex.getInstance(myFixture.getProject());
    Collection<? extends PhpNamedElement> collection = phpIndex.getBySignature(((PhpReference)psiElement).getSignature(), null, 0);
    assertNotEmpty(collection);

    for (String type : collection.iterator().next().getType().getTypes()) {
        if (type.equals(typeSignature)) {
            return;
        }
    }

    fail("Can't find type: "+typeSignature+", found:"+collection.iterator().next().getType().toString());
}
 
开发者ID:Sorien,项目名称:silex-idea-plugin,代码行数:23,代码来源:CodeInsightFixtureTestCase.java

示例4: getType

import com.jetbrains.php.lang.psi.elements.PhpReference; //导入依赖的package包/类
@Nullable
@Override
public PhpType getType(PsiElement psiElement) {
    if (DumbService.getInstance(psiElement.getProject()).isDumb()) {
        return null;
    }

    if (!(psiElement instanceof MethodReference) || !PhpElementsUtil.isMethodWithFirstStringOrFieldReference(psiElement, "makeInstance")) {
        return null;
    }

    MethodReference methodReference = (MethodReference) psiElement;
    if (methodReference.getParameters().length == 0) {
        return null;
    }

    PsiElement firstParam = methodReference.getParameters()[0];

    if (firstParam instanceof PhpReference) {
        PhpReference ref = (PhpReference) firstParam;
        if (ref.getText().toLowerCase().contains("::class")) {
            return  new PhpType().add("#" + this.getKey() + ref.getSignature());
        }
    }

    return null;
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:28,代码来源:GeneralUtilityTypeProvider.java

示例5: assertPhpReferenceResolveTo

import com.jetbrains.php.lang.psi.elements.PhpReference; //导入依赖的package包/类
public void assertPhpReferenceResolveTo(LanguageFileType languageFileType, String configureByText, ElementPattern<?> pattern) {
    myFixture.configureByText(languageFileType, configureByText);
    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());

    psiElement = PsiTreeUtil.getParentOfType(psiElement, PhpReference.class);
    if (psiElement == null) {
        fail("Element is not PhpReference.");
    }

    assertTrue(pattern.accepts(((PhpReference) psiElement).resolve()));
}
 
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:12,代码来源:DotEnvLightCodeInsightFixtureTestCase.java

示例6: assertPhpReferenceNotResolveTo

import com.jetbrains.php.lang.psi.elements.PhpReference; //导入依赖的package包/类
public void assertPhpReferenceNotResolveTo(LanguageFileType languageFileType, String configureByText, ElementPattern<?> pattern) {
    myFixture.configureByText(languageFileType, configureByText);
    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());

    psiElement = PsiTreeUtil.getParentOfType(psiElement, PhpReference.class);
    if (psiElement == null) {
        fail("Element is not PhpReference.");
    }

    assertFalse(pattern.accepts(((PhpReference) psiElement).resolve()));
}
 
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:12,代码来源:DotEnvLightCodeInsightFixtureTestCase.java

示例7: assertPhpReferenceSignatureEquals

import com.jetbrains.php.lang.psi.elements.PhpReference; //导入依赖的package包/类
public void assertPhpReferenceSignatureEquals(LanguageFileType languageFileType, String configureByText, String typeSignature) {
    myFixture.configureByText(languageFileType, configureByText);
    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());

    psiElement = PsiTreeUtil.getParentOfType(psiElement, PhpReference.class);
    if (!(psiElement instanceof PhpReference)) {
        fail("Element is not PhpReference.");
    }

    assertEquals(typeSignature, ((PhpReference) psiElement).getSignature());
}
 
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:12,代码来源:DotEnvLightCodeInsightFixtureTestCase.java

示例8: getType

import com.jetbrains.php.lang.psi.elements.PhpReference; //导入依赖的package包/类
@Nullable
@Override
public String getType(PsiElement psiElement) {
    if (DumbService.getInstance(psiElement.getProject()).isDumb()) {
        return null;
    }

    if (!(psiElement instanceof MethodReference)) {
        return null;
    }

    MethodReference methodRef = ((MethodReference) psiElement);

    if (!("get".equals(methodRef.getName()) || "make".equals(methodRef.getName()))) {
        return null;
    }

    if (methodRef.getParameters().length == 0) {
        return null;
    }

    PsiElement firstParam = methodRef.getParameters()[0];

    if (firstParam instanceof PhpReference) {
        PhpReference ref = (PhpReference)firstParam;
        if (ref.getText().toLowerCase().contains("::class")) {
            return methodRef.getSignature() + "%" + ref.getSignature();
        }
    }

    return null;
}
 
开发者ID:pulyaevskiy,项目名称:phpstorm-phpdi,代码行数:33,代码来源:PhpDiTypeProvider.java

示例9: assertTypeEquals

import com.jetbrains.php.lang.psi.elements.PhpReference; //导入依赖的package包/类
protected void assertTypeEquals(LanguageFileType languageFileType, @NotNull Class aClass, String configureByText, String phpClassType) {
    myFixture.configureByText(languageFileType, configureByText);
    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());

    psiElement = PsiTreeUtil.getParentOfType(psiElement, aClass);

    if (!(psiElement instanceof PhpReference)) {
        fail("Element is not PhpReference.");
    }

    PhpIndex phpIndex = PhpIndex.getInstance(myFixture.getProject());
    Collection<? extends PhpNamedElement> collection = phpIndex.getBySignature(((PhpReference)psiElement).getSignature(), null, 0);
    assertNotEmpty(collection);

    String types = "";

    for (String type : collection.iterator().next().getType().getTypes()) {
        Collection<? extends PhpNamedElement> col = phpIndex.getBySignature(type, null, 0);
        if (col.size() == 0) {
            continue;
        }

        for (String classType : col.iterator().next().getType().getTypes()) {
            types = types + classType + '|';
            if (classType.equals(phpClassType)) {
                return;
            }
        }
    }

    fail("Can't find type: "+phpClassType+", found:"+types);
}
 
开发者ID:Sorien,项目名称:silex-idea-plugin,代码行数:33,代码来源:CodeInsightFixtureTestCase.java

示例10: assertGetPhpReference

import com.jetbrains.php.lang.psi.elements.PhpReference; //导入依赖的package包/类
@NotNull
private PsiElement assertGetPhpReference(LanguageFileType languageFileType, String configureByText) {
    myFixture.configureByText(languageFileType, configureByText);
    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());

    psiElement = PsiTreeUtil.getParentOfType(psiElement, PhpReference.class);
    if (psiElement == null) {
        fail("Element is not PhpReference.");
    }

    return psiElement;
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:13,代码来源:SymfonyLightCodeInsightFixtureTestCase.java

示例11: getNameIdentifier

import com.jetbrains.php.lang.psi.elements.PhpReference; //导入依赖的package包/类
private static ASTNode getNameIdentifier(
    final PsiElement fileSample,
    final String nameIdentifier
) {
    return valueOf(((PhpReference) getElementAssignmentValueByName(fileSample, nameIdentifier)).getNameNode());
}
 
开发者ID:rentalhost,项目名称:laravel-insight,代码行数:7,代码来源:ScopeDeclarationHandlerTest.java

示例12: assertPhpReferenceSignatureEquals

import com.jetbrains.php.lang.psi.elements.PhpReference; //导入依赖的package包/类
public void assertPhpReferenceSignatureEquals(LanguageFileType languageFileType, String configureByText, String typeSignature) {
    PsiElement psiElement = assertGetPhpReference(languageFileType, configureByText);
    assertEquals(typeSignature, ((PhpReference) psiElement).getSignature());
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:5,代码来源:SymfonyLightCodeInsightFixtureTestCase.java

示例13: assertPhpReferenceSignatureContains

import com.jetbrains.php.lang.psi.elements.PhpReference; //导入依赖的package包/类
public void assertPhpReferenceSignatureContains(LanguageFileType languageFileType, String configureByText, String typeSignature) {
    PsiElement psiElement = assertGetPhpReference(languageFileType, configureByText);
    assertTrue(((PhpReference) psiElement).getSignature().contains(typeSignature));
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:5,代码来源:SymfonyLightCodeInsightFixtureTestCase.java


注:本文中的com.jetbrains.php.lang.psi.elements.PhpReference类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。