Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
76,900
boolean (@NotNull ASTNode pairNode) { PsiElement prev = PsiTreeUtil.skipWhitespacesAndCommentsBackward(pairNode.getPsi()); if (prev != null && prev.getNode().getElementType() != JavaTokenType.LPARENTH) return false; PsiElement next = PsiTreeUtil.skipWhitespacesAndCommentsForward(pairNode.getPsi()); if (next != null && ...
isSingleNameValuePair
76,901
boolean (@NotNull ASTNode child) { return child.getElementType() == JavaElementType.DECLARATION_STATEMENT && StringUtil.countNewLines(child.getChars()) == 0; }
shouldAlign
76,902
AlignmentStrategy () { return AlignmentStrategy.createAlignmentPerTypeStrategy(LOCAL_VAR_TYPES_TO_ALIGN, JavaElementType.LOCAL_VARIABLE, true); }
createStrategy
76,903
boolean (@NotNull ASTNode child) { IElementType childType = child.getElementType(); if (childType == JavaElementType.EXPRESSION_STATEMENT) { ASTNode expressionNode = child.getFirstChildNode(); if (expressionNode != null && expressionNode.getElementType() == JavaElementType.ASSIGNMENT_EXPRESSION) { return true; } } retu...
shouldAlign
76,904
AlignmentStrategy () { return AlignmentStrategy.createAlignmentPerTypeStrategy(ASSIGN_TYPES_TO_ALIGN, JavaElementType.ASSIGNMENT_EXPRESSION, true); }
createStrategy
76,905
ASTNode () { return myNode; }
getNode
76,906
TextRange () { if (myStartOffset != -1) { return new TextRange(myStartOffset, myStartOffset + myNode.getTextLength()); } return myNode.getTextRange(); }
getTextRange
76,907
List<Block> () { return EMPTY_SUB_BLOCKS; }
getSubBlocks
76,908
Wrap () { return myWrap; }
getWrap
76,909
Indent () { return myIndent; }
getIndent
76,910
Alignment () { return myAlignment; }
getAlignment
76,911
Spacing (Block child1, @NotNull Block child2) { return null; }
getSpacing
76,912
ASTNode () { return myNode; }
getTreeNode
76,913
ChildAttributes (final int newChildIndex) { return new ChildAttributes(getIndent(), null); }
getChildAttributes
76,914
boolean () { return false; }
isIncomplete
76,915
boolean () { return ShiftIndentInsideHelper.mayShiftIndentInside(myNode); }
isLeaf
76,916
void (final int startOffset) { myStartOffset = startOffset; // if (startOffset != -1) assert startOffset == myNode.getTextRange().getStartOffset(); }
setStartOffset
76,917
List<TextRange> (@NotNull FormattingRangesInfo info) { int startOffset = getTextRange().getStartOffset(); if (info.isOnInsertedLine(startOffset) && myNode.getTextLength() == 1 && myNode.textContains('}
getExtraRangesToFormat
76,918
Block (List<? extends ASTNode> nodes) { List<Block> blocks = buildBlocksFrom(nodes); Indent indent = myBlockIndent != null ? myBlockIndent : Indent.getContinuationWithoutFirstIndent(myIndentSettings.USE_RELATIVE_INDENTS); return new SyntheticCodeBlock(blocks, myBlockAlignment, mySettings, myJavaSettings, indent, myBloc...
build
76,919
List<Block> (List<? extends ASTNode> nodes) { List<ChainedCallChunk> methodCall = splitMethodCallOnChunksByDots(nodes); Wrap wrap = Wrap.createWrap(getWrapType(mySettings.METHOD_CALL_CHAIN_WRAP), true); Wrap builderMethodWrap = Wrap.createWrap(WrapType.ALWAYS, true); Alignment chainedCallsAlignment = null; List<Block> ...
buildBlocksFrom
76,920
int (@NotNull List<ChainedCallChunk> chunks) { String commonIndent = null; for (ChainedCallChunk chunk : chunks) { if (isMethodCall(chunk) && isBuilderMethod(chunk)) { String currIndent = chunk.getIndentString(); if (currIndent != null) { if (commonIndent == null) { commonIndent = currIndent; } else if (commonIndent.st...
getCommonIndentSize
76,921
int (int commonIndentSize, @NotNull ChainedCallChunk chunk) { if (commonIndentSize >= 0) { String indentString = chunk.getIndentString(); if (indentString != null) { return Math.max(indentString.length() - commonIndentSize, 0); } } return -1; }
getRelativeIndentSize
76,922
boolean (ChainedCallChunk chunk) { List<ASTNode> nodes = chunk.nodes; if (nodes.size() == 1) { return nodes.get(0).getPsi() instanceof PsiComment; } return false; }
isComment
76,923
boolean (@NotNull ChainedCallChunk chunk) { String identifier = chunk.getIdentifier(); return identifier != null && mySettings.isBuilderMethod(identifier); }
isBuilderMethod
76,924
boolean (int chunkIndex, @NotNull List<? extends ChainedCallChunk> methodCall) { if (chunkIndex <= 0) return false; ChainedCallChunk prev = methodCall.get(chunkIndex - 1); boolean isFirst = !isMethodCall(prev) || chunkIndex == 1; if (isFirst) { if (mySettings.WRAP_FIRST_METHOD_IN_CALL_CHAIN) { ChainedCallChunk next = c...
canWrap
76,925
boolean (ChainedCallChunk currentMethodChunk, List<ChainedCallChunk> methodCall) { return mySettings.ALIGN_MULTILINE_CHAINED_METHODS && !currentMethodChunk.isEmpty() && !chunkIsFirstInChainMethodCall(currentMethodChunk, methodCall); }
shouldAlignMethod
76,926
boolean (@NotNull ChainedCallChunk callChunk, @NotNull List<ChainedCallChunk> methodCall) { return !methodCall.isEmpty() && callChunk == methodCall.get(0); }
chunkIsFirstInChainMethodCall
76,927
List<ChainedCallChunk> (@NotNull List<? extends ASTNode> nodes) { List<ChainedCallChunk> result = new ArrayList<>(); List<ASTNode> current = new ArrayList<>(); for (ASTNode node : nodes) { if (JavaFormatterUtil.isStartOfCallChunk(mySettings, node) || node.getPsi() instanceof PsiComment) { if (!current.isEmpty()) { resu...
splitMethodCallOnChunksByDots
76,928
Alignment (int chunkIndex, @NotNull List<ChainedCallChunk> methodCall) { ChainedCallChunk current = methodCall.get(chunkIndex); return shouldAlignMethod(current, methodCall) ? AbstractJavaBlock.createAlignment(mySettings.ALIGN_MULTILINE_CHAINED_METHODS, null) : null; }
createCallChunkAlignment
76,929
boolean (@NotNull ChainedCallChunk callChunk) { for (Iterator<ASTNode> iter = callChunk.nodes.iterator(); iter.hasNext();) { ASTNode node = iter.next(); if (node.getElementType() == JavaTokenType.IDENTIFIER) { node = iter.hasNext() ? iter.next() : null; return node != null && node.getElementType() == JavaElementType.EX...
isMethodCall
76,930
record (@NotNull List<ASTNode> nodes) { boolean isEmpty() { return nodes.isEmpty(); } @Nullable private String getIdentifier() { return ObjectUtils.doIfNotNull( ContainerUtil.find(nodes, node -> node.getElementType() == JavaTokenType.IDENTIFIER), node -> node.getText()); } @Nullable private String getIndentString() { i...
ChainedCallChunk
76,931
String () { return ObjectUtils.doIfNotNull( ContainerUtil.find(nodes, node -> node.getElementType() == JavaTokenType.IDENTIFIER), node -> node.getText()); }
getIdentifier
76,932
String () { if (nodes.size() > 0) { ASTNode prev = nodes.get(0).getTreePrev(); if (prev != null && prev.getPsi() instanceof PsiWhiteSpace && prev.textContains('\n')) { CharSequence whitespace = prev.getChars(); int lineStart = CharArrayUtil.lastIndexOf(whitespace, "\n", whitespace.length() - 1); if (lineStart >= 0) { r...
getIndentString
76,933
int (@NotNull Document document, @Nullable Project project, @NotNull PsiElement element, int startOffset, int endOffset, int maxPreferredOffset, boolean isSoftWrap) { if (element.getNode().getElementType() == JavaDocTokenType.DOC_COMMENT_DATA) { CharSequence docChars = document.getCharsSequence(); if (isInsidePreTag(el...
doCalculateWrapPosition
76,934
int (@NotNull CharSequence chars, int startOffset, int endOffset) { @SuppressWarnings("HttpUrlsUsage") final String[] URL_PREFIX = { "http://", "https://", "ftp://"}; for (String urlPrefix : URL_PREFIX) { int urlOffset = CharArrayUtil.indexOf(chars, urlPrefix, startOffset, endOffset); if (urlOffset >= 0) { return urlOf...
getUrlOffset
76,935
boolean (@NotNull PsiElement element, @NotNull CharSequence chars, int offset) { PsiElement parent = PsiTreeUtil.findFirstParent( element, e -> e.getNode().getElementType() == JavaDocElementType.DOC_COMMENT); if (parent != null) { int preStart = CharArrayUtil.lastIndexOf(chars, PRE_TAG_START, offset); if (preStart >= 0...
isInsidePreTag
76,936
ChildAlignmentStrategyProvider (CommonCodeStyleSettings settings) { if (settings.KEEP_SIMPLE_METHODS_IN_ONE_LINE && settings.ALIGN_SUBSEQUENT_SIMPLE_METHODS) { return new SubsequentOneLineMethodsAligner(); } return ChildAlignmentStrategyProvider.NULL_STRATEGY_PROVIDER; }
getSimpleMethodsAligner
76,937
AlignmentStrategy (@NotNull ASTNode child) { AlignmentStrategy fieldInColumnsAlignment = myFieldsAligner.getNextChildStrategy(child); AlignmentStrategy oneLineMethodsAlignment = myOneLineMethodsAligner.getNextChildStrategy(child); if (fieldInColumnsAlignment != AlignmentStrategy.getNullStrategy()) { return fieldInColum...
getNextChildStrategy
76,938
TextRange () { return myTextRange; }
getTextRange
76,939
List<Block> () { return mySubBlocks; }
getSubBlocks
76,940
Wrap () { return myWrap; }
getWrap
76,941
Indent () { return myIndentContent; }
getIndent
76,942
Alignment () { return myAlignment; }
getAlignment
76,943
Spacing (Block child1, @NotNull Block child2) { return JavaSpacePropertyProcessor.getSpacing(child2, mySettings, myJavaSettings); }
getSpacing
76,944
String () { ASTNode treeNode = null; Block child = mySubBlocks.get(0); while (treeNode == null) { if (child instanceof AbstractBlock) { treeNode = ((AbstractBlock)child).getNode(); } else if (child instanceof SyntheticCodeBlock) { child = ((SyntheticCodeBlock)child).mySubBlocks.get(0); } else { break; } } final TextRan...
toString
76,945
ASTNode () { return AbstractJavaBlock.getTreeNode(mySubBlocks.get(0)); }
getFirstTreeNode
76,946
void (final ChildAttributes childAttributes) { myChildAttributes = childAttributes; }
setChildAttributes
76,947
ChildAttributes (final int newChildIndex) { if (myChildAttributes != null) { return myChildAttributes; } else { Alignment alignment = null; if (mySubBlocks.size() > newChildIndex) { Block block = mySubBlocks.get(newChildIndex); alignment = block.getAlignment(); } else if (mySubBlocks.size() == newChildIndex) { if (isRP...
getChildAttributes
76,948
boolean (Block sibling) { if (sibling instanceof LeafBlock) { ASTNode node = ((LeafBlock)sibling).getNode(); return node != null && node.getElementType() == JavaTokenType.RPARENTH; } return false; }
isRParenth
76,949
Alignment () { if (mySubBlocks.size() > 1) { Block block = mySubBlocks.get(1); if (isDotFirst(block)) { return block.getAlignment(); } } return null; }
getDotAlignment
76,950
boolean (final Block block) { Block current = block; while (!current.getSubBlocks().isEmpty()) { current = current.getSubBlocks().get(0); } ASTNode node = current instanceof LeafBlock ? ((LeafBlock)current).getNode() : null; return node != null && node.getElementType() == JavaTokenType.DOT; }
isDotFirst
76,951
Block () { Block rightMost = null; List<Block> subBlocks = getSubBlocks(); while (!subBlocks.isEmpty()) { int lastIndex = subBlocks.size() - 1; rightMost = subBlocks.get(lastIndex); subBlocks = rightMost.getSubBlocks(); } return rightMost; }
getRightMostBlock
76,952
boolean () { if (myIsIncomplete) return true; return getSubBlocks().get(getSubBlocks().size() - 1).isIncomplete(); }
isIncomplete
76,953
boolean () { return false; }
isLeaf
76,954
void (final boolean isIncomplete) { myIsIncomplete = isIncomplete; }
setIsIncomplete
76,955
boolean (@NotNull PsiDirectory directory) { Project project = directory.getProject(); PsiDirectoryFactory factory = project.isDisposed() ? null : PsiDirectoryFactory.getInstance(project); return factory != null && factory.isPackage(directory) && factory.isValidPackageName(factory.getQualifiedName(directory, false)); }
isValidPackage
76,956
PsiClass (@NotNull PsiClass psiClass) { return findCompiledElement(myProject, psiClass, scope -> { String fqn = psiClass.getQualifiedName(); return fqn != null ? Arrays.asList(JavaPsiFacade.getInstance(myProject).findClasses(fqn, scope)) : Collections.emptyList(); }); }
getOriginalClass
76,957
PsiJavaModule (@NotNull PsiJavaModule module) { return findCompiledElement(myProject, module, scope -> JavaPsiFacade.getInstance(myProject).findModules(module.getName(), scope)); }
getOriginalModule
76,958
PsiElement (@NotNull PsiJavaFile clsFile) { Function<VirtualFile, VirtualFile> finder = null; Predicate<PsiFile> filter = null; PsiClass[] classes = clsFile.getClasses(); if (classes.length > 0) { String sourceFileName = ((ClsClassImpl)classes[0]).getSourceFileName(); String packageName = clsFile.getPackageName(); Stri...
getClsFileNavigationElement
76,959
Stream<VirtualFile> (VirtualFile file) { Stream<VirtualFile> modelRoots = ProjectFileIndex.getInstance(myProject).getOrderEntriesForFile(file).stream() .filter(entry -> entry instanceof LibraryOrSdkOrderEntry && entry.isValid()) .flatMap(entry -> Stream.of(((LibraryOrSdkOrderEntry)entry).getRootFiles(OrderRootType.SOUR...
findSourceRoots
76,960
LanguageLevel (@Nullable VirtualFile virtualFile) { // For default project, do not look into virtual file system. // It is important for Upsource, where operations are done in default project to // prevent expensive look-up into VFS if (virtualFile == null || myProject.isDefault()) return PsiUtil.getLanguageLevel(myPro...
getEffectiveLanguageLevel
76,961
LanguageLevel (VirtualFile virtualFile) { final ProjectFileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex(); final VirtualFile sourceRoot = index.getSourceRootForFile(virtualFile); VirtualFile folder = virtualFile.isDirectory() ? virtualFile : virtualFile.getParent(); if (sourceRoot != null && sou...
getClassesLanguageLevel
76,962
PsiJavaFile (final VirtualFile dirFile, @Nullable String className) { if (className != null) { final VirtualFile classFile = dirFile.findChild(StringUtil.getQualifiedName(className, StdFileTypes.CLASS.getDefaultExtension())); if (classFile != null) { final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(cl...
getPsiFileInRoot
76,963
ASTNode (@NotNull PsiImportList list, @NotNull PsiImportStatementBase statement) { ImportHelper importHelper = new ImportHelper(JavaCodeStyleSettings.getInstance(statement.getContainingFile())); return importHelper.getDefaultAnchor(list, statement); }
getDefaultImportAnchor
76,964
PsiElement (@NotNull PsiClass aClass, @NotNull PsiMember member) { CodeStyleSettings settings = CodeStyle.getSettings(aClass.getContainingFile()); MemberOrderService service = ApplicationManager.getApplication().getService(MemberOrderService.class); PsiElement anchor = service.getAnchor(member, settings.getCommonSettin...
getDefaultMemberAnchor
76,965
PsiElement (PsiClass aClass, PsiElement anchor) { if (anchor != null && PsiTreeUtil.skipWhitespacesForward(anchor) == aClass.getRBrace()) { // Given member should be inserted as the last child. return aClass.getRBrace(); } return null; }
skipWhitespaces
76,966
void (@NotNull String exceptionName, @NotNull PsiType exceptionType, PsiElement context, @NotNull PsiCatchSection catchSection) { FileTemplate template = FileTemplateManager.getInstance(catchSection.getProject()).getCodeTemplate(JavaTemplateUtil.TEMPLATE_CATCH_BODY); FileTemplate declarationTemplate = FileTemplateManag...
setupCatchBlock
76,967
PsiSymbolReference (@NotNull PsiSnippetAttributeValue value) { return new PsiSymbolReference() { @Override public @NotNull PsiElement getElement() { return value; } @Override public @NotNull TextRange getRangeInElement() { return ((PsiSnippetAttributeValueImpl)value).getValueRange(); } @Override public @NotNull Collect...
getSnippetRegionSymbol
76,968
PsiElement () { return value; }
getElement
76,969
TextRange () { return ((PsiSnippetAttributeValueImpl)value).getValueRange(); }
getRangeInElement
76,970
Pointer<SnippetRegionSymbol> () { return Pointer.fileRangePointer(myFile, myRangeInFile, SnippetRegionSymbol::new); }
createPointer
76,971
TargetPresentation () { VirtualFile virtualFile = myFile.getVirtualFile(); return TargetPresentation.builder(getText()) .locationText(virtualFile.getName(), virtualFile.getFileType().getIcon()) .presentation(); }
computePresentation
76,972
boolean (char flag, PsiElement context) { return switch (flag) { case 'i' -> true; // case-insensitive matching case 'd' -> true; // Unix lines mode case 'm' -> true; // multiline mode case 's' -> true; // dotall mode case 'u' -> true; // Unicode-aware case folding case 'x' -> true; // whitespace and comments in patter...
supportsInlineOptionFlag
76,973
boolean (char c, boolean isInClass) { return false; }
characterNeedsEscaping
76,974
boolean (RegExpNamedCharacter namedCharacter) { return hasAtLeastJdkVersion(namedCharacter, JavaSdkVersion.JDK_1_9); }
supportsNamedCharacters
76,975
boolean () { return false; }
supportsPerl5EmbeddedComments
76,976
boolean () { return true; }
supportsPossessiveQuantifiers
76,977
boolean () { return false; }
supportsPythonConditionalRefs
76,978
boolean (RegExpGroup group) { return group.getType() == RegExpGroup.Type.NAMED_GROUP && hasAtLeastJdkVersion(group, JavaSdkVersion.JDK_1_7); }
supportsNamedGroupSyntax
76,979
boolean (RegExpNamedGroupRef ref) { return ref.isNamedGroupRef() && hasAtLeastJdkVersion(ref, JavaSdkVersion.JDK_1_7); }
supportsNamedGroupRefSyntax
76,980
boolean (String name, @NotNull RegExpGroup group) { for (int i = 0, length = name.length(); i < length; i++) { final char c = name.charAt(i); if (!AsciiUtil.isLetterOrDigit(c)) { return false; } } return true; }
isValidGroupName
76,981
boolean (RegExpChar regExpChar) { return regExpChar.getUnescapedText().charAt(1) == 'x' && hasAtLeastJdkVersion(regExpChar, JavaSdkVersion.JDK_1_7); }
supportsExtendedHexCharacter
76,982
boolean (RegExpBoundary boundary) { return switch (boundary.getType()) { case UNICODE_EXTENDED_GRAPHEME -> hasAtLeastJdkVersion(boundary, JavaSdkVersion.JDK_1_9); case RESET_MATCH -> false; case LINE_START, LINE_END, WORD, NON_WORD, BEGIN, END, END_NO_LINE_TERM, PREVIOUS_MATCH -> true; }; }
supportsBoundary
76,983
boolean (RegExpSimpleClass simpleClass) { return switch (simpleClass.getKind()) { case UNICODE_LINEBREAK, HORIZONTAL_SPACE, NON_HORIZONTAL_SPACE, NON_VERTICAL_SPACE -> hasAtLeastJdkVersion(simpleClass, JavaSdkVersion.JDK_1_8); case VERTICAL_SPACE -> // is vertical tab before jdk 1.8 true; case UNICODE_GRAPHEME -> hasAt...
supportsSimpleClass
76,984
boolean (RegExpChar aChar) { return false; }
supportsLiteralBackspace
76,985
boolean (PsiElement element, JavaSdkVersion version) { return getJavaVersion(element).isAtLeast(version); }
hasAtLeastJdkVersion
76,986
JavaSdkVersion (PsiElement element) { final Module module = ModuleUtilCore.findModuleForPsiElement(element); if (module != null) { final Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); if (sdk != null && sdk.getSdkType() instanceof JavaSdk) { final JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk...
getJavaVersion
76,987
boolean (@NotNull String name) { return isScriptProperty(name) || isBlockProperty(name) || isCategoryProperty(name); }
isValidPropertyName
76,988
boolean (@NotNull String propertyName) { return "script".equalsIgnoreCase(propertyName) || "sc".equalsIgnoreCase(propertyName); }
isScriptProperty
76,989
boolean (@NotNull String propertyName) { return "block".equalsIgnoreCase(propertyName) || "blk".equalsIgnoreCase(propertyName); }
isBlockProperty
76,990
boolean (@NotNull String propertyName) { return "general_category".equalsIgnoreCase(propertyName) || "gc".equalsIgnoreCase(propertyName); }
isCategoryProperty
76,991
boolean (@NotNull String propertyName, @NotNull String value) { if (isScriptProperty(propertyName)) { return isValidUnicodeScript(value); } else if (isBlockProperty(propertyName)) { return isValidUnicodeBlock(value); } else if (isCategoryProperty(propertyName)) { return isValidGeneralCategory(value); } return false; }
isValidPropertyValue
76,992
boolean (String value) { for (int i = 0; i < myNumberOfGeneralCategoryProperties; i++) { if (value.equals(myPropertyNames[i][0])) { return true; } } return false; }
isValidGeneralCategory
76,993
boolean (@NotNull String category) { if (category.startsWith("In")) { return isValidUnicodeBlock(category.substring(2)); } if (category.startsWith("Is")) { category = category.substring(2); if (isValidProperty(category)) return true; // Unicode properties and scripts available since JDK 1.7 category = StringUtil.toUppe...
isValidCategory
76,994
boolean (@NotNull String category) { for (String[] name : myPropertyNames) { if (name[0].equals(category)) { return true; } } return false; }
isValidProperty
76,995
boolean (@NotNull String category) { try { return Character.UnicodeBlock.forName(category) != null; } catch (IllegalArgumentException e) { return false; } }
isValidUnicodeBlock
76,996
boolean (@NotNull String category) { try { return Character.UnicodeScript.forName(category) != null; } catch (IllegalArgumentException ignore) { return false; } }
isValidUnicodeScript
76,997
boolean (RegExpNamedCharacter namedCharacter) { return UnicodeCharacterNames.getCodePoint(namedCharacter.getName()) >= 0; }
isValidNamedCharacter
76,998
Lookbehind (@NotNull RegExpGroup lookbehindGroup) { return Lookbehind.FINITE_REPETITION; }
supportsLookbehind
76,999
Integer (@NotNull RegExpNumber number) { try { return Integer.valueOf(number.getUnescapedText()); } catch (NumberFormatException e) { return null; } }
getQuantifierValue