本文整理汇总了Java中com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment.getNextPsiSibling方法的典型用法代码示例。如果您正苦于以下问题:Java PhpDocComment.getNextPsiSibling方法的具体用法?Java PhpDocComment.getNextPsiSibling怎么用?Java PhpDocComment.getNextPsiSibling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment
的用法示例。
在下文中一共展示了PhpDocComment.getNextPsiSibling方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTemplateAnnotationFilesWithSiblingMethod
import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入方法依赖的package包/类
/**
* Get templates on "@Template()" and on method attached to given PhpDocTag
*/
@NotNull
public static Map<String, Collection<PsiElement>> getTemplateAnnotationFilesWithSiblingMethod(@NotNull PhpDocTag phpDocTag) {
Map<String, Collection<PsiElement>> targets = new HashMap<>();
// template on direct PhpDocTag
Pair<String, Collection<PsiElement>> templateAnnotationFiles = TwigUtil.getTemplateAnnotationFiles(phpDocTag);
if(templateAnnotationFiles != null) {
targets.put(templateAnnotationFiles.getFirst(), templateAnnotationFiles.getSecond());
}
// templates on "Method" of PhpDocTag
PhpDocComment phpDocComment = PsiTreeUtil.getParentOfType(phpDocTag, PhpDocComment.class);
if(phpDocComment != null) {
PsiElement method = phpDocComment.getNextPsiSibling();
if(method instanceof Method) {
for (String name : TwigUtil.getControllerMethodShortcut((Method) method)) {
targets.put(name, new HashSet<>(getTemplatePsiElements(method.getProject(), name)));
}
}
}
return targets;
}
示例2: getPropertyValueCompletions
import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入方法依赖的package包/类
@Override
public void getPropertyValueCompletions(AnnotationPropertyParameter annotationPropertyParameter, AnnotationCompletionProviderParameter completionParameter) {
String propertyName = annotationPropertyParameter.getPropertyName();
if(propertyName == null) {
return;
}
if(propertyName.equals("name") && PhpLangUtil.equalsClassNames(annotationPropertyParameter.getPhpClass().getPresentableFQN(), "Doctrine\\ORM\\Mapping\\Column")) {
PhpDocComment phpDocComment = PsiTreeUtil.getParentOfType(annotationPropertyParameter.getElement(), PhpDocComment.class);
if(phpDocComment != null) {
PhpPsiElement classField = phpDocComment.getNextPsiSibling();
if(classField != null && classField.getNode().getElementType() == PhpElementTypes.CLASS_FIELDS) {
Field field = PsiTreeUtil.getChildOfType(classField, Field.class);
if(field != null) {
String name = field.getName();
if(StringUtils.isNotBlank(name)) {
completionParameter.getResult().addElement(LookupElementBuilder.create(underscore(name)));
}
}
}
}
}
}
示例3: getClassByClassPhpDoc
import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入方法依赖的package包/类
@Nullable
public static PhpClass getClassByClassPhpDoc(PhpDocComment comment) {
PsiElement nextElement = comment.getNextPsiSibling();
int limit = 10;
while (limit > 0) {
if (nextElement instanceof PhpClass)
return (PhpClass) nextElement;
else if (nextElement == null)
return null;
nextElement = nextElement.getNextSibling();
limit--;
}
return null;
}
示例4: visitPhpDocTag
import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入方法依赖的package包/类
private void visitPhpDocTag(PhpDocTag element) {
String name = StringUtils.stripStart(element.getName(), "@");
if(!"Event".equalsIgnoreCase(name)) {
return;
}
PhpDocComment phpDocComment = ObjectUtils.tryCast(element.getParent(), PhpDocComment.class);
if(phpDocComment == null) {
return;
}
PhpPsiElement nextPsiSibling = phpDocComment.getNextPsiSibling();
if(nextPsiSibling == null || nextPsiSibling.getNode().getElementType() != PhpElementTypes.CLASS_CONSTANTS) {
return;
}
ClassConstImpl childOfAnyType = PsiTreeUtil.findChildOfAnyType(nextPsiSibling, ClassConstImpl.class);
if(childOfAnyType == null) {
return;
}
PsiElement defaultValue = childOfAnyType.getDefaultValue();
if(!(defaultValue instanceof StringLiteralExpression)) {
return;
}
String contents = ((StringLiteralExpression) defaultValue).getContents();
String fqn = StringUtils.stripStart(childOfAnyType.getFQN(), "\\");
map.put(contents, new DispatcherEvent(
fqn,
findClassInstance(phpDocComment, element))
);
}
示例5: getMethodScope
import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入方法依赖的package包/类
@Nullable
public static Method getMethodScope(@NotNull PhpDocTag phpDocTag) {
PhpDocComment parentOfType = PsiTreeUtil.getParentOfType(phpDocTag, PhpDocComment.class);
if(parentOfType == null) {
return null;
}
PhpPsiElement method = parentOfType.getNextPsiSibling();
if(!(method instanceof Method)) {
return null;
}
return (Method) method;
}
示例6: isAnnotationPhpDocTag
import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入方法依赖的package包/类
public static boolean isAnnotationPhpDocTag(PhpDocTag phpDocTag) {
PhpDocComment phpDocComment = PsiTreeUtil.getParentOfType(phpDocTag, PhpDocComment.class);
if(phpDocComment == null) {
return false;
}
PsiElement nextPsiElement = phpDocComment.getNextPsiSibling();
if(nextPsiElement == null || !(nextPsiElement instanceof Method || nextPsiElement instanceof PhpClass || nextPsiElement.getNode().getElementType() == PhpElementTypes.CLASS_FIELDS)) {
return false;
}
return true;
}
示例7: findAnnotationTarget
import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入方法依赖的package包/类
@Nullable
static public AnnotationTarget findAnnotationTarget(@Nullable PhpDocComment phpDocComment) {
if(phpDocComment == null) {
return null;
}
if(phpDocComment.getNextPsiSibling() instanceof Method) {
return AnnotationTarget.METHOD;
}
if(PlatformPatterns.psiElement(PhpElementTypes.CLASS_FIELDS).accepts(phpDocComment.getNextPsiSibling())) {
return AnnotationTarget.PROPERTY;
}
if(phpDocComment.getNextPsiSibling() instanceof PhpClass) {
return AnnotationTarget.CLASS;
}
// workaround: if file has no use statements all is wrapped inside a group
if(phpDocComment.getNextPsiSibling() instanceof GroupStatement) {
PsiElement groupStatement = phpDocComment.getNextPsiSibling();
if(groupStatement != null && groupStatement.getFirstChild() instanceof PhpClass) {
return AnnotationTarget.CLASS;
}
}
return null;
}