本文整理汇总了Java中org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument.getLabel方法的典型用法代码示例。如果您正苦于以下问题:Java GrNamedArgument.getLabel方法的具体用法?Java GrNamedArgument.getLabel怎么用?Java GrNamedArgument.getLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument
的用法示例。
在下文中一共展示了GrNamedArgument.getLabel方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitNamedArgument
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument; //导入方法依赖的package包/类
@Override
public void visitNamedArgument(GrNamedArgument argument) {
final GrArgumentLabel label = argument.getLabel();
if (label != null) {
PsiType expectedType = label.getExpectedArgumentType();
if (expectedType != null) {
expectedType = TypeConversionUtil.erasure(expectedType);
final GrExpression expr = argument.getExpression();
if (expr != null) {
final PsiType argType = expr.getType();
if (argType != null) {
final PsiClassType listType = JavaPsiFacade.getInstance(argument.getProject()).getElementFactory()
.createTypeByFQClassName(CommonClassNames.JAVA_UTIL_LIST, argument.getResolveScope());
if (listType.isAssignableFrom(argType)) return; //this is constructor arguments list
checkAssignability(expectedType, expr, argument);
}
}
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:GroovyUncheckedAssignmentOfMemberOfRawTypeInspection.java
示例2: visitNamedArgument
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument; //导入方法依赖的package包/类
@Override
public void visitNamedArgument(GrNamedArgument argument) {
GrArgumentLabel label = argument.getLabel();
if (label != null) {
PsiElement pparent = argument.getParent().getParent();
if (pparent instanceof GrCall && resolvesToDefaultConstructor(((GrCall)pparent))) {
final GroovyResolveResult resolveResult = label.advancedResolve();
PsiElement resolved = resolveResult.getElement();
PsiType type = resolved instanceof PsiField ?
((PsiField)resolved).getType() :
resolved instanceof PsiMethod && GroovyPropertyUtils.isSimplePropertySetter((PsiMethod)resolved) ?
((PsiMethod)resolved).getParameterList().getParameters()[0].getType()
: null;
PsiType substituted = resolveResult.getSubstitutor().substitute(type);
if (substituted != null) {
myResult = createSimpleSubTypeResult(substituted);
}
}
}
}
示例3: GrMapTypeFromNamedArgs
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument; //导入方法依赖的package包/类
public GrMapTypeFromNamedArgs(@NotNull JavaPsiFacade facade, @NotNull GlobalSearchScope scope, @NotNull GrNamedArgument[] namedArgs) {
super(facade, scope);
myStringEntries = ContainerUtil.newLinkedHashMap();
myOtherEntries = ContainerUtil.newArrayList();
for (GrNamedArgument namedArg : namedArgs) {
final GrArgumentLabel label = namedArg.getLabel();
final GrExpression expression = namedArg.getExpression();
if (label == null || expression == null) {
continue;
}
final String name = label.getName();
if (name != null) {
myStringEntries.put(name, expression);
}
else if (label.getExpression() != null) {
myOtherEntries.add(Couple.of(label.getExpression(), expression));
}
}
}
示例4: satisfiedBy
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument; //导入方法依赖的package包/类
@Override
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof GrListOrMap)) return false;
final GrListOrMap map = (GrListOrMap)element;
final GrNamedArgument[] namedArguments = map.getNamedArguments();
final GrExpression[] initializers = map.getInitializers();
if (initializers.length != 0) return false;
for (GrNamedArgument argument : namedArguments) {
final GrArgumentLabel label = argument.getLabel();
final GrExpression expression = argument.getExpression();
if (label == null || expression == null) return false;
if (label.getName() == null) return false;
}
return true;
}
示例5: namedArgumentListsAreEquivalent
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument; //导入方法依赖的package包/类
private static boolean namedArgumentListsAreEquivalent(GrNamedArgument[] namedArgs1, GrNamedArgument[] namedArgs2) {
if (namedArgs1.length != namedArgs2.length) {
return false;
}
for (GrNamedArgument arg1 : namedArgs1) {
final GrArgumentLabel label1 = arg1.getLabel();
if (label1 == null) {
return false;
}
final String name1 = label1.getName();
boolean found = false;
final GrExpression expression1 = arg1.getExpression();
for (GrNamedArgument arg2 : namedArgs2) {
final GrArgumentLabel label2 = arg2.getLabel();
if (label2 == null) {
return false;
}
final String name2 = label2.getName();
final GrExpression expression2 = arg2.getExpression();
if (name1 == null) {
if (name2 == null &&
expressionsAreEquivalent(((GrExpression)label1.getNameElement()), (GrExpression)label2.getNameElement()) &&
expressionsAreEquivalent(expression1, expression2)) {
found = true;
break;
}
}
else if (name1.equals(name2) && expressionsAreEquivalent(expression1, expression2)) {
found = true;
break;
}
}
if (!found) {
return false;
}
}
return true;
}
示例6: highlightNamedArgs
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument; //导入方法依赖的package包/类
private void highlightNamedArgs(GrNamedArgument[] namedArguments) {
for (GrNamedArgument namedArgument : namedArguments) {
final GrArgumentLabel label = namedArgument.getLabel();
if (label != null && label.getExpression() == null && label.getNameElement().getNode().getElementType() != GroovyTokenTypes.mSTAR) {
myHolder.createInfoAnnotation(label, null).setTextAttributes(GroovySyntaxHighlighter.MAP_KEY);
}
}
}
示例7: getOverriddenMethodVariants
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument; //导入方法依赖的package包/类
@NotNull
public static List<Pair<PsiMethod, PsiSubstitutor>> getOverriddenMethodVariants(GrNamedArgument namedArgument) {
final GrArgumentLabel label = namedArgument.getLabel();
if (label == null) {
return Collections.emptyList();
}
final String methodName = label.getName();
if (methodName == null) {
return Collections.emptyList();
}
final PsiElement map = namedArgument.getParent();
if (map instanceof GrListOrMap && ((GrListOrMap)map).isMap()) {
for (PsiType expected : GroovyExpectedTypesProvider.getDefaultExpectedTypes((GrExpression)map)) {
if (expected instanceof PsiClassType) {
final List<Pair<PsiMethod, PsiSubstitutor>> pairs = getMethodsToOverrideImplementInInheritor((PsiClassType)expected, false);
return ContainerUtil.findAll(pairs, new Condition<Pair<PsiMethod, PsiSubstitutor>>() {
@Override
public boolean value(Pair<PsiMethod, PsiSubstitutor> pair) {
return methodName.equals(pair.first.getName());
}
});
}
}
}
return Collections.emptyList();
}
示例8: checkDefaultMapConstructor
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument; //导入方法依赖的package包/类
private void checkDefaultMapConstructor(GrArgumentList argList, PsiElement element) {
if (argList == null) return;
final GrNamedArgument[] args = argList.getNamedArguments();
for (GrNamedArgument arg : args) {
final GrArgumentLabel label = arg.getLabel();
if (label == null) continue;
if (label.getName() == null) {
final PsiElement nameElement = label.getNameElement();
if (nameElement instanceof GrExpression) {
final PsiType argType = ((GrExpression)nameElement).getType();
if (argType != null && !TypesUtil.isAssignableByMethodCallConversion(TypesUtil.createType(CommonClassNames.JAVA_LANG_STRING, arg), argType, arg)) {
registerError(nameElement, GroovyBundle.message("property.name.expected"));
}
}
else if (!"*".equals(nameElement.getText())) {
registerError(nameElement, GroovyBundle.message("property.name.expected"));
}
}
else {
final PsiElement resolved = label.resolve();
if (resolved == null) {
if (element instanceof PsiMember && !(element instanceof PsiClass)) {
element = ((PsiMember)element).getContainingClass();
}
List<LocalQuickFix> fixes = new ArrayList<LocalQuickFix>(2);
if (element instanceof GrTypeDefinition) {
fixes.add(GroovyQuickFixFactory.getInstance().createCreateFieldFromConstructorLabelFix((GrTypeDefinition)element, label.getNamedArgument()));
}
if (element instanceof PsiClass) {
fixes.add(GroovyQuickFixFactory.getInstance().createDynamicPropertyFix(label, (PsiClass)element));
}
registerError(label, GroovyBundle.message("no.such.property", label.getName()), fixes.toArray(new LocalQuickFix[fixes.size()]),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:GroovyConstructorNamedArgumentsInspection.java