Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
34,300
JVMElementFactory (Project project) { return GroovyPsiElementFactory.getInstance(project); }
getFactory
34,301
PsiElement (PsiElement expression, Project project) { return GroovyPsiElementFactory.getInstance(project).createExpressionFromText(expression.getText(), expression); }
convert
34,302
void (@NotNull GroovyElementVisitor visitor) { visitor.visitElement(this); }
accept
34,303
void (@NotNull GroovyElementVisitor visitor) { acceptGroovyChildren(this, visitor); }
acceptChildren
34,304
GrExpression (final PsiElement element) { for (PsiElement cur = element.getFirstChild(); cur != null; cur = cur.getNextSibling()) { if (cur instanceof GrExpression) return (GrExpression)cur; } return null; }
findExpressionChild
34,305
void (PsiElement parent, GroovyElementVisitor visitor) { PsiElement child = parent.getFirstChild(); while (child != null) { ProgressManager.checkCanceled(); if (child instanceof GroovyPsiElement) { ((GroovyPsiElement) child).accept(visitor); } child = child.getNextSibling(); } }
acceptGroovyChildren
34,306
void (PsiElement from, PsiElement[] elements) { ASTNode parentNode = from.getNode(); for (PsiElement element : elements) { if (element.isValid()) { ASTNode node = element.getNode(); if (node == null || node.getTreeParent() != parentNode) { throw new IncorrectOperationException(); } parentNode.removeChild(node); } } }
removeElements
34,307
void (GroovyPsiElement element) { if (element.getParent() == null || element.getParent().getNode() == null) { throw new IncorrectOperationException(); } ASTNode parentNode = element.getParent().getNode(); ASTNode prevNode = element.getNode().getTreePrev(); parentNode.removeChild(element.getNode()); if (prevNode != null && TokenSets.SEPARATORS.contains(prevNode.getElementType())) { parentNode.removeChild(prevNode); } }
removeStatement
34,308
String () { return myFqn; }
getJavaClassName
34,309
PsiClassType (@NotNull LanguageLevel languageLevel) { return new LazyFqnClassType(myFqn, languageLevel, getResolveScope(), myFacade); }
setLanguageLevel
34,310
String () { return getJavaClassName(); }
getInternalCanonicalText
34,311
boolean () { return !myFacade.getProject().isDisposed(); }
isValid
34,312
PsiClassType () { return this; }
rawType
34,313
PsiClassType (@NotNull String fqn, LanguageLevel languageLevel, @NotNull GlobalSearchScope scope, @NotNull JavaPsiFacade facade) { return new LazyFqnClassType(fqn, languageLevel, scope, facade); }
getLazyType
34,314
PsiClassType (@NotNull String fqn, @NotNull PsiElement context) { return new LazyFqnClassType(fqn, LanguageLevel.JDK_1_5, context.getResolveScope(), JavaPsiFacade.getInstance(context.getProject())); }
getLazyType
34,315
GrLiteral (PsiElement expr) { PsiElement firstChild = expr; while (firstChild != null) { if (firstChild instanceof GrLiteral && GrStringUtil.isRegex((GrLiteral)firstChild)) return (GrLiteral)firstChild; firstChild = firstChild.getFirstChild(); } return null; }
getRegexAtTheBeginning
34,316
boolean (PsiElement el) { final PsiElement prev = PsiUtil.getPreviousNonWhitespaceToken(el); return prev != null && prev.getNode().getElementType() == GroovyTokenTypes.mIDENT; }
isAfterIdentifier
34,317
GrExpression (GrExpression oldExpr, GrExpression newExpr, boolean removeUnnecessaryParentheses) { PsiElement oldParent = oldExpr.getParent(); if (oldParent == null) throw new PsiInvalidElementAccessException(oldExpr); if (convertToMethodCall(oldExpr)) { newExpr = ApplicationStatementUtil.convertToMethodCallExpression(newExpr); } // Remove unnecessary parentheses if (removeUnnecessaryParentheses && oldParent instanceof GrParenthesizedExpression && !(oldParent.getParent() instanceof GrArgumentLabel)) { return ((GrExpression)oldParent).replaceWithExpression(newExpr, true); } //regexes cannot be after identifier , try to replace it with simple string if (getRegexAtTheBeginning(newExpr) != null && isAfterIdentifier(oldExpr)) { final PsiElement copy = newExpr.copy(); final GrLiteral regex = getRegexAtTheBeginning(copy); LOG.assertTrue(regex != null); final GrLiteral stringLiteral = GrStringUtil.createStringFromRegex(regex); if (regex == copy) { return oldExpr.replaceWithExpression(stringLiteral, removeUnnecessaryParentheses); } else { regex.replace(stringLiteral); return oldExpr.replaceWithExpression((GrExpression)copy, removeUnnecessaryParentheses); } } GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(oldExpr.getProject()); if (oldParent instanceof GrStringInjection) { if (newExpr instanceof GrString || newExpr instanceof GrLiteral && ((GrLiteral)newExpr).getValue() instanceof String) { return GrStringUtil.replaceStringInjectionByLiteral((GrStringInjection)oldParent, (GrLiteral)newExpr); } else { GrClosableBlock block = factory.createClosureFromText("{foo}"); oldParent.getNode().replaceChild(oldExpr.getNode(), block.getNode()); GrStatement[] statements = block.getStatements(); return ((GrExpression)statements[0]).replaceWithExpression(newExpr, removeUnnecessaryParentheses); } } if (PsiTreeUtil.getParentOfType(oldExpr, GrStringInjection.class, false, GrCodeBlock.class) != null) { final GrStringInjection stringInjection = PsiTreeUtil.getParentOfType(oldExpr, GrStringInjection.class); assert stringInjection != null; GrStringUtil.wrapInjection(stringInjection); return oldExpr.replaceWithExpression(newExpr, removeUnnecessaryParentheses); } //check priorities if (oldParent instanceof GrExpression && !(oldParent instanceof GrParenthesizedExpression)) { GrExpression addedParenth = checkPrecedence(newExpr, oldExpr) ? parenthesize(newExpr, oldExpr.getContext()) : newExpr; if (newExpr != addedParenth) { return oldExpr.replaceWithExpression(addedParenth, removeUnnecessaryParentheses); } } if (oldParent instanceof GrForInClause) { return (GrExpression) oldExpr.replace(parenthesize(newExpr, oldExpr.getContext())); } //if replace closure argument with expression //we should add the expression in arg list if (oldExpr instanceof GrClosableBlock && !(newExpr instanceof GrClosableBlock) && oldParent instanceof GrMethodCallExpression && ArrayUtil.contains(oldExpr, ((GrMethodCallExpression)oldParent).getClosureArguments())) { return ((GrMethodCallExpression)oldParent).replaceClosureArgument((GrClosableBlock)oldExpr, newExpr); } newExpr = (GrExpression)oldExpr.replace(newExpr); //if newExpr is the first grand child of command argument list we should replace command arg list with parenthesised arg list. // In other case the code will be broken. So we try to find wrapping command arg list counting levels. After arg list replace we go inside it // to find target parenthesised expression. if (newExpr instanceof GrParenthesizedExpression && isFirstChild(newExpr)) { int parentCount = 0; PsiElement element = oldParent; while (!(element instanceof GrCommandArgumentList)) { if (element instanceof GrCodeBlock || element instanceof GrParenthesizedExpression) break; if (element instanceof PsiFile) break; final PsiElement parent = element.getParent(); if (parent == null) break; if (!isFirstChild(element)) break; element = parent; parentCount++; } if (element instanceof GrCommandArgumentList commandArgList) { final PsiElement parent = commandArgList.getParent(); LOG.assertTrue(parent instanceof GrApplicationStatement); final GrMethodCall methodCall = factory.createMethodCallByAppCall((GrApplicationStatement)parent); final GrMethodCall newCall = (GrMethodCall)parent.replace(methodCall); PsiElement result = newCall.getArgumentList().getAllArguments()[0]; for (int i = 0; i < parentCount; i++) { assert result != null; result = PsiUtil.skipWhitespacesAndComments(result.getFirstChild(), true); } LOG.assertTrue(result instanceof GrParenthesizedExpression); return (GrExpression)result; } } return newExpr; }
replaceExpression
34,318
boolean (GrExpression position) { if (position instanceof GrApplicationStatement) return false; final PsiElement parent = position.getParent(); if (parent instanceof GrVariable && ((GrVariable)parent).getInitializerGroovy() == position) return false; return true; }
convertToMethodCall
34,319
boolean (PsiElement element) { return PsiUtil.skipWhitespacesAndComments(element.getParent().getFirstChild(), true) == element; }
isFirstChild
34,320
void (GrVariable variable) { final GrVariableDeclaration varDecl = (GrVariableDeclaration) variable.getParent(); final List<GrVariable> variables = Arrays.asList(varDecl.getVariables()); if (!variables.contains(variable)) { throw new IllegalArgumentException(); } final PsiElement parent = varDecl.getParent(); final ASTNode owner = parent.getNode(); if (variables.size() == 1 && owner != null) { PsiElement next = varDecl.getNextSibling(); // remove redundant semicolons while (next != null && next.getNode() != null && next.getNode().getElementType() == GroovyTokenTypes.mSEMI) { PsiElement tmpNext = next.getNextSibling(); next.delete(); next = tmpNext; } removeNewLineAfter(varDecl); varDecl.delete(); return; } variable.delete(); }
removeVariable
34,321
PsiElement (PsiElement previousLeaf) { while ((previousLeaf instanceof PsiWhiteSpace || previousLeaf instanceof PsiComment || previousLeaf instanceof PsiErrorElement)) { previousLeaf = previousLeaf.getPrevSibling(); } return previousLeaf; }
realPrevious
34,322
void (String name, PsiElement nameElement) { final PsiElement newNameElement = GroovyPsiElementFactory.getInstance(nameElement.getProject()).createReferenceNameFromText(name); nameElement.replace(newNameElement); }
setName
34,323
boolean (MethodSignature superSignatureCandidate, MethodSignature subSignature) { return MethodSignatureUtil.isSubsignature(superSignatureCandidate, subSignature); }
isExtendsSignature
34,324
PsiMethod (GroovyResolveResult @NotNull [] results) { if (results.length != 1) return null; final PsiElement element = results[0].getElement(); return element instanceof PsiMethod ? (PsiMethod) element : null; }
extractUniqueElement
34,325
GroovyResolveResult (@NotNull Collection<? extends GroovyResolveResult> results) { return results.size() == 1 ? results.iterator().next() : EmptyGroovyResolveResult.INSTANCE; }
extractUniqueResult
34,326
GroovyResolveResult (GroovyResolveResult @NotNull [] results) { if (results.length != 1) return EmptyGroovyResolveResult.INSTANCE; return results[0]; }
extractUniqueResult
34,327
PsiMethod[] (@Nullable List<? extends CandidateInfo> list) { if (list == null) return PsiMethod.EMPTY_ARRAY; PsiMethod[] result = new PsiMethod[list.size()]; for (int i = 0; i < list.size(); i++) { result[i] = (PsiMethod) list.get(i).getElement(); } return result; }
mapToMethods
34,328
String (@NotNull GrNamedElement namedElement) { PsiElement nameElement = namedElement.getNameIdentifierGroovy(); ASTNode node = nameElement.getNode(); LOG.assertTrue(node != null); if (node.getElementType() == GroovyTokenTypes.mIDENT || TokenSets.CODE_REFERENCE_ELEMENT_NAME_TOKENS.contains(node.getElementType())) { return nameElement.getText(); } if (GroovyTokenSets.STRING_LITERALS.contains(node.getElementType())) { final Object value = GrLiteralImpl.getLiteralValue(nameElement); if (value instanceof String) { return (String)value; } else { return GrStringUtil.removeQuotes(nameElement.getText()); } } throw new IncorrectOperationException("incorrect name element: " + node.getElementType() + ", named element: " + namedElement); }
getName
34,329
void (@NotNull GrStatement statement) { ASTNode parentNode = statement.getParent().getNode(); ASTNode next = statement.getNode().getTreeNext(); if (parentNode != null && next != null && GroovyTokenTypes.mNLS == next.getElementType()) { parentNode.removeChild(next); } }
removeNewLineAfter
34,330
boolean (GrMethod method) { if (!method.getName().equals(MAIN_METHOD)) return false; else if (!GrModifierListUtil.hasCodeModifierProperty(method, PsiModifier.STATIC)) return false; final GrParameter[] parameters = method.getParameters(); if (parameters.length == 0) return false; if (parameters.length == 1 && parameters[0].getTypeElementGroovy() == null) return true; int args_count = 0; int optional_count = 0; for (GrParameter p : parameters) { final GrTypeElement declaredType = p.getTypeElementGroovy(); boolean optional = p.isOptional(); if (optional) { optional_count++; } else if (declaredType == null || declaredType.getType().equalsToText(CommonClassNames.JAVA_LANG_STRING + "[]")) { args_count++; } } return optional_count == parameters.length - 1 && args_count == 1; }
isMainMethod
34,331
void (PsiElement container, @NotNull PsiElement statement) { PsiElement next = statement.getNextSibling(); while (next != null) { final ASTNode node = next.getNode(); final IElementType type = node.getElementType(); if (type == GroovyTokenTypes.mSEMI || type == TokenType.WHITE_SPACE && !next.getText().contains("\n")) { final PsiElement nNext = next.getNextSibling(); container.deleteChildRange(next, next); next = nNext; } else if (type == GroovyTokenTypes.mNLS || type == TokenType.WHITE_SPACE && next.getText().contains("\n")) { final String text = next.getText(); final int first = text.indexOf("\n"); final int second = text.indexOf("\n", first + 1); if (second < 0) { container.deleteChildRange(next, next); return; } final String substring = text.substring(second); container.getNode() .replaceChild(node, Factory.createSingleLeafElement(type, substring, 0, substring.length(), null, container.getManager())); return; } else { break; } } }
deleteStatementTail
34,332
boolean (PsiType exprType, PsiType[] argTypes, PsiElement context, boolean isLValue) { return exprType instanceof PsiArrayType && (isLValue && argTypes.length == 2 || !isLValue && argTypes.length == 1) && TypesUtil.isAssignableByMethodCallConversion(PsiTypes.intType(), argTypes[0], context); }
isSimpleArrayAccess
34,333
String (ASTNode node) { final TreeElement treeElement = (TreeElement)node; final int length; { final GroovyBufferVisitor lengthVisitor = new GroovyBufferVisitor(true, true, 0, null); treeElement.acceptTree(lengthVisitor); length = lengthVisitor.getEnd(); } final char[] buffer = new char[length]; { final GroovyBufferVisitor textVisitor = new GroovyBufferVisitor(true, true, 0, buffer); treeElement.acceptTree(textVisitor); } return new String(buffer); }
getTextSkipWhiteSpaceAndComments
34,334
boolean (LeafElement element) { return super.isIgnored(element) || (mySkipWhiteSpace && element.getElementType() == GroovyTokenTypes.mNLS) ; }
isIgnored
34,335
PsiCodeBlock (GrOpenBlock block) { if (block == null) return null; final SoftReference<PsiCodeBlock> ref = block.getUserData(PSI_CODE_BLOCK); final PsiCodeBlock body = dereference(ref); if (body != null) return body; final GrSyntheticCodeBlock newBody = new GrSyntheticCodeBlock(block); block.putUserData(PSI_CODE_BLOCK, new SoftReference<>(newBody)); return newBody; }
getOrCreatePsiCodeBlock
34,336
PsiTypeElement (GrTypeElement typeElement) { if (typeElement == null) return null; final SoftReference<PsiTypeElement> ref = typeElement.getUserData(PSI_TYPE_ELEMENT); final PsiTypeElement element = dereference(ref); if (element != null) return element; final GrSyntheticTypeElement newTypeElement = new GrSyntheticTypeElement(typeElement); typeElement.putUserData(PSI_TYPE_ELEMENT, new SoftReference<>(newTypeElement)); return newTypeElement; }
getOrCreateTypeElement
34,337
PsiExpression (GrExpression expr) { if (expr == null) return null; final SoftReference<PsiExpression> ref = expr.getUserData(PSI_EXPRESSION); final PsiExpression element = dereference(ref); if (element != null) return element; final PsiExpression newExpr = expr instanceof GrLiteral ? new GrSyntheticLiteralExpression((GrLiteral)expr) : new GrSyntheticExpression(expr); expr.putUserData(PSI_EXPRESSION, new SoftReference<>(newExpr)); return newExpr; }
getOrCreatePisExpression
34,338
boolean (GrParameter[] parameters) { return parameters.length > 0 && parameters[parameters.length - 1].isVarArgs(); }
isVarArgs
34,339
PsiAnnotation (@NotNull PsiModifierListOwner field, @NotNull String annotationName) { final PsiModifierList modifierList = field.getModifierList(); if (modifierList == null) return null; return modifierList.findAnnotation(annotationName); }
getAnnotation
34,340
GrConstructorInvocation (GrMethod constructor) { if (constructor instanceof GrReflectedMethod && ((GrReflectedMethod)constructor).getSkippedParameters().length > 0) return null; LOG.assertTrue(constructor.isConstructor()); GrOpenBlock body = constructor.getBlock(); if (body == null) return null; GrStatement[] statements = body.getStatements(); if (statements.length > 0 && statements[0] instanceof GrConstructorInvocation) { return (GrConstructorInvocation) statements[0]; } return null; }
getChainingConstructorInvocation
34,341
GrMethod[] (GrMethod method) { final GrReflectedMethod[] reflectedMethods = method.getReflectedMethods(); return reflectedMethods.length > 0 ? reflectedMethods : new GrMethod[]{method}; }
getMethodOrReflectedMethods
34,342
PsiType (GrExpression diamondNew) { PsiElement skipped = PsiUtil.skipParentheses(diamondNew, true); assert skipped != null; PsiElement pParent = skipped.getParent(); if (pParent instanceof GrAssignmentExpression && PsiTreeUtil.isAncestor(((GrAssignmentExpression)pParent).getRValue(), diamondNew, false)) { GrExpression lValue = ((GrAssignmentExpression)pParent).getLValue(); if (PsiUtil.mightBeLValue(lValue)) { return lValue.getNominalType(); } } else if (pParent instanceof GrVariable && ((GrVariable)pParent).getInitializerGroovy() == diamondNew) { return ((GrVariable)pParent).getDeclaredType(); } else if (pParent instanceof GrListOrMap) { PsiElement ppParent = PsiUtil.skipParentheses(pParent.getParent(), true); if (ppParent instanceof GrTupleAssignmentExpression && PsiTreeUtil.isAncestor(((GrTupleAssignmentExpression)ppParent).getRValue(), pParent, false)) { GrTuple lValue = ((GrTupleAssignmentExpression)ppParent).getLValue(); GrExpression[] initializers = ((GrListOrMap)pParent).getInitializers(); int index = ArrayUtil.find(initializers, diamondNew); GrExpression[] expressions = lValue.getExpressions(); if (index < expressions.length) { return expressions[index].getNominalType(); } } } return null; }
inferExpectedTypeForDiamond
34,343
PsiType (@NotNull PsiType type, @NotNull GrExpression expression) { GrExpression topLevel = expression; while (topLevel.getParent() instanceof GrIndexProperty && ((GrIndexProperty)topLevel.getParent()).getInvokedExpression() == topLevel) { topLevel = (GrExpression)topLevel.getParent(); } PsiType captured = type; if (captured instanceof PsiClassType && !PsiUtil.isAccessedForWriting(topLevel)) { captured = com.intellij.psi.util.PsiUtil.captureToplevelWildcards(type, expression); } return doNormalizeWildcardByPosition(captured, expression, topLevel); }
normalizeWildcardTypeByPosition
34,344
PsiType (final PsiType type, final GrExpression expression, final GrExpression topLevel) { if (type instanceof PsiCapturedWildcardType) { return doNormalizeWildcardByPosition(((PsiCapturedWildcardType)type).getUpperBound(), expression, topLevel); } if (type instanceof PsiWildcardType wildcardType) { if (PsiUtil.isAccessedForWriting(topLevel)) { return wildcardType.getBound(); } else { if (wildcardType.isExtends()) { return wildcardType.getBound(); } else { return TypesUtil.getJavaLangObject(expression); } } } else if (type instanceof PsiArrayType) { final PsiType componentType = ((PsiArrayType)type).getComponentType(); final PsiType normalizedComponentType = doNormalizeWildcardByPosition(componentType, expression, topLevel); if (normalizedComponentType != componentType) { assert normalizedComponentType != null; return normalizedComponentType.createArrayType(); } } return type; }
doNormalizeWildcardByPosition
34,345
boolean (@Nullable PsiElement next, @NotNull final IElementType type) { if (next == null) return false; final ASTNode astNode = next.getNode(); return astNode != null && astNode.getElementType() == type; }
hasElementType
34,346
boolean (@Nullable GrNamedArgumentsOwner list) { if (list == null) return false; for (PsiElement child = list.getFirstChild(); child != null; child = child.getNextSibling()) { if (child instanceof GrNamedArgument) return true; } return false; }
hasNamedArguments
34,347
boolean (@Nullable GrArgumentList list) { if (list == null) return false; for (PsiElement child = list.getFirstChild(); child != null; child = child.getNextSibling()) { if (child instanceof GrExpression) return true; } return false; }
hasExpressionArguments
34,348
boolean (@NotNull GrCall call) { if (call.hasClosureArguments()) return true; GrArgumentList list = call.getArgumentList(); return hasExpressionArguments(list) || hasNamedArguments(list); }
hasArguments
34,349
PsiElement (@NotNull GrStatement statement) { final PsiElement nextNonSpace = PsiUtil.skipWhitespaces(statement.getNextSibling(), true); if (nextNonSpace != null && nextNonSpace.getNode().getElementType() == GroovyTokenTypes.mSEMI) { return nextNonSpace; } return null; }
findTailingSemicolon
34,350
PsiType (PsiElement position) { final GrControlFlowOwner flowOwner = ControlFlowUtils.findControlFlowOwner(position); if (flowOwner == null) return null; final PsiElement parent = flowOwner.getContext(); if (flowOwner instanceof GrOpenBlock && parent instanceof GrMethod method) { if (method.isConstructor()) return null; return method.getReturnType(); } return null; }
inferReturnType
34,351
GrStatement[] (final GrStatementOwner statementOwner) { List<GrStatement> result = new ArrayList<>(); for (PsiElement cur = statementOwner.getFirstChild(); cur != null; cur = cur.getNextSibling()) { if (cur instanceof GrStatement) { result.add((GrStatement)cur); } } return result.toArray(GrStatement.EMPTY_ARRAY); }
getStatements
34,352
GrNamedArgument (final GrNamedArgumentsOwner namedArgumentOwner, String label) { for (PsiElement cur = namedArgumentOwner.getFirstChild(); cur != null; cur = cur.getNextSibling()) { if (cur instanceof GrNamedArgument) { if (label.equals(((GrNamedArgument)cur).getLabelName())) { return (GrNamedArgument)cur; } } } return null; }
findNamedArgument
34,353
boolean (@Nullable PsiElement sibling) { return sibling != null && isWhiteSpaceOrNls(sibling.getNode()); }
isWhiteSpaceOrNls
34,354
boolean (@Nullable ASTNode node) { return node != null && TokenSets.WHITE_SPACES_SET.contains(node.getElementType()); }
isWhiteSpaceOrNls
34,355
void (GrModifierList modifierList) { PsiElement newLineAfterModifierList = findNewLineAfterElement(modifierList); if (newLineAfterModifierList != null) { modifierList.setModifierProperty(GrModifier.DEF, false); if (modifierList.getModifiers().length > 0) { modifierList.getNode().addLeaf(GroovyTokenTypes.mNLS, newLineAfterModifierList.getText(), null); } modifierList.getNode().addLeaf(GroovyTokenTypes.kDEF, "def", null); final PsiElement newLineUpdated = findNewLineAfterElement(modifierList); if (newLineUpdated != null) newLineUpdated.delete(); if (!isWhiteSpaceOrNls(modifierList.getNextSibling())) { modifierList.getParent().getNode().addLeaf(TokenType.WHITE_SPACE, " ", modifierList.getNextSibling().getNode()); } } else if (modifierList.getModifiers().length == 0) { modifierList.setModifierProperty(GrModifier.DEF, true); } }
insertPlaceHolderToModifierListAtEndIfNeeded
34,356
PsiElement (PsiElement element) { PsiElement sibling = element.getNextSibling(); while (sibling != null && isWhiteSpaceOrNls(sibling)) { if (PsiUtil.isNewLine(sibling)) { return sibling; } sibling = sibling.getNextSibling(); } return null; }
findNewLineAfterElement
34,357
GrAnnotation (@NotNull GrAnnotationNameValuePair pair) { PsiElement pParent = pair.getParent().getParent(); if (pParent instanceof GrAnnotation) return (GrAnnotation)pParent; PsiElement ppParent = pParent.getParent(); return ppParent instanceof GrAnnotation ? (GrAnnotation)ppParent : null; }
getAnnotation
34,358
boolean (@NotNull PsiElement element, int startOffset, int endOffset) { if (element instanceof GrLiteral && StringPartInfo.isWholeLiteralContentSelected((GrLiteral)element, startOffset, endOffset)) { return true; } if (element.getTextRange().getStartOffset() == startOffset) { return true; } return false; }
checkRanges
34,359
void (StringBuilder buffer, final PsiType type, PsiElement context) { if (type != null) { JavaDocInfoGeneratorFactory.create(context.getProject(), null).generateType(buffer, type, context); } else { buffer.append(GrModifier.DEF); } }
appendTypeString
34,360
boolean (@Nullable GrExpression lValue) { if (lValue instanceof GrReferenceExpression expression) { final PsiElement dot = expression.getDotToken(); if (dot != null && dot.getNode().getElementType() == GroovyTokenTypes.mSPREAD_DOT) { return true; } else { final GrExpression qualifier = expression.getQualifierExpression(); if (qualifier != null) return isSpreadAssignment(qualifier); } } return false; }
isSpreadAssignment
34,361
boolean (@Nullable GrExpression expr) { if (expr == null) return false; while (expr instanceof GrReferenceExpression) { final PsiElement nameElement = ((GrReferenceExpression)expr).getReferenceNameElement(); if (((GrReferenceExpression)expr).getTypeArguments().length > 0) return false; if (nameElement == null || !TokenSets.CODE_REFERENCE_ELEMENT_NAME_TOKENS.contains(nameElement.getNode().getElementType())) { return false; } IElementType dotType = ((GrReferenceExpression)expr).getDotTokenType(); if (dotType != null && dotType != GroovyTokenTypes.mDOT) return false; expr = ((GrReferenceExpression)expr).getQualifierExpression(); } return expr == null; }
seemsToBeQualifiedClassName
34,362
PsiType (@NotNull GrReferenceExpression ref) { final GrExpression rtQualifier = ref.getQualifierExpression(); if (rtQualifier != null) { return rtQualifier.getType(); } PsiClass containingClass = null; final GrMember member = PsiTreeUtil.getParentOfType(ref, GrMember.class); if (member == null) { final PsiFile file = ref.getContainingFile(); if (file instanceof GroovyFileBase && ((GroovyFileBase)file).isScript()) { containingClass = ((GroovyFileBase)file).getScriptClass(); } else { return null; } } else if (member instanceof GrMethod) { if (!member.hasModifierProperty(PsiModifier.STATIC)) { containingClass = member.getContainingClass(); } } if (containingClass != null) { final PsiClassType categoryType = GdkMethodUtil.getCategoryType(containingClass); if (categoryType != null) { return categoryType; } return JavaPsiFacade.getElementFactory(ref.getProject()).createType(containingClass); } return null; }
getQualifierType
34,363
GroovyResolveResult (GroovyResolveResult result, GrMethod baseMethod, GrReflectedMethod reflectedMethod) { PsiSubstitutor substitutor = result.getSubstitutor(); PsiTypeParameter[] reflectedParameters = reflectedMethod.getTypeParameters(); PsiTypeParameter[] baseParameters = baseMethod.getTypeParameters(); assert baseParameters.length == reflectedParameters.length; for (int i = 0; i < baseParameters.length; i++) { substitutor = substitutor.put(baseParameters[i], result.getSubstitutor().substitute(reflectedParameters[i])); } return new GroovyResolveResultImpl(baseMethod, result.getCurrentFileResolveContext(), result.getSpreadState(), substitutor, result.isAccessible(), result.isStaticsOK(), result.isInvokedOnProperty(), result.isValidResult()); }
reflectedToBase
34,364
PsiClass () { return resolveGenerics().getElement(); }
resolve
34,365
String () { final PsiClass resolved = resolve(); if (resolved != null) return resolved.getName(); return myReferenceElement.getReferenceName(); }
getClassName
34,366
int () { GrTypeArgumentList typeArgumentList = myReferenceElement.getTypeArgumentList(); return typeArgumentList == null ? 0 : typeArgumentList.getTypeArgumentCount(); }
getParameterCount
34,367
ClassResolveResult () { final GroovyResolveResult resolveResult = myReferenceElement.advancedResolve(); return new ClassResolveResult() { @Override public PsiClass getElement() { final PsiElement resolved = resolveResult.getElement(); return resolved instanceof PsiClass ? (PsiClass)resolved : null; } @Override @NotNull public PsiSubstitutor getSubstitutor() { return resolveResult.getSubstitutor(); } @Override public boolean isPackagePrefixPackageReference() { return false; } @Override public boolean isAccessible() { return resolveResult.isAccessible(); } @Override public boolean isStaticsScopeCorrect() { return resolveResult.isStaticsOK(); } @Override @Nullable public PsiElement getCurrentFileResolveScope() { return resolveResult.getCurrentFileResolveContext(); } @Override public boolean isValidResult() { return isStaticsScopeCorrect() && isAccessible(); } }; }
resolveGenerics
34,368
PsiClass () { final PsiElement resolved = resolveResult.getElement(); return resolved instanceof PsiClass ? (PsiClass)resolved : null; }
getElement
34,369
PsiSubstitutor () { return resolveResult.getSubstitutor(); }
getSubstitutor
34,370
boolean () { return false; }
isPackagePrefixPackageReference
34,371
boolean () { return resolveResult.isAccessible(); }
isAccessible
34,372
boolean () { return resolveResult.isStaticsOK(); }
isStaticsScopeCorrect
34,373
PsiElement () { return resolveResult.getCurrentFileResolveContext(); }
getCurrentFileResolveScope
34,374
boolean () { return isStaticsScopeCorrect() && isAccessible(); }
isValidResult
34,375
PsiClassType () { final PsiElementFactory factory = JavaPsiFacade.getElementFactory(myReferenceElement.getProject()); final PsiClass clazz = resolve(); if (clazz != null) { return factory.createType(clazz, factory.createRawSubstitutor(clazz), getLanguageLevel()); } else { String qName = StringUtil.notNullize(myReferenceElement.getQualifiedReferenceName()); return factory.createTypeByFQClassName(qName, myReferenceElement.getResolveScope()); } }
rawType
34,376
String () { return PsiNameHelper .getPresentableText(myReferenceElement.getReferenceName(), PsiAnnotation.EMPTY_ARRAY, myReferenceElement.getTypeArguments()); }
getPresentableText
34,377
String () { return myReferenceElement.getCanonicalText(); }
getCanonicalText
34,378
boolean () { return myReferenceElement.isValid(); }
isValid
34,379
boolean (@NotNull String text) { return text.endsWith(getPresentableText()) /*optimization*/ && text.equals(getCanonicalText()); }
equalsToText
34,380
GlobalSearchScope () { return myReferenceElement.getResolveScope(); }
getResolveScope
34,381
LanguageLevel () { return myLanguageLevel; }
getLanguageLevel
34,382
PsiClassType (@NotNull final LanguageLevel languageLevel) { return new GrClassReferenceType(myReferenceElement, languageLevel); }
setLanguageLevel
34,383
GrCodeReferenceElement () { return myReferenceElement; }
getReference
34,384
boolean (Object obj) { if (this == obj) return true; if (obj instanceof GrClassReferenceType) { if (myReferenceElement.equals(((GrClassReferenceType)obj).myReferenceElement)) { return true; } } return super.equals(obj); }
equals
34,385
int () { String name = myReferenceElement.getReferenceName(); return name == null ? 0 : name.hashCode(); }
hashCode
34,386
GroovyPsiManager (Project project) { return project.getService(GroovyPsiManager.class); }
getInstance
34,387
PsiClassType (@NotNull String fqName, @NotNull GlobalSearchScope resolveScope) { if (ourPopularClasses.contains(fqName)) { PsiClass result = JavaPsiFacade.getInstance(myProject).findClass(fqName, resolveScope); if (result != null) { return JavaPsiFacade.getElementFactory(myProject).createType(result); } } return JavaPsiFacade.getElementFactory(myProject).createTypeByFQClassName(fqName, resolveScope); }
createTypeByFQClassName
34,388
GroovyCodeStyleSettingsFacade (Project project) { return project.getService(GroovyCodeStyleSettingsFacade.class); }
getInstance
34,389
void () { myQualifiedReferenceName = DUMMY_FQN; super.subtreeChanged(); }
subtreeChanged
34,390
String () { PsiElement nameElement = getReferenceNameElement(); if (nameElement != null) { return nameElement.getText(); } return null; }
getReferenceName
34,391
String () { String qualifiedReferenceName = myQualifiedReferenceName; if (Strings.areSameInstance(qualifiedReferenceName, DUMMY_FQN)) { qualifiedReferenceName = PsiImplUtilKt.getQualifiedReferenceName(this); myQualifiedReferenceName = qualifiedReferenceName; } return qualifiedReferenceName; }
getQualifiedReferenceName
34,392
PsiElement () { return this; }
getElement
34,393
TextRange () { final PsiElement refNameElement = getReferenceNameElement(); if (refNameElement != null) { final int offsetInParent = refNameElement.getStartOffsetInParent(); return new TextRange(offsetInParent, offsetInParent + refNameElement.getTextLength()); } return new TextRange(0, getTextLength()); }
getRangeInElement
34,394
GrReferenceElement<Q> (@NotNull String qName) { GrReferenceElement<Q> qualifiedRef = createQualifiedRef(qName); final GrTypeArgumentList list = getTypeArgumentList(); if (list != null) { qualifiedRef.getNode().addChild(list.copy().getNode()); } getNode().getTreeParent().replaceChild(getNode(), qualifiedRef.getNode()); return qualifiedRef; }
bindWithQualifiedRef
34,395
boolean (PsiElement element) { return isReferenceTo(element); }
bindsCorrectly
34,396
GrTypeArgumentList () { return findChildByType(GroovyElementTypes.TYPE_ARGUMENTS); }
getTypeArgumentList
34,397
void (@Nullable Q newQualifier) { PsiImplUtil.setQualifier(this, newQualifier); }
setQualifier
34,398
boolean () { return getQualifier() != null; }
isQualified
34,399
FileType () { return GroovyFileType.GROOVY_FILE_TYPE; }
getFileType