Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
29,000 | GroovyCompilerConfiguration (Project project) { return project.getService(GroovyCompilerConfiguration.class); } | getInstance |
29,001 | boolean () { return myInvokeDynamic; } | isInvokeDynamic |
29,002 | void (boolean invokeDynamic) { myInvokeDynamic = invokeDynamic; } | setInvokeDynamic |
29,003 | String () { return myConfigScript; } | getConfigScript |
29,004 | void (String configScript) { myConfigScript = configScript; } | setConfigScript |
29,005 | void () { Disposer.dispose(myExcludeFromStubGeneration); } | dispose |
29,006 | void (@NotNull final AnActionEvent e) { final PsiFile file = e.getData(CommonDataKeys.PSI_FILE); assert file != null && file.getLanguage() == GroovyLanguage.INSTANCE; doExcludeFromStubGeneration(file); } | actionPerformed |
29,007 | void (PsiFile file) { final VirtualFile virtualFile = file.getVirtualFile(); assert virtualFile != null; final Project project = file.getProject(); final GroovyCompilerConfigurable configurable = new GroovyCompilerConfigurable(project); ShowSettingsUtil.getInstance().editConfigurable(project, configurable, () -> configurable.getExcludes().addEntry(new ExcludeEntryDescription(virtualFile, false, true, project))); } | doExcludeFromStubGeneration |
29,008 | ActionUpdateThread () { return ActionUpdateThread.BGT; } | getActionUpdateThread |
29,009 | void (@NotNull AnActionEvent e) { Presentation presentation = e.getPresentation(); boolean enabled = isEnabled(e); presentation.setEnabledAndVisible(enabled); } | update |
29,010 | boolean (AnActionEvent e) { PsiFile file = e.getData(CommonDataKeys.PSI_FILE); if (file == null || file.getLanguage() != GroovyLanguage.INSTANCE) { return false; } final VirtualFile virtualFile = file.getVirtualFile(); return virtualFile != null && !GroovyCompilerConfiguration.getExcludeConfiguration(file.getProject()).isExcluded(virtualFile); } | isEnabled |
29,011 | Set<FileType> () { return Collections.singleton(GroovyFileType.GROOVY_FILE_TYPE); } | getCompilableFileTypes |
29,012 | void (@NotNull AnActionEvent e) { checkResources(e.getProject(), null, this instanceof Rebuild); } | actionPerformed |
29,013 | ActionUpdateThread () { return ActionUpdateThread.BGT; } | getActionUpdateThread |
29,014 | void (Project project, @Nullable CompileStatusNotification callback, boolean rebuild) { ProjectCompileScope scope = new ProjectCompileScope(project); scope.putUserData(GroovyResourceChecker.CHECKING_RESOURCES_REBUILD, rebuild); CompilerManager.getInstance(project).make(scope, callback); } | checkResources |
29,015 | List<String> () { CompilerConfiguration config = myProject.isDefault() ? null : CompilerConfiguration.getInstance(myProject); if (config instanceof CompilerConfigurationImpl) { BackendCompiler backend = ((CompilerConfigurationImpl)config).getDefaultCompiler(); if (backend != null && backend.getId().equals(GreclipseBuilder.ID)) { File file = EclipseCompilerTool.findEcjJarFile(); if (file != null) { return Collections.singletonList(file.getAbsolutePath()); } } } return Collections.emptyList(); } | getClassPath |
29,016 | Iterable<String> () { final Path jarPath = PathManager.getJarForClass(GroovyBuilder.class); if (jarPath != null) { final Supplier<List<String>> roots = lazy(() -> GroovyRtJarPaths.getGroovyRtRoots(jarPath.toFile(), false)); return () -> roots.get().iterator(); } return Collections.emptyList(); } | getAdditionalPluginPaths |
29,017 | T () { T val = cached; if (val == null) { cached = val = calculation.get(); } return val; } | get |
29,018 | String () { return GreclipseBuilder.ID; } | getId |
29,019 | String () { return GreclipseBuilder.ID; } | getPresentableName |
29,020 | Configurable () { return new GreclipseConfigurable(GreclipseIdeaCompilerSettings.getSettings(myProject)); } | createConfigurable |
29,021 | Set<FileType> () { return Set.of(JavaFileType.INSTANCE, GroovyFileType.GROOVY_FILE_TYPE); } | getCompilableFileTypes |
29,022 | CompilerOptions () { return GreclipseIdeaCompilerSettings.getSettings(myProject); } | getOptions |
29,023 | PsiClass (Project project, VirtualFile stubFile) { final String[] components = StringUtil.trimEnd(stubFile.getPath(), ".java").split("[\\\\/]"); final int stubs = Arrays.asList(components).indexOf(GROOVY_STUBS); if (stubs < 0 || stubs >= components.length - 3) { return null; } final String moduleName = components[stubs + 1]; final Module module = ModuleManager.getInstance(project).findModuleByName(moduleName); if (module == null) { return null; } final String fqn = StringUtil.join(Arrays.asList(components).subList(stubs + 3, components.length), "."); return JavaPsiFacade.getInstance(project).findClass(fqn, GlobalSearchScope.moduleScope(module)); } | findClassByStub |
29,024 | EditorNotificationPanel (final VirtualFile file, final Project project, @NotNull FileEditor fileEditor) { final EditorNotificationPanel panel = new EditorNotificationPanel(fileEditor, EditorNotificationPanel.Status.Info); panel.setText(GroovyBundle.message("generated.stub.message")); panel.createActionLabel(GroovyBundle.message("generated.stub.navigate.link.label"), () -> DumbService.getInstance(project).withAlternativeResolveEnabled(() -> { final PsiClass original = findClassByStub(project, file); if (original != null) { original.navigate(true); } })); panel.createActionLabel(GroovyBundle.message("generated.stub.exclude.link.label"), () -> DumbService.getInstance(project).withAlternativeResolveEnabled(() -> { final PsiClass psiClass = findClassByStub(project, file); if (psiClass != null) { ExcludeFromStubGenerationAction.doExcludeFromStubGeneration(psiClass.getContainingFile()); } })); return panel; } | decorateStubFile |
29,025 | GreclipseSettings () { return mySettings; } | getState |
29,026 | void (@NotNull GreclipseSettings state) { XmlSerializerUtil.copyBean(state, mySettings); } | loadState |
29,027 | GreclipseSettings (@NotNull Project project) { return project.getService(GreclipseIdeaCompilerSettings.class).mySettings; } | getSettings |
29,028 | void (@NotNull Project project, @NotNull String path) { project.getService(GreclipseIdeaCompilerSettings.class).mySettings.greclipsePath = FileUtil.toSystemIndependentName(path); } | setGrEclipsePath |
29,029 | void (@NotNull Project project, @NotNull String cmdLineParams) { project.getService(GreclipseIdeaCompilerSettings.class).mySettings.cmdLineParams = cmdLineParams; } | setGrCmdParams |
29,030 | Collection<String> (@NotNull PsiQualifiedReferenceElement ref) { GrImportStatement importStatement = PsiTreeUtil.getParentOfType(ref.getElement(), GrImportStatement.class); //from static imports if (importStatement != null) { String fqn = importStatement.getImportFqn(); return fqn == null ? Collections.emptyList() : Collections.singleton(fqn); } if (ref.getQualifier() != null) return Collections.emptyList(); final String className = ref.getReferenceName(); if (className == null) return Collections.emptyList(); PsiFile file = ref.getContainingFile().getOriginalFile(); if (!(file instanceof GroovyFile)) return Collections.emptyList(); GrImportStatement[] importList = ((GroovyFile)file).getImportStatements(); for (GrImportStatement imp : importList) { if (className.equals(imp.getImportedName())) { String fqn = imp.getImportFqn(); return fqn == null ? Collections.emptyList() : Collections.singleton(fqn); } } return Collections.emptyList(); } | getFqns |
29,031 | void (@NotNull GrReferenceElement<?> ref, @NotNull QuickFixActionRegistrar registrar) { registrar.register(new GroovyFindJarFix(ref)); } | registerFixes |
29,032 | PsiElementPredicate () { return new EndOfLineCommentPredicate(); } | getElementPredicate |
29,033 | void (@NotNull PsiElement element, @NotNull ActionContext context, @NotNull ModPsiUpdater updater) { final PsiComment selectedComment = (PsiComment) element; PsiComment firstComment = selectedComment; while (true) { final PsiElement prevComment = getPrevNonWhiteSpace(firstComment); if (!isEndOfLineComment(prevComment)) { break; } firstComment = (PsiComment) prevComment; } final JavaPsiFacade manager = JavaPsiFacade.getInstance(selectedComment.getProject()); final PsiElementFactory factory = manager.getElementFactory(); String text = getCommentContents(firstComment); final List<PsiElement> commentsToDelete = new ArrayList<>(); PsiElement nextComment = firstComment; while (true) { nextComment = getNextNonWhiteSpace(nextComment); if (!isEndOfLineComment(nextComment)) { break; } text += nextComment.getPrevSibling().getText() + " " //to get the whitespace for proper spacing + getCommentContents((PsiComment) nextComment); commentsToDelete.add(nextComment); } final PsiComment newComment = factory.createCommentFromText("/*" + text + " */", selectedComment.getParent()); firstComment.replace(newComment); for (PsiElement commentToDelete : commentsToDelete) { commentToDelete.delete(); } } | processIntention |
29,034 | PsiElement (PsiElement nextComment) { PsiElement elementToCheck = nextComment; while (true) { final PsiElement sibling = elementToCheck.getNextSibling(); if (sibling == null) { return null; } if (sibling.getText().trim().replace("\n", "").isEmpty()) { elementToCheck = sibling; } else { return sibling; } } } | getNextNonWhiteSpace |
29,035 | PsiElement (PsiElement nextComment) { PsiElement elementToCheck = nextComment; while (true) { final PsiElement sibling = elementToCheck.getPrevSibling(); if (sibling == null) { return null; } if (sibling.getText().trim().replace("\n", "").isEmpty()) { elementToCheck = sibling; } else { return sibling; } } } | getPrevNonWhiteSpace |
29,036 | boolean (PsiElement element) { if (!(element instanceof PsiComment comment)) { return false; } final IElementType tokenType = comment.getTokenType(); return GroovyTokenTypes.mSL_COMMENT.equals(tokenType); } | isEndOfLineComment |
29,037 | String (PsiComment comment) { final String text = comment.getText(); return text.substring(2); } | getCommentContents |
29,038 | boolean (@NotNull PsiElement element) { if (!(element instanceof PsiComment comment)) { return false; } if (element instanceof PsiDocComment) { return false; } final IElementType type = comment.getTokenType(); return GroovyTokenTypes.mSL_COMMENT.equals(type); } | satisfiedBy |
29,039 | PsiElementPredicate () { return new ExplicitClosureCallPredicate(); } | getElementPredicate |
29,040 | void (@NotNull PsiElement element, @NotNull ActionContext context, @NotNull ModPsiUpdater updater) { final GrMethodCallExpression expression = (GrMethodCallExpression)element; final GrReferenceExpression invokedExpression = (GrReferenceExpression)expression.getInvokedExpression(); final GrExpression qualifier = invokedExpression.getQualifierExpression(); final GrArgumentList argList = expression.getArgumentList(); final GrClosableBlock[] closureArgs = expression.getClosureArguments(); final StringBuilder newExpression = new StringBuilder(); newExpression.append(qualifier.getText()); newExpression.append(argList.getText()); for (GrClosableBlock closureArg : closureArgs) { newExpression.append(closureArg.getText()); } PsiImplUtil.replaceExpression(newExpression.toString(), expression); } | processIntention |
29,041 | boolean (@NotNull PsiElement element) { if (!(element instanceof GrForStatement statement)) { return false; } final GrForClause clause = statement.getClause(); if (!(clause instanceof GrForInClause) || ((GrForInClause) clause).getIteratedExpression() == null) { return false; } return !ErrorUtil.containsError(element); } | satisfiedBy |
29,042 | boolean (@NotNull PsiElement element) { if (!(element instanceof final GrMethodCallExpression call)) { return false; } final GrExpression invokedExpression = call.getInvokedExpression(); if (!(invokedExpression instanceof final GrReferenceExpression referenceExpression)) { return false; } final String name = referenceExpression.getReferenceName(); if (!"call".equals(name)) { return false; } final GrExpression qualifier = referenceExpression.getQualifierExpression(); if (qualifier == null) { return false; } final PsiType qualifierType = qualifier.getType(); if (qualifierType == null) { return false; } if (!qualifierType.equalsToText(GroovyCommonClassNames.GROOVY_LANG_CLOSURE)) { return false; } return !ErrorUtil.containsError(element); } | satisfiedBy |
29,043 | PsiElementPredicate () { return new ForToEachPredicate(); } | getElementPredicate |
29,044 | void (@NotNull PsiElement element, @NotNull ActionContext context, @NotNull ModPsiUpdater updater) { final GrForStatement parentStatement = (GrForStatement) element; final GrForInClause clause = (GrForInClause) parentStatement.getClause(); final GrVariable var = clause.getDeclaredVariable(); final GrStatement body = parentStatement.getBody(); final String bodyText; if (body instanceof GrBlockStatement) { final String text = body.getText(); bodyText = text.substring(1, text.length() - 1); } else { bodyText = body.getText(); } GrExpression collection = clause.getIteratedExpression(); assert collection != null; @NonNls final String statement = "x.each{" + var.getText() + " -> " + bodyText + " }"; final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(parentStatement.getProject()); final GrMethodCallExpression eachExpression = (GrMethodCallExpression) factory.createTopElementFromText(statement); ((GrReferenceExpression) eachExpression.getInvokedExpression()).getQualifierExpression().replaceWithExpression(collection, true); parentStatement.replaceWithStatement(eachExpression); } | processIntention |
29,045 | PsiElementPredicate () { return ImplicitClosureCallPredicate.INSTANCE; } | getElementPredicate |
29,046 | void (@NotNull PsiElement element, @NotNull ActionContext context, @NotNull ModPsiUpdater updater) { final GrMethodCallExpression expression = (GrMethodCallExpression)element; final GrExpression invokedExpression = expression.getInvokedExpression(); final GrArgumentList argList = expression.getArgumentList(); final GrClosableBlock[] closureArgs = expression.getClosureArguments(); final StringBuilder newExpression = new StringBuilder(); newExpression.append(invokedExpression.getText()); newExpression.append(".call"); newExpression.append(argList.getText()); for (GrClosableBlock closureArg : closureArgs) { newExpression.append(closureArg.getText()); } PsiImplUtil.replaceExpression(newExpression.toString(), expression); } | processIntention |
29,047 | PsiElementPredicate () { return new EachToForPredicate(); } | getElementPredicate |
29,048 | void (@NotNull PsiElement element, @NotNull ActionContext context, @NotNull ModPsiUpdater updater) { final GrMethodCallExpression expression = (GrMethodCallExpression)element; final GrClosableBlock block = expression.getClosureArguments()[0]; final GrParameterList parameterList = block.getParameterList(); final GrParameter[] parameters = parameterList.getParameters(); String var; if (parameters.length == 1) { var = parameters[0].getText(); var = StringUtil.replace(var, GrModifier.DEF, ""); } else { var = "it"; } final GrExpression invokedExpression = expression.getInvokedExpression(); GrExpression qualifier = ((GrReferenceExpression)invokedExpression).getQualifierExpression(); final GroovyPsiElementFactory elementFactory = GroovyPsiElementFactory.getInstance(element.getProject()); if (qualifier == null) { qualifier = elementFactory.createExpressionFromText("this"); } StringBuilder builder = new StringBuilder(); builder.append("for (").append(var).append(" in ").append(qualifier.getText()).append(") {\n"); String text = block.getText(); final PsiElement blockArrow = block.getArrow(); int index; if (blockArrow != null) { index = blockArrow.getStartOffsetInParent() + blockArrow.getTextLength(); } else { index = 1; } while (index < text.length() && Character.isWhitespace(text.charAt(index))) index++; text = text.substring(index, text.length() - 1); builder.append(text); builder.append("}"); final GrStatement statement = elementFactory.createStatementFromText(builder.toString()); GrForStatement forStatement = (GrForStatement)expression.replaceWithStatement(statement); final GrForClause clause = forStatement.getClause(); if (!(clause instanceof GrForInClause)) return; final GrVariable variable = ((GrForInClause)clause).getDeclaredVariable(); if (variable != null) { updater.rename(variable, List.of(variable.getName())); } updateReturnStatements(forStatement); } | processIntention |
29,049 | void (GrForStatement forStatement) { GrStatement body = forStatement.getBody(); assert body != null; final Set<String> usedLabels = new HashSet<>(); final Ref<Boolean> needLabel = Ref.create(false); body.accept(new GroovyRecursiveElementVisitor() { private int myLoops = 0; @Override public void visitReturnStatement(@NotNull GrReturnStatement returnStatement) { if (returnStatement.getReturnValue() != null) return; if (myLoops > 0) needLabel.set(true); } @Override public void visitLabeledStatement(@NotNull GrLabeledStatement labeledStatement) { super.visitLabeledStatement(labeledStatement); usedLabels.add(labeledStatement.getName()); } @Override public void visitForStatement(@NotNull GrForStatement forStatement) { myLoops++; super.visitForStatement(forStatement); myLoops--; } @Override public void visitWhileStatement(@NotNull GrWhileStatement whileStatement) { myLoops++; super.visitWhileStatement(whileStatement); myLoops--; } @Override public void visitClosure(@NotNull GrClosableBlock closure) { //don't go into closures } @Override public void visitAnonymousClassDefinition(@NotNull GrAnonymousClassDefinition anonymousClassDefinition) { //don't go into anonymous } }); GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(forStatement.getProject()); final String continueText; if (needLabel.get()) { int i = 0; String label = OUTER; while (usedLabels.contains(label)) { label = OUTER + i; i++; } continueText = "continue "+ label; GrLabeledStatement labeled = (GrLabeledStatement)factory.createStatementFromText(label + ": while (true){}"); labeled.getStatement().replaceWithStatement(forStatement); labeled = forStatement.replaceWithStatement(labeled); forStatement = (GrForStatement)labeled.getStatement(); body = forStatement.getBody(); assert body != null; } else { continueText = "continue"; } final GrStatement continueStatement = factory.createStatementFromText(continueText); body.accept(new GroovyRecursiveElementVisitor() { @Override public void visitReturnStatement(@NotNull GrReturnStatement returnStatement) { if (returnStatement.getReturnValue() == null) { returnStatement.replaceWithStatement(continueStatement); } } @Override public void visitClosure(@NotNull GrClosableBlock closure) { //don't go into closures } @Override public void visitAnonymousClassDefinition(@NotNull GrAnonymousClassDefinition anonymousClassDefinition) { //don't go into anonymous } }); } | updateReturnStatements |
29,050 | void (@NotNull GrReturnStatement returnStatement) { if (returnStatement.getReturnValue() != null) return; if (myLoops > 0) needLabel.set(true); } | visitReturnStatement |
29,051 | void (@NotNull GrLabeledStatement labeledStatement) { super.visitLabeledStatement(labeledStatement); usedLabels.add(labeledStatement.getName()); } | visitLabeledStatement |
29,052 | void (@NotNull GrForStatement forStatement) { myLoops++; super.visitForStatement(forStatement); myLoops--; } | visitForStatement |
29,053 | void (@NotNull GrWhileStatement whileStatement) { myLoops++; super.visitWhileStatement(whileStatement); myLoops--; } | visitWhileStatement |
29,054 | void (@NotNull GrClosableBlock closure) { //don't go into closures } | visitClosure |
29,055 | void (@NotNull GrAnonymousClassDefinition anonymousClassDefinition) { //don't go into anonymous } | visitAnonymousClassDefinition |
29,056 | void (@NotNull GrReturnStatement returnStatement) { if (returnStatement.getReturnValue() == null) { returnStatement.replaceWithStatement(continueStatement); } } | visitReturnStatement |
29,057 | void (@NotNull GrClosableBlock closure) { //don't go into closures } | visitClosure |
29,058 | void (@NotNull GrAnonymousClassDefinition anonymousClassDefinition) { //don't go into anonymous } | visitAnonymousClassDefinition |
29,059 | boolean (@NotNull PsiElement element) { if (element instanceof GrMethodCallExpression expression) { // final PsiElement parent = expression.getParent(); // if (parent instanceof GrAssignmentExpression) return false; // if (parent instanceof GrArgumentList) return false; // if (parent instanceof GrReturnStatement) return false; // if (!(parent instanceof GrCodeBlock || parent instanceof GrIfStatement|| parent instanceof GrCaseSection)) return false; final GrExpression invokedExpression = expression.getInvokedExpression(); if (invokedExpression instanceof GrReferenceExpression referenceExpression) { if ("each".equals(referenceExpression.getReferenceName())) { final GrArgumentList argumentList = expression.getArgumentList(); if (PsiImplUtil.hasExpressionArguments(argumentList)) return false; if (PsiImplUtil.hasNamedArguments(argumentList)) return false; final GrClosableBlock[] closureArguments = expression.getClosureArguments(); if (closureArguments.length != 1) return false; final GrParameter[] parameters = closureArguments[0].getParameterList().getParameters(); if (parameters.length > 1) return false; return true; } } } return false; } | satisfiedBy |
29,060 | PsiElementPredicate () { return new MyPredicate(); } | getElementPredicate |
29,061 | void (@NotNull PsiElement psiElement, @NotNull ActionContext context, @NotNull ModPsiUpdater updater) { GrCodeReferenceElement ref = (GrCodeReferenceElement)psiElement; final GrAnonymousClassDefinition anonymous = (GrAnonymousClassDefinition)ref.getParent(); final GrNewExpression newExpr = (GrNewExpression)anonymous.getParent(); final PsiElement resolved = ref.resolve(); assert resolved instanceof PsiClass;// && ((PsiClass)resolved).isInterface(); GrTypeDefinitionBody body = anonymous.getBody(); assert body != null; List<Pair<PsiMethod, GrOpenBlock>> methods = new ArrayList<>(); for (GrMethod method : body.getMethods()) { methods.add(new Pair<>(method, method.getBlock())); } final PsiClass iface = (PsiClass)resolved; final Collection<CandidateInfo> collection = OverrideImplementExploreUtil.getMethodsToOverrideImplement(anonymous, true); for (CandidateInfo info : collection) { methods.add(new Pair<>((PsiMethod)info.getElement(), null)); } StringBuilder buffer = new StringBuilder(); if (methods.size() == 1) { final Pair<PsiMethod, GrOpenBlock> pair = methods.get(0); appendClosureTextByMethod(pair.getFirst(), buffer, pair.getSecond(), newExpr); if (!GroovyConfigUtils.getInstance().isVersionAtLeast(psiElement, GroovyConfigUtils.GROOVY2_2)) { buffer.append(" as ").append(iface.getQualifiedName()); } } else { buffer.append("["); buffer.append("\n"); for (Pair<PsiMethod, GrOpenBlock> pair : methods) { final PsiMethod method = pair.getFirst(); final GrOpenBlock block = pair.getSecond(); buffer.append(method.getName()).append(": "); appendClosureTextByMethod(method, buffer, block, newExpr); buffer.append(",\n"); } if (!methods.isEmpty()) { buffer.delete(buffer.length() - 2, buffer.length()); buffer.append('\n'); } buffer.append("]"); buffer.append(" as ").append(iface.getQualifiedName()); } createAndAdjustNewExpression(context.project(), newExpr, buffer); } | processIntention |
29,062 | void (final PsiMethod method, final StringBuilder buffer, @Nullable GrOpenBlock block, GroovyPsiElement context) { final PsiParameterList list = method.getParameterList(); buffer.append("{ "); final PsiParameter[] parameters = list.getParameters(); Set<String> generatedNames = new HashSet<>(); if (parameters.length > 0) { final PsiParameter first = parameters[0]; final PsiType type = first.getType(); buffer.append(type.getCanonicalText()).append(" "); buffer.append(createName(generatedNames, first, type, context)); } for (int i = 1; i < parameters.length; i++) { buffer.append(", "); final PsiParameter param = parameters[i]; final PsiType type = param.getType(); buffer.append(type.getCanonicalText()).append(" "); String name = createName(generatedNames, param, type, context); buffer.append(name); } if (parameters.length > 0) { buffer.append(" ->"); } if (block != null) { final PsiElement lBrace = block.getLBrace(); final PsiElement rBrace = block.getRBrace(); for (PsiElement child = lBrace != null ? lBrace.getNextSibling() : block.getFirstChild(); child != null && child != rBrace; child = child.getNextSibling()) { buffer.append(child.getText()); } } buffer.append(" }"); } | appendClosureTextByMethod |
29,063 | String (final Set<String> generatedNames, final PsiParameter param, final PsiType type, GroovyPsiElement context) { String name = param.getName(); generatedNames.add(name); return name; } | createName |
29,064 | boolean (@NotNull PsiElement element) { if (element instanceof GrCodeReferenceElement && element.getParent() instanceof GrAnonymousClassDefinition anonymous) { if (anonymous.getFields().length == 0) { return true; } } return false; } | satisfiedBy |
29,065 | void (@NotNull PsiElement element, @NotNull ActionContext context, @NotNull ModPsiUpdater updater) { if (element instanceof GrReturnStatement returnStatement && returnStatement.getReturnValue() != null) { GrExpression value = returnStatement.getReturnValue(); returnStatement.replaceWithStatement(value); } } | processIntention |
29,066 | PsiElementPredicate () { return element -> element instanceof GrReturnStatement returnStatement && returnStatement.getReturnValue() != null && ControlFlowBuilderUtil.isCertainlyReturnStatement(returnStatement); } | getElementPredicate |
29,067 | boolean (@NotNull PsiElement element) { if (element.getLanguage() != GroovyLanguage.INSTANCE) return false; if (!CodeStyleSettingsManager.getInstance(element.getProject()).getCurrentSettings() .getCustomSettings(GroovyCodeStyleSettings.class).USE_FLYING_GEESE_BRACES) { return false; } if (PsiImplUtil.isWhiteSpaceOrNls(element)) { element = PsiTreeUtil.prevLeaf(element); } if (!GeeseUtil.isClosureRBrace(element)) return false; String text = element.getContainingFile().getText(); PsiElement first = element; PsiElement last = element; for (PsiElement cur = getNext(element); GeeseUtil.isClosureRBrace(cur); cur = getNext(cur)) { if (!StringUtil.contains(text, last.getTextRange().getEndOffset(), cur.getTextRange().getStartOffset(), '\n')) return true; last = cur; } for (PsiElement cur = getPrev(element); GeeseUtil.isClosureRBrace(cur); cur = getPrev(cur)) { if (!StringUtil.contains(text, cur.getTextRange().getEndOffset(), first.getTextRange().getStartOffset(), '\n')) return true; first = cur; } return false; } | satisfiedBy |
29,068 | PsiElement (PsiElement element) { PsiElement prev = PsiUtil.getPreviousNonWhitespaceToken(element); if (prev != null && prev.getNode().getElementType() == GroovyTokenTypes.mNLS) { prev = PsiUtil.getPreviousNonWhitespaceToken(prev); } return prev; } | getPrev |
29,069 | PsiElement (PsiElement element) { PsiElement next = GeeseUtil.getNextNonWhitespaceToken(element); if (next != null && next.getNode().getElementType() == GroovyTokenTypes.mNLS) next = GeeseUtil.getNextNonWhitespaceToken(next); return next; } | getNext |
29,070 | void (@NotNull PsiElement element, @NotNull ActionContext context, @NotNull ModPsiUpdater updater) { if (PsiImplUtil.isWhiteSpaceOrNls(element)) { element = PsiTreeUtil.prevLeaf(element); } LOG.assertTrue(GeeseUtil.isClosureRBrace(element)); PsiFile file = element.getContainingFile(); Document document = file.getViewProvider().getDocument(); PsiElement first = null; PsiElement last = null; for (PsiElement cur = element; GeeseUtil.isClosureRBrace(cur); cur = getNext(cur)) { last = cur; } for (PsiElement cur = element; GeeseUtil.isClosureRBrace(cur); cur = getPrev(cur)) { first = cur; } LOG.assertTrue(first != null); LOG.assertTrue(last != null); RangeMarker rangeMarker = document.createRangeMarker(first.getTextRange().getStartOffset(), last.getTextRange().getEndOffset()); String text = document.getText(); for (PsiElement cur = getPrev(last); GeeseUtil.isClosureRBrace(cur); cur = getPrev(cur)) { int offset = last.getTextRange().getStartOffset(); if (!StringUtil.contains(text, cur.getTextRange().getEndOffset(), offset, '\n')) { document.insertString(offset, "\n"); } last = cur; } CodeStyleManager.getInstance(context.project()).reformatText(file, rangeMarker.getStartOffset(), rangeMarker.getEndOffset()); } | processIntention |
29,071 | PsiElementPredicate () { return MY_PREDICATE; } | getElementPredicate |
29,072 | void (@NotNull PsiElement element, @NotNull ActionContext context, @NotNull ModPsiUpdater updater) { if (!(element instanceof GrReferenceElement<?> ref)) return; final PsiElement resolved = ref.resolve(); if (!(resolved instanceof PsiClass psiClass)) return; final String qname = psiClass.getQualifiedName(); final GrImportStatement importStatement = GroovyPsiElementFactory.getInstance(context.project()).createImportStatementFromText(qname, true, true, null); final PsiFile containingFile = element.getContainingFile(); if (!(containingFile instanceof GroovyFile)) return; ((GroovyFile)containingFile).addImport(importStatement); for (PsiReference reference : ReferencesSearch.search(resolved, new LocalSearchScope(containingFile))) { final PsiElement refElement = reference.getElement(); final PsiElement parent = refElement.getParent(); if (parent instanceof GrQualifiedReference<?>) { GrReferenceAdjuster.shortenReference((GrQualifiedReference<?>)parent); } } } | processIntention |
29,073 | PsiElementPredicate () { return new PsiElementPredicate() { @Override public boolean satisfiedBy(@NotNull PsiElement element) { if (!(element instanceof GrReferenceElement<?> ref)) return false; final PsiElement parent = ref.getParent(); if (!(parent instanceof GrReferenceElement)) return false; final PsiElement resolved = ref.resolve(); if (resolved == null) return false; return resolved instanceof PsiClass; } }; } | getElementPredicate |
29,074 | boolean (@NotNull PsiElement element) { if (!(element instanceof GrReferenceElement<?> ref)) return false; final PsiElement parent = ref.getParent(); if (!(parent instanceof GrReferenceElement)) return false; final PsiElement resolved = ref.resolve(); if (resolved == null) return false; return resolved instanceof PsiClass; } | satisfiedBy |
29,075 | void (@NotNull PsiElement element, @NotNull ActionContext context, @NotNull ModPsiUpdater updater) { if (element instanceof GrReferenceExpression ref) { ref.replaceWithExpression(ref.getQualifier(), true); } } | processIntention |
29,076 | PsiElementPredicate () { return element -> element instanceof GrReferenceExpression ref && "class".equals(ref.getReferenceName()) && ref.getQualifier() instanceof GrReferenceExpression qualifier && qualifier.resolve() instanceof PsiClass; } | getElementPredicate |
29,077 | boolean (@NotNull PsiElement element) { if (element.getLanguage() != GroovyLanguage.INSTANCE) return false; if (!CodeStyleSettingsManager.getInstance(element.getProject()).getCurrentSettings() .getCustomSettings(GroovyCodeStyleSettings.class).USE_FLYING_GEESE_BRACES) { return false; } if (PsiImplUtil.isWhiteSpaceOrNls(element)) { element = PsiTreeUtil.prevLeaf(element); } if (!GeeseUtil.isClosureRBrace(element) || !GeeseUtil.isClosureContainLF(element)) return false; TextRange range = findRange(element); return StringUtil.contains(element.getContainingFile().getText(), range.getStartOffset(), range.getEndOffset(), '\n'); } | satisfiedBy |
29,078 | PsiElement (PsiElement element) { PsiElement prev = PsiUtil.getPreviousNonWhitespaceToken(element); if (prev != null && prev.getNode().getElementType() == GroovyTokenTypes.mNLS) { prev = PsiUtil.getPreviousNonWhitespaceToken(prev); } return prev; } | getPrev |
29,079 | PsiElement (PsiElement element) { PsiElement next = GeeseUtil.getNextNonWhitespaceToken(element); if (next != null && next.getNode().getElementType() == GroovyTokenTypes.mNLS) next = GeeseUtil.getNextNonWhitespaceToken(next); return next; } | getNext |
29,080 | void (@NotNull PsiElement element, @NotNull ActionContext context, @NotNull ModPsiUpdater updater) { if (PsiImplUtil.isWhiteSpaceOrNls(element)) { element = PsiTreeUtil.prevLeaf(element); } LOG.assertTrue(GeeseUtil.isClosureRBrace(element) && GeeseUtil.isClosureContainLF(element)); PsiFile file = element.getContainingFile(); Document document = file.getViewProvider().getDocument(); TextRange textRange = findRange(element); int startOffset = textRange.getStartOffset(); int endOffset = textRange.getEndOffset(); RangeMarker rangeMarker = document.createRangeMarker(textRange); String text = document.getText(); for (int i = endOffset - 1; i >= startOffset; i--) { if (text.charAt(i) == '\n') document.deleteString(i, i + 1); } CodeStyleManager.getInstance(context.project()).reformatText(file, rangeMarker.getStartOffset(), rangeMarker.getEndOffset()); } | processIntention |
29,081 | TextRange (PsiElement element) { PsiElement first = null; PsiElement last = null; for (PsiElement cur = element; GeeseUtil.isClosureRBrace(cur) && GeeseUtil.isClosureContainLF(cur); cur = getNext(cur)) { last = cur; } for (PsiElement cur = element; GeeseUtil.isClosureRBrace(cur) && GeeseUtil.isClosureContainLF(cur); cur = getPrev(cur)) { first = cur; } LOG.assertTrue(first != null); LOG.assertTrue(last != null); return new TextRange(first.getTextRange().getStartOffset(), last.getTextRange().getEndOffset()); } | findRange |
29,082 | PsiElementPredicate () { return MY_PREDICATE; } | getElementPredicate |
29,083 | void (@NotNull GrReferenceExpression expression) { super.visitReferenceExpression(expression); if (name.equals(expression.getReferenceName())) { PsiElement resolved = expression.resolve(); if (resolved != null) { expression.putUserData(TEMP_REFERENT_USER_DATA, resolved); } } } | visitReferenceExpression |
29,084 | void (@NotNull GrReferenceExpression expression) { super.visitReferenceExpression(expression); GrTypeArgumentList typeArgumentList = expression.getTypeArgumentList(); if (typeArgumentList != null && typeArgumentList.getFirstChild() != null) { expression.putUserData(TEMP_REFERENT_USER_DATA, null); return; } if (name.equals(expression.getReferenceName())) { if (expression.isQualified()) { GrExpression qualifier = expression.getQualifierExpression(); if (qualifier instanceof GrReferenceExpression) { PsiElement aClass = ((GrReferenceExpression)qualifier).resolve(); if (aClass == ((PsiMember)resolved).getContainingClass()) { GrReferenceAdjuster.shortenReference(expression); } } } else { PsiElement referent = expression.getUserData(TEMP_REFERENT_USER_DATA); if (referent instanceof PsiMember && ((PsiMember)referent).hasModifierProperty(PsiModifier.STATIC) && referent != expression.resolve()) { expression.bindToElement(referent); } } } expression.putUserData(TEMP_REFERENT_USER_DATA, null); } | visitReferenceExpression |
29,085 | boolean (PsiElement resolved, PsiFile containingFile) { boolean isAnythingShortened = false; for (PsiReference reference : ReferencesSearch.search(resolved, new LocalSearchScope(containingFile))) { final PsiElement refElement = reference.getElement(); if (refElement instanceof GrQualifiedReference<?>) { boolean shortened = GrReferenceAdjuster.shortenReference((GrQualifiedReference<?>)refElement); isAnythingShortened |= shortened; } } return isAnythingShortened; } | shortenUsages |
29,086 | boolean (PsiElement element) { return super.isStopElement(element) || element instanceof GrReferenceExpression; } | isStopElement |
29,087 | PsiElementPredicate () { return new PsiElementPredicate() { @Override public boolean satisfiedBy(@NotNull PsiElement element) { final PsiElement resolved = resolve(element); if (resolved == null) return false; return resolved instanceof PsiMember && !(resolved instanceof PsiClass) && ((PsiMember)resolved).hasModifierProperty(PsiModifier.STATIC) && ((PsiMember)resolved).getContainingClass() != null; } }; } | getElementPredicate |
29,088 | boolean (@NotNull PsiElement element) { final PsiElement resolved = resolve(element); if (resolved == null) return false; return resolved instanceof PsiMember && !(resolved instanceof PsiClass) && ((PsiMember)resolved).hasModifierProperty(PsiModifier.STATIC) && ((PsiMember)resolved).getContainingClass() != null; } | satisfiedBy |
29,089 | PsiElement (PsiElement element) { GrReferenceExpression ref = findRef(element); if (ref == null || ref.getQualifier() == null) return null; return ref.resolve(); } | resolve |
29,090 | GrReferenceExpression (PsiElement element) { if ((element instanceof GrReferenceExpression)) { return (GrReferenceExpression)element; } else if (element instanceof GrArgumentList) { PsiElement parent = element.getParent(); if (parent instanceof GrMethodCall) { GrExpression invoked = ((GrMethodCall)parent).getInvokedExpression(); if (invoked instanceof GrReferenceExpression) { return ((GrReferenceExpression)invoked); } } } return null; } | findRef |
29,091 | String () { return GroovyBundle.message("add.return.type.to.method.declaration"); } | getFamilyName |
29,092 | GrMethod (@NotNull PsiElement at, int offset) { if (at.getParent() instanceof GrReturnStatement returnStatement) { final PsiElement word = returnStatement.getReturnWord(); if (!word.getTextRange().contains(offset)) return null; final GroovyPsiElement returnOwner = PsiTreeUtil.getParentOfType(returnStatement, GrClosableBlock.class, GrMethod.class); if (returnOwner instanceof GrMethod) { final GrTypeElement returnTypeElement = ((GrMethod)returnOwner).getReturnTypeElementGroovy(); if (returnTypeElement == null) { return (GrMethod)returnOwner; } } return null; } final GrMethod method = PsiTreeUtil.getParentOfType(at, GrMethod.class, false, GrTypeDefinition.class, GrClosableBlock.class); if (method == null) return null; final TextRange headerRange = GrHighlightUtil.getMethodHeaderTextRange(method); if (!headerRange.contains(offset) && !headerRange.contains(offset - 1)) return null; if (method.isConstructor()) return null; if (method.getReturnTypeElementGroovy() != null) return null; return method; } | findMethod |
29,093 | void (@NotNull ActionContext context, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { final GrMethod method = findMethod(element, context.offset()); if (method == null) return; applyFix(context.project(), method); } | invoke |
29,094 | void (@NotNull Project project, @NotNull GrMethod method) { PsiType type = method.getInferredReturnType(); if (type == null) type = PsiType.getJavaLangObject(PsiManager.getInstance(project), method.getResolveScope()); type = TypesUtil.unboxPrimitiveTypeWrapper(type); GrReferenceAdjuster.shortenAllReferencesIn(method.setReturnType(type)); method.getModifierList().setModifierProperty(DEF, false); } | applyFix |
29,095 | void () { String name = getEnteredName(); MultiMap<PsiElement, String> conflicts = new MultiMap<>(); assert name != null; GroovyValidationUtil.validateNewParameterName(firstParam, conflicts, name); if (isClosure) { findClosureConflictUsages(conflicts, occurrences); } if (reportConflicts(conflicts, project)) { performRefactoring(element, owner, occurrences, createNewFirst(), name, specifyTypeExplicitly()); } super.doOKAction(); } | doOKAction |
29,096 | void (MultiMap<PsiElement, String> conflicts, Collection<PsiElement> occurrences) { for (PsiElement occurrence : occurrences) { PsiElement origin = occurrence; while (occurrence instanceof GrReferenceExpression) { occurrence = occurrence.getParent(); } if (occurrence instanceof GrArgumentList) { conflicts.putValue(origin, GroovyBundle.message("closure.used.as.variable")); } } } | findClosureConflictUsages |
29,097 | boolean () { return false; } | startInWriteAction |
29,098 | void (final PsiElement element, final GrParameterListOwner owner, final Collection<PsiElement> occurrences, final boolean createNewFirstParam, @Nullable final String mapParamName, final boolean specifyMapType) { final GrParameter param = getAppropriateParameter(element); assert param != null; final String paramName = param.getName(); final String mapName = createNewFirstParam ? mapParamName : getFirstParameter(owner).getName(); final Project project = element.getProject(); final Runnable runnable = () -> { final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(project); final GrParameterList list = owner.getParameterList(); final int index = list.getParameterNumber(param); if (!createNewFirstParam && index <= 0) { // bad undo return; } //Remove old arguments from occurrences //final List<GrCall> calls = getCallOccurrences(occurrences); try { for (PsiElement occurrence : occurrences) { GrReferenceExpression refExpr = null; GroovyResolveResult resolveResult = null; boolean isExplicitGetterCall = false; if (occurrence instanceof GrReferenceExpression) { final PsiElement parent = occurrence.getParent(); if (parent instanceof GrCall) { refExpr = (GrReferenceExpression)occurrence; resolveResult = refExpr.advancedResolve(); final PsiElement resolved = resolveResult.getElement(); if (resolved instanceof PsiMethod && GroovyPropertyUtils.isSimplePropertyGetter(((PsiMethod)resolved)) && //check for explicit getter call ((PsiMethod)resolved).getName().equals(refExpr.getReferenceName())) { isExplicitGetterCall = true; } } else if (parent instanceof GrReferenceExpression) { resolveResult = ((GrReferenceExpression)parent).advancedResolve(); final PsiElement resolved = resolveResult.getElement(); if (resolved instanceof PsiMethod && "call".equals(((PsiMethod)resolved).getName())) { refExpr = (GrReferenceExpression)parent; } } } if (refExpr == null) continue; final GrSignature signature = generateSignature(owner, refExpr); if (signature == null) continue; GrCall call; if (isExplicitGetterCall) { PsiElement parent = refExpr.getParent(); LOG.assertTrue(parent instanceof GrCall); parent = parent.getParent(); if (parent instanceof GrReferenceExpression && "call".equals(((GrReferenceExpression)parent).getReferenceName())) { parent = parent.getParent(); } if (parent instanceof GrCall) { call = (GrCall)parent; } else { continue; } } else { call = (GrCall)refExpr.getParent(); } if (resolveResult.isInvokedOnProperty()) { final PsiElement parent = call.getParent(); if (parent instanceof GrCall) { call = (GrCall)parent; } else if (parent instanceof GrReferenceExpression && parent.getParent() instanceof GrCall) { final PsiElement resolved = ((GrReferenceExpression)parent).resolve(); if (resolved instanceof PsiMethod && "call".equals(((PsiMethod)resolved).getName())) { call = (GrCall)parent.getParent(); } else { continue; } } } final GrClosureSignatureUtil.ArgInfo<PsiElement>[] argInfos = GrClosureSignatureUtil.mapParametersToArguments(signature, call); if (argInfos == null) continue; final GrClosureSignatureUtil.ArgInfo<PsiElement> argInfo = argInfos[index]; final GrNamedArgument namedArg; if (argInfo.isMultiArg) { if (argInfo.args.isEmpty()) continue; String arg = "[" + StringUtil.join(ContainerUtil.map(argInfo.args, element1 -> element1.getText()), ", ") + "]"; for (PsiElement psiElement : argInfo.args) { psiElement.delete(); } namedArg = factory.createNamedArgument(paramName, factory.createExpressionFromText(arg)); } else { if (argInfo.args.isEmpty()) continue; final PsiElement argument = argInfo.args.iterator().next(); assert argument instanceof GrExpression; namedArg = factory.createNamedArgument(paramName, (GrExpression)argument); argument.delete(); } call.addNamedArgument(namedArg); } } catch (IncorrectOperationException e) { LOG.error(e); } //Replace of occurrences of old parameter in closure/method final Collection<PsiReference> references = ReferencesSearch.search(param).findAll(); for (PsiReference ref : references) { final PsiElement elt = ref.getElement(); if (elt instanceof GrReferenceExpression expr) { final GrExpression newExpr = factory.createExpressionFromText(mapName + "." + paramName); expr.replaceWithExpression(newExpr, true); } } //Add new map parameter to closure/method if it's necessary if (createNewFirstParam) { try { final GrParameter newParam = factory.createParameter(mapName, specifyMapType ? MAP_TYPE_TEXT : "", null); list.addAfter(newParam, null); } catch (IncorrectOperationException e) { LOG.error(e); } } //Eliminate obsolete parameter from parameter list param.delete(); }; CommandProcessor.getInstance().executeCommand(project, () -> ApplicationManager.getApplication().runWriteAction(runnable), GroovyBundle.message("convert.parameter.to.map.entry.title"), null); } | performRefactoring |
29,099 | GrParameter (final PsiElement element) { if (element instanceof GrParameter) { return (GrParameter)element; } if (element instanceof GrReferenceExpression expr) { final PsiElement resolved = expr.resolve(); LOG.assertTrue(resolved instanceof GrParameter); return ((GrParameter)resolved); } LOG.error("Selected expression is not resolved to method/closure parameter"); return null; } | getAppropriateParameter |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.