Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
14,700
int (@NotNull Caret caret) { return caret.hasSelection() ? caret.getSelectionEnd() : caret.getOffset(); }
calcSelectionEnd
14,701
int (@NotNull Editor editor, int startFrom) { final CharSequence text = editor.getDocument().getCharsSequence(); int idEnd = startFrom; int length = text.length(); while (idEnd < length) { char ch = text.charAt(idEnd); if (Character.isJavaIdentifierPart(ch) || ch == '.' || ch == '-' || ch == '@') idEnd++; else if (idEn...
calcDefaultIdentifierEnd
14,702
void (@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) { String originalText = getTextWithEnvVarReplacement(parameters); if (originalText != null) { int lastSlashIndex = originalText.lastIndexOf("/"); if (lastSlashIndex >= 0) { String afterSlash = origin...
addCompletions
14,703
LookupElement (@NotNull File file) { String name = file.getName(); boolean isDirectory = file.isDirectory(); return LookupElementBuilder.create(file, quote(name)) .withIcon(isDirectory ? PlatformIcons.FOLDER_ICON : null) .withInsertHandler(FILE_INSERT_HANDLER); }
createFileLookupElement
14,704
String (@NotNull CompletionParameters parameters) { PsiElement original = parameters.getOriginalPosition(); if (original == null) return null; int textLength = parameters.getOffset() - parameters.getPosition().getTextRange().getStartOffset(); String originalText = original.getText().substring(0, textLength); int offset...
getTextWithEnvVarReplacement
14,705
PsiElement (@NotNull PsiFile file, int offset) { PsiElement e = file.findElementAt(offset); if (!(e instanceof LeafPsiElement leaf)) return null; if (leaf.getElementType() == ShTypes.VAR) return leaf; if (isStringOfVar(leaf)) return leaf.getPrevSibling(); return null; }
getNearestVarIfExist
14,706
boolean (@NotNull LeafPsiElement e) { if (e.getElementType() != ShTypes.CLOSE_QUOTE) return false; PsiElement str = e.getParent(); if (!(str instanceof ShString)) return false; ASTNode[] children = str.getNode().getChildren(null); return children.length == 3 && children[0].getElementType() == ShTypes.OPEN_QUOTE && chil...
isStringOfVar
14,707
String (PsiElement e) { String variable = e.getText(); int index = variable.indexOf("$"); if (index + 1 <= 0) return variable; return variable.substring(index + 1); }
variableText
14,708
void (@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) { if (endsWithDot(parameters)) return; Collection<String> kws = new SmartList<>(); PsiElement original = parameters.getOriginalPosition(); if (original == null || !original.getText().contains("/")) {...
addCompletions
14,709
Collection<String> (PsiElement position) { TextRange posRange = position.getTextRange(); ShFile posFile = (ShFile) position.getContainingFile(); ShCommandsList parent = PsiTreeUtil.getTopmostParentOfType(position, ShCommandsList.class); TextRange range = new TextRange(parent == null ? 0 : parent.getTextRange().getStart...
suggestKeywords
14,710
String (Object o) { if (o instanceof IElementType[] && ((IElementType[]) o).length > 0) return kw2str(((IElementType[]) o)[0]); return o instanceof IElementType ? kw2str(((IElementType) o)) : null; }
convertItem
14,711
String (IElementType o) { return ShTokenTypes.HUMAN_READABLE_KEYWORDS_WITHOUT_TEMPLATES.contains(o) ? o.toString() : null; }
kw2str
14,712
Object2LongMap<String> (PsiBuilder b) { Object2LongMap<String> flags = b.getUserData(MODES_KEY); if (flags == null) b.putUserData(MODES_KEY, flags = new Object2LongOpenHashMap<>()); return flags; }
getParsingModes
14,713
boolean (PsiBuilder b, int level_, String mode, Parser parser) { return withImpl(b, level_, mode, true, parser, parser); }
withOn
14,714
boolean (PsiBuilder b, int level_, String mode, boolean onOff, Parser whenOn, Parser whenOff) { Object2LongMap<String> map = getParsingModes(b); long prev = map.getLong(mode); boolean change = ((prev & 1) == 0) == onOff; if (change) map.put(mode, prev << 1 | (onOff ? 1 : 0)); boolean result = (change ? whenOn : whenOff...
withImpl
14,715
void (IElementType type, int start, int end) { isWhitespaceSkipped[0] = true; }
onSkip
14,716
Lexer (Project project) { return new ShLexer(); }
createLexer
14,717
PsiParser (Project project) { return new ShParser(); }
createParser
14,718
IFileElementType () { return ShFileElementType.INSTANCE; }
getFileNodeType
14,719
TokenSet () { return whitespaceTokens; }
getWhitespaceTokens
14,720
TokenSet () { return commentTokens; }
getCommentTokens
14,721
TokenSet () { return stringLiterals; }
getStringLiteralElements
14,722
PsiElement (ASTNode astNode) { return ShTypes.Factory.createElement(astNode); }
createElement
14,723
PsiFile (@NotNull FileViewProvider fileViewProvider) { return new ShFile(fileViewProvider); }
createFile
14,724
SpaceRequirements (ASTNode left, ASTNode right) { return SpaceRequirements.MAY; }
spaceExistenceTypeBetweenTokens
14,725
String (@NotNull ShFile file) { VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile != null && virtualFile.exists()) { ASTNode shebang = file.getNode().findChildByType(ShTypes.SHEBANG); String prefix = "#!"; if (shebang != null && shebang.getText().startsWith(prefix)) { return shebang.getText().substring(p...
getShebangExecutable
14,726
String (@Nullable String shebang) { if (shebang == null || !shebang.startsWith(PREFIX)) return null; String interpreterPath = getInterpreterPath(shebang.substring(PREFIX.length()).trim()); String lowerCasePath = SystemInfo.isFileSystemCaseSensitive ? interpreterPath.toLowerCase(Locale.ENGLISH) : interpreterPath; return...
detectInterpreter
14,727
String (@NotNull String shebang) { int index = shebang.indexOf(" "); @NonNls String possiblePath = index < 0 ? shebang : shebang.substring(0, index); if (!possiblePath.equals("/usr/bin/env")) return possiblePath; String interpreterPath = shebang.substring(index + 1); index = interpreterPath.indexOf(" "); return index <...
getInterpreterPath
14,728
String (@NotNull String name) { String ext = PathUtil.getFileExtension(name); return ext != null && KNOWN_EXTENSIONS.contains(ext) ? name.substring(0, name.length() - ext.length() - 1) : name; }
trimKnownExt
14,729
String () { return PropertiesComponent.getInstance().getValue(SHELLCHECK_PATH, ""); }
getShellcheckPath
14,730
void (@Nullable String path) { if (StringUtil.isNotEmpty(path)) PropertiesComponent.getInstance().setValue(SHELLCHECK_PATH, path); }
setShellcheckPath
14,731
String () { return PropertiesComponent.getInstance().getValue(SHFMT_PATH, ""); }
getShfmtPath
14,732
void (@Nullable String path) { if (StringUtil.isNotEmpty(path)) PropertiesComponent.getInstance().setValue(SHFMT_PATH, path); }
setShfmtPath
14,733
String () { return PropertiesComponent.getInstance().getValue(SHELLCHECK_SKIPPED_VERSION, ""); }
getSkippedShellcheckVersion
14,734
void (@NotNull String version) { if (StringUtil.isNotEmpty(version)) PropertiesComponent.getInstance().setValue(SHELLCHECK_SKIPPED_VERSION, version); }
setSkippedShellcheckVersion
14,735
String () { return PropertiesComponent.getInstance().getValue(SHFMT_SKIPPED_VERSION, ""); }
getSkippedShfmtVersion
14,736
void (@NotNull String version) { if (StringUtil.isNotEmpty(version)) PropertiesComponent.getInstance().setValue(SHFMT_SKIPPED_VERSION, version); }
setSkippedShfmtVersion
14,737
boolean (@NotNull TemplateActionContext templateActionContext) { PsiFile psiFile = templateActionContext.getFile(); if (psiFile instanceof ShFile) { PsiElement element = psiFile.findElementAt(templateActionContext.getStartOffset()); if (element == null) return true; return element.getNode().getElementType() != ShTokenT...
isInContext
14,738
Tokenizer (PsiElement element) { final ASTNode node = element.getNode(); if (node != null && TOKENS_WITH_TEXT.contains(node.getElementType())) return TEXT_TOKENIZER; if (element instanceof PsiNameIdentifierOwner) return ShIdentifierOwnerTokenizer.INSTANCE; return EMPTY_TOKENIZER; }
getTokenizer
14,739
void (@NotNull PsiNameIdentifierOwner element, @NotNull TokenConsumer consumer) { PsiElement identifier = element.getNameIdentifier(); if (identifier == null) { return; } PsiElement parent = element; final TextRange range = identifier.getTextRange(); if (range.isEmpty()) return; int offset = range.getStartOffset() - pa...
tokenize
14,740
CodeInsightActionHandler () { return this; }
getHandler
14,741
void (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { TemplateManager templateManager = TemplateManager.getInstance(project); Template template = TemplateSettings.getInstance().getTemplateById("shell_until"); if (template == null) return; moveAtNewLineIfNeeded(editor); templateManager.startTe...
invoke
14,742
CodeInsightActionHandler () { return this; }
getHandler
14,743
void (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { TemplateManager templateManager = TemplateManager.getInstance(project); Template template = TemplateSettings.getInstance().getTemplateById("shell_for"); if (template == null) return; moveAtNewLineIfNeeded(editor); templateManager.startTemp...
invoke
14,744
CodeInsightActionHandler () { return this; }
getHandler
14,745
void (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { TemplateManager templateManager = TemplateManager.getInstance(project); Template template = TemplateSettings.getInstance().getTemplateById("shell_while"); if (template == null) return; moveAtNewLineIfNeeded(editor); templateManager.startTe...
invoke
14,746
boolean (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { return file.getLanguage().is(ShLanguage.INSTANCE); }
isValidForFile
14,747
void (@NotNull Editor editor) { Document document = editor.getDocument(); Caret caret = editor.getCaretModel().getPrimaryCaret(); int line = caret.getLogicalPosition().line; if (DocumentUtil.isLineEmpty(document, line)) return; int lineEndOffset = DocumentUtil.getLineEndOffset(caret.getOffset(), document); caret.moveTo...
moveAtNewLineIfNeeded
14,748
EventLogGroup () { return GROUP; }
getGroup
14,749
String (@NotNull Project project, @NotNull Editor editor, @Nullable Language language, int offset) { if (offset > 0) { ShSemanticEditorPosition position = getPosition(editor, offset - 1); if (position.isAt(ShTypes.LINEFEED) || position.isAt(ShTokenTypes.WHITESPACE)) { moveAtEndOfPreviousLine(position); if (position.isA...
getLineIndent
14,750
boolean (@Nullable Language language) { return language instanceof ShLanguage; }
isSuitableFor
14,751
boolean (@NotNull Editor editor, ShSemanticEditorPosition position) { CharSequence docChars = editor.getDocument().getCharsSequence(); int lineStart = CharArrayUtil.shiftBackwardUntil(docChars, position.getStartOffset(), "\n") + 1; if (lineStart >= 0) { ShSemanticEditorPosition possiblePatternPosition = getPosition(edi...
isInCasePattern
14,752
void (ShSemanticEditorPosition position) { position.moveBeforeOptionalMix(ShTokenTypes.WHITESPACE); if (position.isAt(ShTypes.LINEFEED)) { position.moveBefore(); position.moveBeforeOptionalMix(ShTokenTypes.WHITESPACE); } }
moveAtEndOfPreviousLine
14,753
String (@NotNull Editor editor, int offset, boolean shouldExpand) { CodeStyleSettings settings = CodeStyle.getSettings(editor); CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(ShFileType.INSTANCE); CharSequence docChars = editor.getDocument().getCharsSequence(); String baseIndent = ""; i...
getIndentString
14,754
ShSemanticEditorPosition (@NotNull Editor editor, int offset) { return ShSemanticEditorPosition.createEditorPosition(editor, offset); }
getPosition
14,755
void (@Nullable Project project, @NotNull Runnable onSuccess, @NotNull Runnable onFailure) { download(project, onSuccess, onFailure, false); }
download
14,756
void (@Nullable Project project, @NotNull Runnable onSuccess, @NotNull Runnable onFailure, boolean withReplace) { File directory = new File(DOWNLOAD_PATH); if (!directory.exists()) { //noinspection ResultOfMethodCallIgnored directory.mkdirs(); } File formatter = new File(DOWNLOAD_PATH + File.separator + SHFMT + (System...
download
14,757
void (@NotNull ProgressIndicator indicator) { try { List<Pair<File, DownloadableFileDescription>> pairs = downloader.download(new File(DOWNLOAD_PATH)); Pair<File, DownloadableFileDescription> first = ContainerUtil.getFirstItem(pairs); File file = first != null ? first.first : null; if (file != null) { FileUtil.setExecu...
run
14,758
void (@NotNull File formatter, @NotNull Runnable onSuccess, @NotNull Runnable onFailure) { try { String formatterPath = formatter.getCanonicalPath(); if (ShSettings.getShfmtPath().equals(formatterPath)) { LOG.info("Shfmt formatter already downloaded"); } else { ShSettings.setShfmtPath(formatterPath); } if (!formatter.c...
setupFormatterPath
14,759
boolean (@NotNull File formatter, @NotNull File oldFormatter, @NotNull Runnable onFailure) { LOG.info("Rename formatter to the temporary filename"); try { FileUtil.rename(formatter, oldFormatter); } catch (IOException e) { LOG.info("Can't rename formatter to the temporary filename", e); ApplicationManager.getApplicatio...
renameOldFormatter
14,760
void (@NotNull File formatter, @NotNull File oldFormatter) { LOG.info("Update failed, rollback"); try { FileUtil.rename(oldFormatter, formatter); } catch (IOException e) { LOG.info("Can't rollback formatter after failed update", e); } FileUtil.delete(oldFormatter); }
rollbackToOldFormatter
14,761
boolean (@Nullable String path) { if (path == null) return false; if (ShSettings.I_DO_MIND_SUPPLIER.get().equals(path)) return true; File file = new File(path); if (!file.canExecute()) return false; return file.getName().contains(SHFMT); }
isValidPath
14,762
void (@NotNull Project project) { Application application = ApplicationManager.getApplication(); if (application.getUserData(UPDATE_NOTIFICATION_SHOWN) != null) return; application.putUserData(UPDATE_NOTIFICATION_SHOWN, true); if (application.isDispatchThread()) { application.executeOnPooledThread(() -> checkForUpdateI...
checkShfmtForUpdate
14,763
void (@NotNull Project project) { ApplicationManager.getApplication().assertIsNonDispatchThread(); if (!isNewVersionAvailable()) return; Notification notification = NOTIFICATION_GROUP.createNotification(message("sh.shell.script"), message("sh.fmt.update.question"), NotificationType.INFORMATION); notification.setSuggest...
checkForUpdateInBackgroundThread
14,764
boolean () { String path = ShSettings.getShfmtPath(); if (ShSettings.I_DO_MIND_SUPPLIER.get().equals(path)) return false; File file = new File(path); if (!file.canExecute()) return false; if (!file.getName().contains(SHFMT)) return false; try { GeneralCommandLine commandLine = new GeneralCommandLine().withExePath(path)...
isNewVersionAvailable
14,765
String () { StringBuilder baseUrl = new StringBuilder("https://github.com/mvdan/sh/releases/download/") .append(SHFMT_VERSION) .append('/') .append(SHFMT) .append('_') .append(SHFMT_VERSION); if (SystemInfo.isMac) { baseUrl.append(MAC); } else if (SystemInfo.isLinux) { baseUrl.append(LINUX); } else if (SystemInfo.isWin...
getShfmtDistributionLink
14,766
void () { statusBarUpdated = false; }
beforeAllDocumentsSaving
14,767
void (@NotNull Document document) { VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document); if (virtualFile == null) return; Project project = ProjectUtil.guessProjectForFile(virtualFile); if (project == null) return; PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile); if (!(...
beforeDocumentSaving
14,768
void (@NotNull Project project) { ApplicationManager.getApplication().invokeLater(() -> { IdeFrame frame = WindowManager.getInstance().getIdeFrame(project); StatusBar statusBar = frame != null ? frame.getStatusBar() : null; StatusBarWidget widget = statusBar != null ? statusBar.getWidget(StatusBar.StandardWidgets.LINE_...
updateStatusBar
14,769
ShSemanticEditorPosition (@NotNull Editor editor, int offset) { return new ShSemanticEditorPosition(editor, offset); }
createEditorPosition
14,770
boolean (@NotNull PsiFile file) { return file instanceof ShFile; }
canFormat
14,771
Set<Feature> () { return FEATURES; }
getFeatures
14,772
String () { return NOTIFICATION_GROUP_ID; }
getNotificationGroupId
14,773
String () { return message("sh.shell.script"); }
getName
14,774
void () { handler.addProcessListener(new CapturingProcessAdapter() { @Override public void processTerminated(@NotNull ProcessEvent event) { int exitCode = event.getExitCode(); if (exitCode == 0) { request.onTextReady(getOutput().getStdout()); } else { request.onError(message("sh.shell.script"), getOutput().getStderr())...
run
14,775
void (@NotNull ProcessEvent event) { int exitCode = event.getExitCode(); if (exitCode == 0) { request.onTextReady(getOutput().getStdout()); } else { request.onError(message("sh.shell.script"), getOutput().getStderr()); } }
processTerminated
14,776
boolean () { handler.destroyProcess(); return true; }
cancel
14,777
boolean () { return true; }
isRunUnderProgress
14,778
String () { return getText(); }
getFamilyName
14,779
String () { return ShBundle.message("sh.rename.all.occurrences"); }
getText
14,780
boolean () { return false; }
startInWriteAction
14,781
boolean (@NotNull Project project, Editor editor, PsiFile file) { return ShOccurrencesHighlightingSuppressor.isOccurrencesHighlightingEnabled(editor, file) && ShRenameAllOccurrencesHandler.INSTANCE.isEnabled(editor, editor.getCaretModel().getPrimaryCaret(), null); }
isAvailable
14,782
ShortcutSet () { return CommonShortcuts.getRename(); }
getShortcut
14,783
ShTextRenameRefactoring (@NotNull Editor editor, @NotNull Project project, @NotNull String occurrenceText, @NotNull Collection<TextRange> occurrenceRanges, @NotNull TextRange occurrenceRangeAtCaret) { PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (psiFile != null) { retu...
create
14,784
void () { int offset = myEditor.getCaretModel().getOffset(); myCaretRangeMarker = myEditor.getDocument().createRangeMarker(offset, offset); myCaretRangeMarker.setGreedyToLeft(true); myCaretRangeMarker.setGreedyToRight(true); }
createCaretRangeMarker
14,785
void (TemplateBuilderImpl builder) { int caretOffset = myEditor.getCaretModel().getOffset(); TextRange range = myPsiFile.getTextRange(); assert range != null; RangeMarker rangeMarker = myEditor.getDocument().createRangeMarker(range); Template template = builder.buildInlineTemplate(); template.setToShortenLongNames(fals...
startTemplate
14,786
void (@NotNull Template template) { if (myHighlighters != null) { // can be null if finish is called during testing Map<TextRange, TextAttributes> rangesToHighlight = new HashMap<>(); TemplateState templateState = TemplateManagerImpl.getTemplateState(myEditor); if (templateState != null) { EditorColorsManager colorsMan...
highlightTemplateVariables
14,787
TextAttributes (@NotNull EditorColorsManager colorsManager, @NotNull String segmentName) { if (segmentName.equals(PRIMARY_VARIABLE_NAME)) { return colorsManager.getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES); } if (segmentName.equals(OTHER_VARIABLE_NAME)) { return colorsManager.getGlobalSc...
getAttributes
14,788
void (@NotNull Map<TextRange, TextAttributes> ranges, @NotNull Collection<RangeHighlighter> highlighters) { HighlightManager highlightManager = HighlightManager.getInstance(myProject); for (Map.Entry<TextRange, TextAttributes> entry : ranges.entrySet()) { TextRange range = entry.getKey(); TextAttributes attributes = en...
addHighlights
14,789
void () { if (myHighlighters != null) { if (!myProject.isDisposed()) { HighlightManager highlightManager = HighlightManager.getInstance(myProject); for (RangeHighlighter highlighter : myHighlighters) { highlightManager.removeSegmentHighlighter(myEditor, highlighter); } } myHighlighters = null; } }
clearHighlights
14,790
void (int offset) { Runnable runnable = () -> myEditor.getCaretModel().moveToOffset(restoreCaretOffset(offset)); LookupImpl lookup = (LookupImpl) LookupManager.getActiveLookup(myEditor); if (lookup != null && lookup.getLookupStart() <= (restoreCaretOffset(offset))) { lookup.setLookupFocusDegree(LookupFocusDegree.UNFOCU...
restoreOldCaretPositionAndSelection
14,791
int (int offset) { return myCaretRangeMarker.isValid() ? myCaretRangeMarker.getEndOffset() : offset; }
restoreCaretOffset
14,792
Result (ExpressionContext context) { Editor editor = context.getEditor(); if (editor != null) { TextResult insertedValue = context.getVariableValue(PRIMARY_VARIABLE_NAME); if (insertedValue != null && !insertedValue.getText().isEmpty()) { return insertedValue; } } return new TextResult(myInitialText); }
calculateResult
14,793
LookupElement[] (ExpressionContext context) { return LookupElement.EMPTY_ARRAY; }
calculateLookupItems
14,794
void (@NotNull TemplateState templateState, Template template) { clearHighlights(); }
beforeTemplateFinished
14,795
void (Template template) { clearHighlights(); }
templateCancelled
14,796
boolean (@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) { return editor.getProject() != null; }
isEnabledForCaret
14,797
void (@NotNull final Editor editor, @Nullable Caret c, DataContext dataContext) { Caret caret = editor.getCaretModel().getPrimaryCaret(); SelectionModel selectionModel = editor.getSelectionModel(); boolean hasSelection = caret.hasSelection(); TextRange occurrenceAtCaret = hasSelection ? new TextRange(selectionModel.get...
doExecute
14,798
RegistryValue () { return Registry.get("inplace.rename.segments.limit"); }
getMaxInplaceRenameSegmentsRegistryValue
14,799
int () { try { return getMaxInplaceRenameSegmentsRegistryValue().asInteger(); } catch (MissingResourceException e) { return -1; } }
getMaxInplaceRenameSegments