本文整理汇总了Java中com.intellij.psi.PsiNameValuePair.getName方法的典型用法代码示例。如果您正苦于以下问题:Java PsiNameValuePair.getName方法的具体用法?Java PsiNameValuePair.getName怎么用?Java PsiNameValuePair.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiNameValuePair
的用法示例。
在下文中一共展示了PsiNameValuePair.getName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isOnXParameterAnnotation
import com.intellij.psi.PsiNameValuePair; //导入方法依赖的package包/类
public static boolean isOnXParameterAnnotation(HighlightInfo highlightInfo, PsiFile file) {
if (!(ANNOTATION_TYPE_EXPECTED.equals(highlightInfo.getDescription())
|| CANNOT_RESOLVE_UNDERSCORES_MESSAGE.matcher(StringUtil.notNullize(highlightInfo.getDescription())).matches())) {
return false;
}
PsiElement highlightedElement = file.findElementAt(highlightInfo.getStartOffset());
PsiNameValuePair nameValuePair = findContainingNameValuePair(highlightedElement);
if (nameValuePair == null || !(nameValuePair.getContext() instanceof PsiAnnotationParameterList)) {
return false;
}
String parameterName = nameValuePair.getName();
if (!ONX_PARAMETERS.contains(parameterName)) {
return false;
}
PsiElement containingAnnotation = nameValuePair.getContext().getContext();
return containingAnnotation instanceof PsiAnnotation && ONXABLE_ANNOTATIONS.contains(((PsiAnnotation) containingAnnotation).getQualifiedName());
}
示例2: addInternal
import com.intellij.psi.PsiNameValuePair; //导入方法依赖的package包/类
@Override
public ASTNode addInternal(ASTNode first, ASTNode last, ASTNode anchor, Boolean before) {
if (first.getElementType() == GroovyElementTypes.ANNOTATION_MEMBER_VALUE_PAIR && last.getElementType() ==
GroovyElementTypes.ANNOTATION_MEMBER_VALUE_PAIR) {
ASTNode lparenth = getNode().getFirstChildNode();
ASTNode rparenth = getNode().getLastChildNode();
if (lparenth == null) {
getNode().addLeaf(GroovyTokenTypes.mLPAREN, "(", null);
}
if (rparenth == null) {
getNode().addLeaf(GroovyTokenTypes.mRPAREN, ")", null);
}
final PsiNameValuePair[] nodes = getAttributes();
if (nodes.length == 1) {
final PsiNameValuePair pair = nodes[0];
if (pair.getName() == null) {
final String text = pair.getValue().getText();
try {
final PsiAnnotation annotation = GroovyPsiElementFactory.getInstance(getProject()).createAnnotationFromText("@AAA(value = " + text + ")");
getNode().replaceChild(pair.getNode(), annotation.getParameterList().getAttributes()[0].getNode());
}
catch (IncorrectOperationException e) {
LOG.error(e);
}
}
}
if (anchor == null && before != null) {
anchor = before.booleanValue() ? getNode().getLastChildNode() : getNode().getFirstChildNode();
}
}
return super.addInternal(first, last, anchor, before);
}
示例3: addInternal
import com.intellij.psi.PsiNameValuePair; //导入方法依赖的package包/类
@Override
public ASTNode addInternal(ASTNode first, ASTNode last, ASTNode anchor, Boolean before) {
if (first.getElementType() == ANNOTATION_MEMBER_VALUE_PAIR && last.getElementType() == ANNOTATION_MEMBER_VALUE_PAIR) {
ASTNode lparenth = getNode().getFirstChildNode();
ASTNode rparenth = getNode().getLastChildNode();
if (lparenth == null) {
getNode().addLeaf(mLPAREN, "(", null);
}
if (rparenth == null) {
getNode().addLeaf(mRPAREN, ")", null);
}
final PsiNameValuePair[] nodes = getAttributes();
if (nodes.length == 1) {
final PsiNameValuePair pair = nodes[0];
if (pair.getName() == null) {
final String text = pair.getValue().getText();
try {
final PsiAnnotation annotation = GroovyPsiElementFactory.getInstance(getProject()).createAnnotationFromText("@AAA(value = " + text + ")");
getNode().replaceChild(pair.getNode(), annotation.getParameterList().getAttributes()[0].getNode());
}
catch (IncorrectOperationException e) {
LOG.error(e);
}
}
}
if (anchor == null && before != null) {
anchor = before.booleanValue() ? getNode().getLastChildNode() : getNode().getFirstChildNode();
}
}
return super.addInternal(first, last, anchor, before);
}
示例4: selectAnnotationAttribute
import com.intellij.psi.PsiNameValuePair; //导入方法依赖的package包/类
private PsiNameValuePair selectAnnotationAttribute() {
PsiNameValuePair result = null;
PsiNameValuePair[] attributes = myAnnotation.getParameterList().getAttributes();
for (PsiNameValuePair attribute : attributes) {
@NonNls final String attributeName = attribute.getName();
if (equals(myName, attributeName) || attributeName == null && myName.equals(PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME)) {
result = attribute;
break;
}
}
return result;
}
示例5: findDefaultValue
import com.intellij.psi.PsiNameValuePair; //导入方法依赖的package包/类
public static PsiElement findDefaultValue(PsiAnnotation annotation){
final PsiAnnotationParameterList parameters = annotation.getParameterList();
final PsiNameValuePair[] pairs = parameters.getAttributes();
for(PsiNameValuePair pair : pairs){
final String name = pair.getName();
if("value".equals(name) || name == null){
return pair.getValue();
}
}
return null;
}