本文整理汇总了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;
}
示例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));
}
示例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());
}
示例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;
}
示例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()));
}
示例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()));
}
示例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());
}
示例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;
}
示例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);
}
示例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());
}
示例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