Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
30,200 | void (@NotNull GrImportStatement statement) { if (!myOptions.skipImports()) { visitElement(statement); } } | visitImportStatement |
30,201 | void (@NotNull GrDocComment comment) {} | visitDocComment |
30,202 | void (@NotNull GrLiteral literal) {} | visitLiteralExpression |
30,203 | OptPane () { return pane( number("m_limit", InspectionGadgetsBundle.message("overly.complex.arithmetic.expression.max.number.option"), 2, 100)); } | getGroovyOptionsPane |
30,204 | void (@NotNull Project project, @NotNull PsiElement startElement, @NotNull ModPsiUpdater updater) { LOG.assertTrue(startElement instanceof GrReferenceElement<?>); GrReferenceAdjuster.shortenReference((GrQualifiedReference<?>)startElement); } | applyFix |
30,205 | String () { return GroovyBundle.message("replace.qualified.name.with.import"); } | getFamilyName |
30,206 | OptPane () { return pane( number("m_limit", InspectionGadgetsBundle.message("overly.complex.boolean.expression.max.terms.option"), 2, 100)); } | getGroovyOptionsPane |
30,207 | LocalQuickFix () { return new MyQuickFix(); } | getFix |
30,208 | String () { return GroovyBundle.message("declare.explicit.implementations.of.trait"); } | getFamilyName |
30,209 | void (@NotNull Project project, @NotNull final ProblemDescriptor descriptor) { PsiElement element = descriptor.getPsiElement(); PsiElement parent = element.getParent(); if (parent instanceof GrTypeDefinition aClass && ((GrTypeDefinition)parent).getNameIdentifierGroovy() == element) { final List<ClashingMethod> clashingMethods = collectClassingMethods(aClass); for (ClashingMethod method : clashingMethods) { PsiMethod traitMethod = method.getSignature().getMethod(); LOG.assertTrue(traitMethod instanceof GrTraitMethod); OverrideImplementUtil.overrideOrImplement(aClass, traitMethod); } } } | applyFix |
30,210 | void (@NotNull PsiDocComment comment, @NotNull TokenConsumer consumer) { final CommentSplitter splitter = CommentSplitter.getInstance(); for (PsiElement el : comment.getChildren()) { if (el instanceof PsiDocTag tag) { if (!excludedTags.contains(tag.getName())) { for (PsiElement data : tag.getDataElements()) { consumer.consumeToken(data, splitter); } } } else { consumer.consumeToken(el, splitter); } } } | tokenize |
30,211 | void (@NotNull PsiElement literal, @NotNull TokenConsumer consumer) { String text = GrStringUtil.removeQuotes(literal.getText()); if (!text.contains("\\")) { consumer.consumeToken(literal, PlainTextSplitter.getInstance()); } else { StringBuilder unescapedText = new StringBuilder(); int[] offsets = new int[text.length() + 1]; GrStringUtil.parseStringCharacters(text, unescapedText, offsets); processTextWithOffsets(literal, consumer, unescapedText, offsets, GrStringUtil.getStartQuote(literal.getText()).length()); } } | tokenize |
30,212 | Tokenizer (PsiElement element) { if (TokenSets.STRING_LITERAL_SET.contains(element.getNode().getElementType())) { return myStringTokenizer; } if (element instanceof GrNamedElement) { final PsiElement name = ((GrNamedElement)element).getNameIdentifierGroovy(); if (TokenSets.STRING_LITERAL_SET.contains(name.getNode().getElementType())) { return EMPTY_TOKENIZER; } } if (element instanceof PsiDocComment) return myDocCommentTokenizer; //if (element instanceof GrLiteralImpl && ((GrLiteralImpl)element).isStringLiteral()) return myStringTokenizer; return super.getTokenizer(element); } | getTokenizer |
30,213 | OptPane () { return pane( number("m_limit", GroovyBundle.message("method.returns.max.returns.option"), 1, 100)); } | getGroovyOptionsPane |
30,214 | OptPane () { return pane( number("m_limit", GroovyBundle.message("method.parameters.count.max.parameters.option"), 1, 255)); } | getGroovyOptionsPane |
30,215 | OptPane () { return pane( number("m_limit", GroovyBundle.message("overly.complex.method.complexity.limit.option"), 1, 1000)); } | getGroovyOptionsPane |
30,216 | OptPane () { return pane( number("m_limit", GroovyBundle.message("overly.nested.method.nesting.limit.option"), 1, 100)); } | getGroovyOptionsPane |
30,217 | OptPane () { return pane( number("m_limit", GroovyBundle.message("overly.long.method.statements.limit.option"), 2, 1000)); } | getGroovyOptionsPane |
30,218 | IntentionPreviewInfo (@NotNull Project project, @NotNull ProblemDescriptor previewDescriptor) { final PsiElement element = previewDescriptor.getPsiElement(); PsiClass psiClass = PsiTreeUtil.getParentOfType(element, PsiClass.class); if (psiClass == null) return IntentionPreviewInfo.EMPTY; String textBefore = psiClass.getText(); psiClass.setName("NewCustomName"); String textAfter = psiClass.getText(); return new IntentionPreviewInfo.CustomDiff(GroovyFileType.GROOVY_FILE_TYPE, textBefore, textAfter); } | generatePreview |
30,219 | String () { return GroovyBundle.message("intention.family.name.rename"); } | getFamilyName |
30,220 | void (@NotNull final Project project, @NotNull ProblemDescriptor descriptor) { final PsiElement element = descriptor.getPsiElement(); doFix(element); } | doFix |
30,221 | RefactoringActionHandler () { return RefactoringActionHandlerFactory.getInstance().createRenameHandler(); } | getHandler |
30,222 | String () { return GroovyBundle.message("remove.parameter.0", myName); } | getText |
30,223 | String () { return GroovyBundle.message("remove.unused.parameter"); } | getFamilyName |
30,224 | boolean (@NotNull Project project, Editor editor, PsiFile file) { PsiElement at = file.findElementAt(editor.getCaretModel().getOffset()); GrParameter parameter = PsiTreeUtil.getParentOfType(at, GrParameter.class); return parameter != null && myName.equals(parameter.getName()); } | isAvailable |
30,225 | GrParameter (Editor editor, PsiFile file) { PsiElement at = file.findElementAt(editor.getCaretModel().getOffset()); GrParameter parameter = PsiTreeUtil.getParentOfType(at, GrParameter.class); if (parameter == null) return null; return parameter; } | getParameter |
30,226 | GrChangeInfoImpl (GrMethod method, GrParameter parameter) { List<GrParameterInfo> params = new ArrayList<>(); int i = 0; for (GrParameter p : method.getParameterList().getParameters()) { if (p != parameter) { params.add(new GrParameterInfo(p, i)); } i++; } GrTypeElement typeElement = method.getReturnTypeElementGroovy(); CanonicalTypes.Type wrapper = typeElement != null ? CanonicalTypes.createTypeWrapper(method.getReturnType()) : null; return new GrChangeInfoImpl(method, null, wrapper, method.getName(), params, null, false); } | createChangeInfo |
30,227 | IntentionPreviewInfo (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { GrParameter parameter = getParameter(editor, file); if (parameter == null) { return IntentionPreviewInfo.EMPTY; } parameter.delete(); return IntentionPreviewInfo.DIFF; } | generatePreview |
30,228 | boolean () { return false; } | startInWriteAction |
30,229 | String () { return GroovyBundle.message("implement.class", myInterfaceName); } | getName |
30,230 | String () { return GroovyBundle.message("add.class.to.extends.family.name"); } | getFamilyName |
30,231 | String () { return GroovyBundle.message("add.method", myMethodName, myClassName); } | getName |
30,232 | String () { return GroovyBundle.message("add.method.family"); } | getFamilyName |
30,233 | String (GrTypeDefinition aClass) { String className = aClass.getName(); LOG.assertTrue(className != null, aClass); StringBuilder returnType = new StringBuilder(className); final PsiTypeParameter[] typeParameters = aClass.getTypeParameters(); if (typeParameters.length > 0) { returnType.append('<'); for (PsiTypeParameter typeParameter : typeParameters) { returnType.append(typeParameter.getName()).append(", "); } returnType.replace(returnType.length() - 2, returnType.length(), ">"); } return returnType.toString(); } | generateTypeText |
30,234 | BaseInspectionVisitor () { return new BaseInspectionVisitor() { @Override public void visitFile(@NotNull GroovyFileBase file) { CompilerConfiguration configuration = CompilerConfiguration.getInstance(file.getProject()); if (configuration != null && !configuration.isResourceFile(file.getVirtualFile()) && fileSeemsToBeTypeCustomizer(file)) { final LocalQuickFix[] fixes = {new AddToResourceFix(file)}; final String message = GroovyBundle.message("type.customizer.is.not.marked.as.a.resource.file"); registerError(file, message, fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } } }; } | buildVisitor |
30,235 | void (@NotNull GroovyFileBase file) { CompilerConfiguration configuration = CompilerConfiguration.getInstance(file.getProject()); if (configuration != null && !configuration.isResourceFile(file.getVirtualFile()) && fileSeemsToBeTypeCustomizer(file)) { final LocalQuickFix[] fixes = {new AddToResourceFix(file)}; final String message = GroovyBundle.message("type.customizer.is.not.marked.as.a.resource.file"); registerError(file, message, fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } } | visitFile |
30,236 | boolean (@NotNull final PsiFile file) { if (file instanceof GroovyFile && ((GroovyFile)file).isScript()) { for (GrStatement statement : ((GroovyFile)file).getStatements()) { if (statement instanceof GrMethodCall) { GrExpression invoked = ((GrMethodCall)statement).getInvokedExpression(); if (invoked instanceof GrReferenceExpression && !((GrReferenceExpression)invoked).isQualified() && isCustomizerEvent(((GrReferenceExpression)invoked).getReferenceName())) { return true; } } } } return false; } | fileSeemsToBeTypeCustomizer |
30,237 | boolean (@Nullable String name) { return CUSTOMIZER_EVENT_NAMES.contains(name); } | isCustomizerEvent |
30,238 | String () { return GroovyBundle.message("add.to.resources"); } | getName |
30,239 | boolean () { return false; } | startInWriteAction |
30,240 | String () { return GroovyBundle.message("add.type.customizer.to.resources"); } | getFamilyName |
30,241 | void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { PsiFile file = myFilePointer.getElement(); if (file == null) return; final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile == null) return; final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); final VirtualFile contentRoot = fileIndex.getContentRootForFile(virtualFile); if (contentRoot == null) return; final VirtualFile sourceRoot = fileIndex.getSourceRootForFile(virtualFile); if (sourceRoot == null) { final String path = VfsUtilCore.getRelativePath(virtualFile, contentRoot, '/'); CompilerConfiguration.getInstance(project).addResourceFilePattern(path); } else { final String path = VfsUtilCore.getRelativePath(virtualFile, sourceRoot, '/'); final String sourceRootPath = VfsUtilCore.getRelativePath(sourceRoot, contentRoot, '/'); CompilerConfiguration.getInstance(project).addResourceFilePattern(sourceRootPath + ':' + path); } DaemonCodeAnalyzer.getInstance(project).restart(file); } | applyFix |
30,242 | OptPane () { return pane( number("m_limit", InspectionGadgetsBundle.message("if.statement.with.too.many.branches.max.option"), 2, 100)); } | getGroovyOptionsPane |
30,243 | GlobalSearchScope (@NotNull VirtualFile file, @NotNull Project project) { final GroovyConsoleStateService projectConsole = GroovyConsoleStateService.getInstance(project); final Module module = projectConsole.getSelectedModule(file); if (module == null || module.isDisposed()) return null; GlobalSearchScope moduleScope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module); if (hasNeededDependenciesToRunConsole(module)) return moduleScope; GlobalSearchScope bundledScope = createBundledGroovyScope(project); return bundledScope != null ? moduleScope.uniteWith(bundledScope) : moduleScope; } | getResolveScope |
30,244 | void (Project project, Consumer<Module> consumer) { ModuleChooserUtil.selectModule(project, getApplicableModules(project), GroovyConsoleUtil::getDisplayGroovyVersion, consumer); } | selectModuleAndRun |
30,245 | void (@NotNull AnActionEvent e) { final Project project = e.getProject(); final Editor editor = e.getData(CommonDataKeys.EDITOR); final VirtualFile virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE); if (project == null || editor == null || virtualFile == null) return; FileDocumentManager.getInstance().saveAllDocuments(); final Document document = editor.getDocument(); final TextRange selectedRange = EditorUtil.getSelectionInAnyMode(editor); final String command; if (selectedRange.isEmpty()) { command = document.getText(); // whole document } else { StringBuilder commandBuilder = new StringBuilder(); PsiFile file = e.getData(CommonDataKeys.PSI_FILE); if (file instanceof GroovyFile) { GrImportStatement[] statements = ((GroovyFile)file).getImportStatements(); for (GrImportStatement statement : statements) { if (!selectedRange.contains(statement.getTextRange())) { commandBuilder.append(statement.getText()).append("\n"); } } } commandBuilder.append(document.getText(selectedRange)); command = commandBuilder.toString(); } GroovyConsole.getOrCreateConsole(project, virtualFile, console -> console.execute(command)); } | actionPerformed |
30,246 | GroovyConsoleRootType () { return findByClass(GroovyConsoleRootType.class); } | getInstance |
30,247 | String () { return GroovyFileType.DEFAULT_EXTENSION; } | getDefaultFileExtension |
30,248 | boolean (@NotNull Project project, @NotNull VirtualFile element) { return !GroovyConsoleStateService.getInstance(project).isProjectConsole(element); } | isIgnored |
30,249 | String (@NotNull String id) { assert id.equals(CONTENT_ID); return CONTENT_ID; } | getContentPathName |
30,250 | void (@NotNull final VirtualFile file, @NotNull FileEditorManager source) { for (FileEditor fileEditor : source.getAllEditors(file)) { if (!(fileEditor instanceof TextEditor)) continue; EXECUTE_ACTION.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, fileEditor.getComponent()); } } | fileOpened |
30,251 | ActionUpdateThread () { return ActionUpdateThread.BGT; } | getActionUpdateThread |
30,252 | void (@NotNull AnActionEvent e) { e.getPresentation().setEnabled(isEnabled()); } | update |
30,253 | boolean () { if (myModule == null || myModule.isDisposed()) return false; final ProcessHandler processHandler = myContentDescriptor.getProcessHandler(); if (processHandler == null || processHandler.isProcessTerminated()) return false; return true; } | isEnabled |
30,254 | void (@NotNull AnActionEvent e) { if (RunContentManager.getInstance(myProject).removeRunContent(myExecutor, myContentDescriptor)) { CompilerManager.getInstance(myProject).compile(myModule, new CompileStatusNotification() { @Override public void finished(boolean aborted, int errors, int warnings, @NotNull CompileContext compileContext) { if (!myModule.isDisposed()) { myRestarter.consume(myModule); } } }); } } | actionPerformed |
30,255 | void (boolean aborted, int errors, int warnings, @NotNull CompileContext compileContext) { if (!myModule.isDisposed()) { myRestarter.consume(myModule); } } | finished |
30,256 | void (@NotNull String command) { for (String line : command.trim().split("\n")) { myConsoleView.print("> ", ConsoleViewContentType.USER_INPUT); myConsoleView.print(line, ConsoleViewContentType.USER_INPUT); myConsoleView.print("\n", ConsoleViewContentType.NORMAL_OUTPUT); } ApplicationManager.getApplication().executeOnPooledThread( () -> send(myProcessHandler, StringUtil.replace(command, "\n", "###\\n")) ); } | doExecute |
30,257 | void (@NotNull String command) { if (!StringUtil.isEmptyOrSpaces(command)) { doExecute(command); } RunContentManager.getInstance(myProject).toFrontRunContent(defaultExecutor, myContentDescriptor); } | execute |
30,258 | void () { myProcessHandler.destroyProcess(); // use force } | stop |
30,259 | void (@NotNull ProcessHandler processHandler, @NotNull String command) { final OutputStream outputStream = processHandler.getProcessInput(); assert outputStream != null : "output stream is null"; final Charset charset = processHandler instanceof BaseOSProcessHandler ? ((BaseOSProcessHandler)processHandler).getCharset() : null; byte[] bytes = (command + "\n").getBytes(charset != null ? charset : StandardCharsets.UTF_8); try { outputStream.write(bytes); outputStream.flush(); } catch (IOException e) { LOG.warn(e); } } | send |
30,260 | void (@NotNull VirtualFile contentFile) { GroovyConsole console = removeUserData(contentFile, GROOVY_CONSOLE); if (console != null) { console.stop(); } } | stopConsole |
30,261 | void (@NotNull final Project project, @NotNull final VirtualFile contentFile, @NotNull final Consumer<? super GroovyConsole> callback) { final GroovyConsole existingConsole = contentFile.getUserData(GROOVY_CONSOLE); if (existingConsole != null) { callback.consume(existingConsole); return; } final Consumer<Module> initializer = module -> { final GroovyConsole console = createConsole(project, contentFile, module); if (console != null) { callback.consume(console); } }; final GroovyConsoleStateService service = GroovyConsoleStateService.getInstance(project); final Module module = service.getSelectedModule(contentFile); if (module != null) { // if module for console is already selected, then use it for creation initializer.consume(module); return; } // if not, then select module, then run initializer GroovyConsoleUtil.selectModuleAndRun(project, selectedModule -> { service.setFileModule(contentFile, selectedModule); initializer.consume(selectedModule); }); } | getOrCreateConsole |
30,262 | GroovyConsole (@NotNull final Project project, @NotNull final VirtualFile contentFile, @NotNull Module module) { final ProcessHandler processHandler = createProcessHandler(module); if (processHandler == null) return null; final ConsoleViewImpl consoleView = new GroovyConsoleView(project); final RunContentDescriptor descriptor = new RunContentDescriptor( consoleView, processHandler, new JPanel(new BorderLayout()), contentFile.getNameWithoutExtension() ); final GroovyConsole console = new GroovyConsole(project, descriptor, consoleView, processHandler); // must call getComponent before createConsoleActions() final JComponent consoleViewComponent = consoleView.getComponent(); final DefaultActionGroup actionGroup = new DefaultActionGroup(); actionGroup.add(new BuildAndRestartConsoleAction(module, project, defaultExecutor, descriptor, restarter(project, contentFile))); actionGroup.addSeparator(); actionGroup.addAll(consoleView.createConsoleActions()); actionGroup.add(new CloseAction(defaultExecutor, descriptor, project) { @Override public void actionPerformed(@NotNull AnActionEvent e) { processHandler.destroyProcess(); // use force super.actionPerformed(e); } }); final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("GroovyConsole", actionGroup, false); toolbar.setTargetComponent(consoleViewComponent); final JComponent ui = descriptor.getComponent(); ui.add(consoleViewComponent, BorderLayout.CENTER); ui.add(toolbar.getComponent(), BorderLayout.WEST); processHandler.addProcessListener(new ProcessAdapter() { @Override public void processTerminated(@NotNull ProcessEvent event) { if (contentFile.getUserData(GROOVY_CONSOLE) == console) { // process terminated either by closing file or by close action contentFile.putUserData(GROOVY_CONSOLE, null); } } }); contentFile.putUserData(GROOVY_CONSOLE, console); consoleView.attachToProcess(processHandler); processHandler.startNotify(); RunContentManager.getInstance(project).showRunContent(defaultExecutor, descriptor); return console; } | createConsole |
30,263 | void (@NotNull AnActionEvent e) { processHandler.destroyProcess(); // use force super.actionPerformed(e); } | actionPerformed |
30,264 | void (@NotNull ProcessEvent event) { if (contentFile.getUserData(GROOVY_CONSOLE) == console) { // process terminated either by closing file or by close action contentFile.putUserData(GROOVY_CONSOLE, null); } } | processTerminated |
30,265 | ProcessHandler (Module module) { try { final JavaParameters javaParameters = createJavaParameters(module); final GeneralCommandLine commandLine = javaParameters.toCommandLine(); return new ColoredProcessHandler(commandLine) { @Override protected @NotNull BaseOutputReader.Options readerOptions() { return BaseOutputReader.Options.forMostlySilentProcess(); } @Override public boolean isSilentlyDestroyOnClose() { return true; } }; } catch (ExecutionException e) { LOG.warn(e); return null; } } | createProcessHandler |
30,266 | boolean () { return true; } | isSilentlyDestroyOnClose |
30,267 | boolean (@NotNull JavaParameters res) { Sdk jdk = res.getJdk(); if (jdk == null) { return false; } String rootPath = jdk.getHomePath(); if (rootPath == null) { return false; } return JdkUtil.isModularRuntime(rootPath); } | useArgsFile |
30,268 | Consumer<Module> (final Project project, final VirtualFile file) { return module -> createConsole(project, file, module); } | restarter |
30,269 | ASTNode (ASTNode node) { IElementType elementType = node.getElementType(); if (elementType == GroovyElementTypes.CLOSABLE_BLOCK) { PsiElement rBrace = ((GrClosableBlock)node.getPsi()).getRBrace(); return rBrace != null ? rBrace.getNode() : null; } ASTNode lastChild = node.getLastChildNode(); while (lastChild != null && PsiImplUtil.isWhiteSpaceOrNls(lastChild)) { lastChild = lastChild.getTreePrev(); } if (lastChild == null) return null; return getClosureRBraceAtTheEnd(lastChild); } | getClosureRBraceAtTheEnd |
30,270 | boolean (PsiElement e) { return e != null && e.getNode().getElementType() == GroovyTokenTypes.mRCURLY && e.getParent() instanceof GrClosableBlock && ((GrClosableBlock)e.getParent()).getRBrace() == e; } | isClosureRBrace |
30,271 | PsiElement (PsiElement e) { PsiElement next = PsiTreeUtil.nextLeaf(e); while (next != null && next.getNode().getElementType() == TokenType.WHITE_SPACE) next = PsiTreeUtil.nextLeaf(next); return next; } | getNextNonWhitespaceToken |
30,272 | void (PsiElement rBrace, AlignmentProvider alignments) { int leadingBraceCount = 0; PsiElement next; if (!isClosureContainLF(rBrace)) return; for (next = PsiUtil.getPreviousNonWhitespaceToken(rBrace); isClosureRBrace(next) && isClosureContainLF(next); next = PsiUtil.getPreviousNonWhitespaceToken(next)) { leadingBraceCount++; } PsiElement cur = rBrace; for (next = getNextNonWhitespaceToken(cur); isClosureRBrace(next); next = getNextNonWhitespaceToken(cur)) { cur = next; } for (; leadingBraceCount > 0; leadingBraceCount--) { cur = PsiUtil.getPreviousNonWhitespaceToken(cur); } PsiElement parent = cur.getParent(); LOG.assertTrue(parent instanceof GrClosableBlock); //search for start of the line cur = parent; if (cur.getParent() instanceof GrMethodCall call) { GrExpression invoked = call.getInvokedExpression(); if (invoked instanceof GrReferenceExpression && ((GrReferenceExpression)invoked).getReferenceNameElement() != null) { cur = ((GrReferenceExpression)invoked).getReferenceNameElement(); } else { cur = call; } } cur = PsiTreeUtil.getDeepestFirst(cur); while (!PsiUtil.isNewLine(next = PsiTreeUtil.prevLeaf(cur, true))) { if (next == null) break; if (next.getNode().getElementType() == TokenType.WHITE_SPACE && PsiTreeUtil.prevLeaf(next) == null) { break; //if cur is first word in the text, whitespace could be before it } cur = next; } int startOffset = cur.getTextRange().getStartOffset(); int endOffset = rBrace.getTextRange().getStartOffset(); if (rBrace.getContainingFile().getText().substring(startOffset, endOffset).indexOf('\n') < 0) { return; } while (true) { final PsiElement p = cur.getParent(); if (p != null && p.getTextOffset() == cur.getTextOffset()) { cur = p; } else { break; } } alignments.addPair(rBrace, cur, true); } | calculateRBraceAlignment |
30,273 | boolean (PsiElement rBrace) { PsiElement parent = rBrace.getParent(); return parent.getText().indexOf('\n') >= 0; } | isClosureContainLF |
30,274 | PsiElement (@NotNull PsiElement source, @NotNull CodeStyleSettings settings) { if (source instanceof GroovyPsiElement) { return new GroovyBraceEnforcer(settings).process(((GroovyPsiElement)source)); } else { return source; } } | processElement |
30,275 | TextRange (@NotNull PsiFile source, @NotNull TextRange rangeToReformat, @NotNull CodeStyleSettings settings) { if (source instanceof GroovyFile) { return new GroovyBraceEnforcer(settings).processText(((GroovyFile)source), rangeToReformat); } else { return rangeToReformat; } } | processText |
30,276 | boolean (@NotNull ASTNode node) { return node.getElementType() == GroovyTokenTypes.mNLS; } | containsWhitespacesOnly |
30,277 | FormattingModel (com.intellij.formatting.@NotNull FormattingContext formattingContext) { PsiFile containingFile = formattingContext.getContainingFile().getViewProvider().getPsi(GroovyLanguage.INSTANCE); assert containingFile != null; ASTNode astNode = containingFile.getNode(); assert astNode != null; CodeStyleSettings settings = formattingContext.getCodeStyleSettings(); CommonCodeStyleSettings groovySettings = settings.getCommonSettings(GroovyLanguage.INSTANCE); GroovyCodeStyleSettings customSettings = settings.getCustomSettings(GroovyCodeStyleSettings.class); final AlignmentProvider alignments = new AlignmentProvider(); if (customSettings.USE_FLYING_GEESE_BRACES) { formattingContext.getPsiElement().accept(new PsiRecursiveElementVisitor() { @Override public void visitElement(@NotNull PsiElement element) { if (GeeseUtil.isClosureRBrace(element)) { GeeseUtil.calculateRBraceAlignment(element, alignments); } else { super.visitElement(element); } } }); } final GroovyBlock block = new GroovyBlock( astNode, Indent.getAbsoluteNoneIndent(), null, new FormattingContext(groovySettings, alignments, customSettings, false, false, GroovyBlockProducer.DEFAULT) ); if (Registry.is("groovy.document.based.formatting")) { return new DocumentBasedFormattingModel(block, settings, containingFile); } else { return new GroovyFormattingModel(containingFile, block, FormattingDocumentModelImpl.createOn(containingFile)); } } | createModel |
30,278 | void (@NotNull PsiElement element) { if (GeeseUtil.isClosureRBrace(element)) { GeeseUtil.calculateRBraceAlignment(element, alignments); } else { super.visitElement(element); } } | visitElement |
30,279 | String (TextRange textRange, String whiteSpace, ASTNode leafElement) { if (!myCanModifyAllWhiteSpaces) { if (PsiImplUtil.isWhiteSpaceOrNls(leafElement)) return null; } IElementType elementTypeToUse = TokenType.WHITE_SPACE; ASTNode prevNode = TreeUtil.prevLeaf(leafElement); if (prevNode != null && PsiImplUtil.isWhiteSpaceOrNls(prevNode)) { elementTypeToUse = prevNode.getElementType(); } FormatterUtil.replaceWhiteSpace(whiteSpace, leafElement, elementTypeToUse, textRange); return whiteSpace; } | replaceWithPsiInLeaf |
30,280 | TextRange (final GroovyFile source, final TextRange rangeToReformat) { myPostProcessor.setResultTextRange(rangeToReformat); source.accept(this); return myPostProcessor.getResultTextRange(); } | processText |
30,281 | PsiElement (GroovyPsiElement formatted) { LOG.assertTrue(formatted.isValid()); formatted.accept(this); return formatted; } | process |
30,282 | void (@NotNull GrStatement statement, GrStatement blockCandidate) { if (!statement.isValid()) { LOG.assertTrue(false); } if (!checkRangeContainsElement(blockCandidate)) return; final PsiManager manager = statement.getManager(); LOG.assertTrue(manager != null); GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(manager.getProject()); String oldText = blockCandidate.getText(); // There is a possible case that target block to wrap ends with single-line comment. Example: // if (true) i = 1; // Cool assignment // We can't just surround target block of code with curly braces because the closing one will be treated as comment as well. // Hence, we perform a check if we have such situation at the moment and insert new line before the closing brace. StringBuilder buf = new StringBuilder(oldText.length() + 5); buf.append("{\n").append(oldText); buf.append("\n}"); final int oldTextLength = statement.getTextLength(); try { ASTNode newChild = SourceTreeToPsiMap.psiElementToTree(factory.createBlockStatementFromText(buf.toString(), null)); ASTNode parent = SourceTreeToPsiMap.psiElementToTree(statement); ASTNode childToReplace = SourceTreeToPsiMap.psiElementToTree(blockCandidate); CodeEditUtil.replaceChild(parent, childToReplace, newChild); removeTailSemicolon(newChild, parent); statement = forcePsiPostprocessAndRestoreElement(statement); if (statement != null) { CodeStyleManager.getInstance(statement.getProject()).reformat(statement, true); } } catch (IncorrectOperationException e) { LOG.error(e); } finally { updateResultRange(oldTextLength, statement.getTextLength()); } } | replaceWithBlock |
30,283 | void (ASTNode newChild, ASTNode parent) { ASTNode semi = newChild.getTreeNext(); while (semi != null && semi.getElementType() == TokenType.WHITE_SPACE && !semi.getText().contains("\n")) { semi = semi.getTreeNext(); } if (semi != null && semi.getElementType() == GroovyTokenTypes.mSEMI) { parent.removeRange(newChild.getTreeNext(), semi.getTreeNext()); } } | removeTailSemicolon |
30,284 | void (final int oldTextLength, final int newTextLength) { myPostProcessor.updateResultRange(oldTextLength, newTextLength); } | updateResultRange |
30,285 | boolean (final PsiElement element) { return myPostProcessor.isElementPartlyInRange(element); } | checkElementContainsRange |
30,286 | boolean (final PsiElement element) { return myPostProcessor.isElementFullyInRange(element); } | checkRangeContainsElement |
30,287 | void (GrStatement statement, @Nullable GrStatement blockCandidate, int options) { if (blockCandidate instanceof GrCodeBlock || blockCandidate instanceof GrBlockStatement || blockCandidate == null) return; if (options == CommonCodeStyleSettings.FORCE_BRACES_ALWAYS || options == CommonCodeStyleSettings.FORCE_BRACES_IF_MULTILINE && PostFormatProcessorHelper.isMultiline(statement)) { replaceWithBlock(statement, blockCandidate); } } | processStatement |
30,288 | void (@NotNull GrIfStatement statement) { if (checkElementContainsRange(statement)) { final SmartPsiElementPointer pointer = SmartPointerManager.getInstance(statement.getProject()).createSmartPsiElementPointer(statement); super.visitIfStatement(statement); statement = (GrIfStatement)pointer.getElement(); if (statement == null) return; processStatement(statement, statement.getThenBranch(), myPostProcessor.getSettings().IF_BRACE_FORCE); final GrStatement elseBranch = statement.getElseBranch(); if (!(elseBranch instanceof GrIfStatement) || !myPostProcessor.getSettings().SPECIAL_ELSE_IF_TREATMENT) { processStatement(statement, elseBranch, myPostProcessor.getSettings().IF_BRACE_FORCE); } } } | visitIfStatement |
30,289 | void (@NotNull GrForStatement statement) { if (checkElementContainsRange(statement)) { super.visitForStatement(statement); processStatement(statement, statement.getBody(), myPostProcessor.getSettings().FOR_BRACE_FORCE); } } | visitForStatement |
30,290 | void (@NotNull GrWhileStatement statement) { if (checkElementContainsRange(statement)) { super.visitWhileStatement(statement); processStatement(statement, statement.getBody(), myPostProcessor.getSettings().WHILE_BRACE_FORCE); } } | visitWhileStatement |
30,291 | void (@NotNull GrDoWhileStatement statement) { if (checkElementContainsRange(statement)) { super.visitDoWhileStatement(statement); processStatement(statement, statement.getBody(), myPostProcessor.getSettings().DOWHILE_BRACE_FORCE); } } | visitDoWhileStatement |
30,292 | void (@NotNull PsiElement e1, @NotNull PsiElement e2, boolean allowBackwardShift) { Aligner aligner = createAligner(allowBackwardShift); aligner.append(e1); aligner.append(e2); } | addPair |
30,293 | Alignment (@NotNull PsiElement e) { Aligner aligner = myElement2Aligner.get(e); return aligner == null ? null : aligner.getAlignment(); } | getAlignment |
30,294 | Aligner (boolean allowBackwardShift) { return new Aligner(allowBackwardShift, Alignment.Anchor.LEFT); } | createAligner |
30,295 | Aligner (PsiElement element, boolean allowBackwardShift, Alignment.Anchor anchor) { final Aligner aligner = new Aligner(allowBackwardShift, anchor); aligner.append(element); return aligner; } | createAligner |
30,296 | void (@Nullable PsiElement element) { if (element == null) return; assert !myElement2Aligner.containsKey(element) || myElement2Aligner.get(element) == this; myElement2Aligner.put(element, this); } | append |
30,297 | Alignment () { return myAlignment.getValue(); } | getAlignment |
30,298 | CommonCodeStyleSettings () { return mySettings; } | getSettings |
30,299 | AlignmentProvider () { return myAlignmentProvider; } | getAlignmentProvider |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.