Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
27,900 | void (@Nullable TextMateLexer.Token token, int fallbackOffset) { if (token != null) { myTokenType = token.scope == TextMateScope.WHITESPACE ? TokenType.WHITE_SPACE : new TextMateElementType(token.scope); myTokenStart = token.startOffset; myTokenEnd = Math.min(token.endOffset, myEndOffset); myCurrentOffset = token.endOffset; myRestartable = token.restartable; } else { myTokenType = null; myTokenStart = fallbackOffset; myTokenEnd = fallbackOffset; myCurrentOffset = fallbackOffset; myRestartable = true; } } | updateState |
27,901 | int (@NotNull IElementType tokenType, int state, boolean isRestartableState) { if (tokenType instanceof TextMateElementType) { synchronized (tokenTypeMap) { if (tokenTypeMap.containsKey(tokenType)) { return tokenTypeMap.getInt(tokenType) * (isRestartableState ? 1 : -1); } int data = tokenTypes.size() + 1; tokenTypes.add((TextMateElementType)tokenType); tokenTypeMap.put((TextMateElementType)tokenType, data); return isRestartableState ? data : -data; } } return 0; } | packData |
27,902 | IElementType (int data) { return data != 0 ? tokenTypes.get(Math.abs(data) - 1) : new TextMateElementType(TextMateScope.EMPTY); } | unpackTokenFromData |
27,903 | DataStorage () { return new TextMateLexerDataStorage(myData, tokenTypeMap, tokenTypes); } | copy |
27,904 | DataStorage () { return new TextMateLexerDataStorage(tokenTypeMap, tokenTypes); } | createStorage |
27,905 | TextMateScope () { return myScope; } | getScope |
27,906 | int () { return getScope().hashCode(); } | hashCode |
27,907 | String () { return myScope.toString(); } | toString |
27,908 | boolean (Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; return ((TextMateElementType)o).getScope().equals(getScope()); } | equals |
27,909 | Tokenizer (PsiElement element) { return TEXT_TOKENIZER; } | getTokenizer |
27,910 | Lexer (Project project) { return new EmptyLexer(); } | createLexer |
27,911 | PsiParser (Project project) { return new TextMateParser(); } | createParser |
27,912 | IFileElementType () { return FILE_ELEMENT_TYPE; } | getFileNodeType |
27,913 | TokenSet () { return TokenSet.EMPTY; } | getCommentTokens |
27,914 | TokenSet () { return TokenSet.EMPTY; } | getStringLiteralElements |
27,915 | PsiElement (ASTNode node) { return new TextMatePsiElement(node.getElementType()); } | createElement |
27,916 | PsiFile (@NotNull FileViewProvider viewProvider) { return new TextMateFile(viewProvider); } | createFile |
27,917 | SpaceRequirements (ASTNode left, ASTNode right) { return SpaceRequirements.MAY; } | spaceExistenceTypeBetweenTokens |
27,918 | FileType () { return TextMateFileType.INSTANCE; } | getFileType |
27,919 | ASTNode (@NotNull IElementType root, PsiBuilder builder) { PsiBuilder.Marker mark = builder.mark(); while (!builder.eof()) { builder.advanceLexer(); } mark.done(root); return builder.getTreeBuilt(); } | parse |
27,920 | Result (char c, @NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file, @NotNull FileType fileType) { if (fileType == TextMateFileType.INSTANCE) { if (c == '\'' || c == '"' || c == '`') { if (!CodeInsightSettings.getInstance().AUTOINSERT_PAIR_QUOTE) { return Result.CONTINUE; } } else if (!CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET) { return Result.CONTINUE; } final int offset = editor.getCaretModel().getOffset(); @Nullable TextMateScope scopeSelector = TextMateEditorUtils.getCurrentScopeSelector((EditorEx)editor); final Document document = editor.getDocument(); final TextMateAutoClosingPair pairForRightChar = findSingleCharSmartTypingPair(c, scopeSelector); if (pairForRightChar != null) { if (offset < document.getTextLength() && document.getCharsSequence().charAt(offset) == c) { EditorModificationUtil.moveCaretRelatively(editor, 1); return Result.STOP; } } } return Result.CONTINUE; } | beforeCharTyped |
27,921 | Result (char c, @NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { if (file.getFileType() == TextMateFileType.INSTANCE) { if (c == '\'' || c == '"' || c == '`') { if (!CodeInsightSettings.getInstance().AUTOINSERT_PAIR_QUOTE) { return Result.CONTINUE; } } else if (!CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET) { return Result.CONTINUE; } final int offset = editor.getCaretModel().getOffset(); @Nullable TextMateScope scopeSelector = TextMateEditorUtils.getCurrentScopeSelector((EditorEx)editor); CharSequence sequence = editor.getDocument().getCharsSequence(); final TextMateAutoClosingPair autoInsertingPair = findAutoInsertingPair(offset, sequence, scopeSelector); if (autoInsertingPair != null) { int rightBraceEndOffset = offset + autoInsertingPair.getRight().length(); // has a right brace already if (rightBraceEndOffset < sequence.length() && StringUtil.equals(autoInsertingPair.getRight(), sequence.subSequence(offset, rightBraceEndOffset))) { return Result.CONTINUE; } if (StringUtil.equals(autoInsertingPair.getLeft(), autoInsertingPair.getRight())) { // letter on the right if (offset < sequence.length() && Character.isLetterOrDigit(sequence.charAt(offset))) { return Result.CONTINUE; } int leftBraceStartOffset = offset - autoInsertingPair.getLeft().length(); // letter on the left if (leftBraceStartOffset > 0 && Character.isLetterOrDigit(sequence.charAt(leftBraceStartOffset - 1))) { return Result.CONTINUE; } } EditorModificationUtilEx.insertStringAtCaret(editor, autoInsertingPair.getRight().toString(), true, false); return Result.STOP; } } return Result.CONTINUE; } | charTyped |
27,922 | TextMateAutoClosingPair (char closingChar, @Nullable TextMateScope currentSelector) { if (!TextMateService.getInstance().getPreferenceRegistry().isPossibleRightSmartTypingBrace(closingChar)) { return null; } Set<TextMateAutoClosingPair> pairs = getSmartTypingPairs(currentSelector); for (TextMateAutoClosingPair pair : pairs) { if (pair.getRight().length() == 1 && pair.getRight().charAt(0) == closingChar) { return pair; } } return null; } | findSingleCharSmartTypingPair |
27,923 | TextMateAutoClosingPair (int offset, @NotNull CharSequence fileText, @Nullable TextMateScope currentScope) { if (offset == 0 || !TextMateService.getInstance().getPreferenceRegistry().isPossibleLeftSmartTypingBrace(fileText.charAt(offset - 1))) { return null; } Set<TextMateAutoClosingPair> pairs = getSmartTypingPairs(currentScope); for (TextMateAutoClosingPair pair : pairs) { int startOffset = offset - pair.getLeft().length(); if (startOffset >= 0 && StringUtil.equals(pair.getLeft(), fileText.subSequence(startOffset, offset))) { return pair; } } return null; } | findAutoInsertingPair |
27,924 | int (@NotNull IElementType tokenType) { return BraceMatchingUtil.UNDEFINED_TOKEN_GROUP; } | getBraceTokenGroupId |
27,925 | boolean (@NotNull HighlighterIterator iterator, @NotNull CharSequence fileText, @NotNull FileType fileType) { if (iterator.getStart() == iterator.getEnd()) return false; IElementType tokenType = iterator.getTokenType(); TextMateScope currentSelector = tokenType instanceof TextMateElementType ? ((TextMateElementType)tokenType).getScope() : null; return TextMateEditorUtils.findRightHighlightingPair(iterator.getStart(), fileText, currentSelector) != null; } | isLBraceToken |
27,926 | boolean (@NotNull HighlighterIterator iterator, @NotNull CharSequence fileText, @NotNull FileType fileType) { if (iterator.getEnd() == iterator.getStart()) return false; IElementType tokenType = iterator.getTokenType(); TextMateScope currentSelector = tokenType instanceof TextMateElementType ? ((TextMateElementType)tokenType).getScope() : null; return TextMateEditorUtils.findLeftHighlightingPair(iterator.getEnd(), fileText, currentSelector) != null; } | isRBraceToken |
27,927 | boolean (@NotNull IElementType tokenType, @NotNull IElementType tokenType2) { return true; } | isPairBraces |
27,928 | boolean (@NotNull HighlighterIterator iterator, @NotNull CharSequence text, @NotNull FileType fileType) { return false; } | isStructuralBrace |
27,929 | IElementType (@NotNull IElementType type) { return null; } | getOppositeBraceTokenType |
27,930 | boolean (@NotNull IElementType lbraceType, @Nullable IElementType contextType) { return true; } | isPairedBracesAllowedBeforeType |
27,931 | int (@NotNull PsiFile file, int openingBraceOffset) { return openingBraceOffset; } | getCodeConstructStart |
27,932 | void (@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) { String prefix = CompletionUtil.findJavaIdentifierPrefix(parameters); CompletionResultSet resultSetWithPrefix = result.withPrefixMatcher(prefix); WordCompletionContributor.addWordCompletionVariants(resultSetWithPrefix, parameters, Collections.emptySet(), true); } | addCompletions |
27,933 | Commenter (@NotNull PsiFile file, @NotNull Editor editor, @NotNull Language lineStartLanguage, @NotNull Language lineEndLanguage) { final TextMateScope actualScope = TextMateEditorUtils.getCurrentScopeSelector((EditorEx)editor); if (actualScope == null) { return null; } ShellVariablesRegistry registry = TextMateService.getInstance().getShellVariableRegistry(); final TextMateCommentPrefixes prefixes = PreferencesReadUtil.readCommentPrefixes(registry, actualScope); return (prefixes.getBlockCommentPair() != null || prefixes.getLineCommentPrefix() != null) ? new MyCommenter(prefixes) : null; } | getLineCommenter |
27,934 | boolean (@NotNull PsiFile file, @NotNull FileViewProvider viewProvider) { return file.getFileType() == TextMateFileType.INSTANCE; } | canProcess |
27,935 | String () { return null; } | getLineCommentPrefix |
27,936 | String () { return ""; } | getBlockCommentPrefix |
27,937 | String () { return ""; } | getBlockCommentSuffix |
27,938 | String () { return null; } | getCommentedBlockCommentPrefix |
27,939 | String () { return null; } | getCommentedBlockCommentSuffix |
27,940 | String () { return myLinePrefix; } | getLineCommentPrefix |
27,941 | String () { return myBlockPrefixes != null ? myBlockPrefixes.getPrefix() : null; } | getBlockCommentPrefix |
27,942 | String () { return myBlockPrefixes != null ? myBlockPrefixes.getSuffix() : null; } | getBlockCommentSuffix |
27,943 | String () { return null; } | getCommentedBlockCommentPrefix |
27,944 | String () { return null; } | getCommentedBlockCommentSuffix |
27,945 | TextMateScope (@NotNull EditorEx editor) { TextMateScope result = getCurrentScopeFromEditor(editor); //retrieve root scope of file if (result == null) { final VirtualFile file = editor.getVirtualFile(); if (file != null) { final TextMateLanguageDescriptor languageDescriptor = TextMateService.getInstance().getLanguageDescriptorByFileName(file.getName()); if (languageDescriptor != null) { return new TextMateScope(languageDescriptor.getScopeName(), null); } } } return result; } | getCurrentScopeSelector |
27,946 | TextMateScope (@NotNull EditorEx editor) { final EditorHighlighter highlighter = editor.getHighlighter(); SelectionModel selection = editor.getSelectionModel(); final int offset = selection.hasSelection() ? selection.getSelectionStart() : editor.getCaretModel().getOffset(); final HighlighterIterator iterator = highlighter.createIterator(offset); TextMateScope result = null; if (offset != 0 || !iterator.atEnd()) { IElementType tokenType = iterator.getTokenType(); result = tokenType instanceof TextMateElementType ? ((TextMateElementType)tokenType).getScope() : null; } return result; } | getCurrentScopeFromEditor |
27,947 | TextMateBracePair (int leftBraceStartOffset, @NotNull CharSequence fileText, @Nullable TextMateScope currentScope) { if (!TextMateService.getInstance().getPreferenceRegistry().isPossibleLeftHighlightingBrace(fileText.charAt(leftBraceStartOffset))) { return null; } Set<TextMateBracePair> pairs = getAllPairsForMatcher(currentScope); for (TextMateBracePair pair : pairs) { int endOffset = leftBraceStartOffset + pair.getLeft().length(); if (endOffset < fileText.length() && StringUtil.equals(pair.getLeft(), fileText.subSequence(leftBraceStartOffset, endOffset))) { return pair; } } return null; } | findRightHighlightingPair |
27,948 | TextMateBracePair (int rightBraceEndOffset, @NotNull CharSequence fileText, @Nullable TextMateScope currentSelector) { if (!TextMateService.getInstance().getPreferenceRegistry().isPossibleRightHighlightingBrace(fileText.charAt(rightBraceEndOffset - 1))) { return null; } Set<TextMateBracePair> pairs = getAllPairsForMatcher(currentSelector); for (TextMateBracePair pair : pairs) { int startOffset = rightBraceEndOffset - pair.getRight().length(); if (startOffset >= 0 && StringUtil.equals(pair.getRight(), fileText.subSequence(startOffset, rightBraceEndOffset))) { return pair; } } return null; } | findLeftHighlightingPair |
27,949 | Set<TextMateBracePair> (@Nullable TextMateScope selector) { if (selector == null) { return Constants.DEFAULT_HIGHLIGHTING_BRACE_PAIRS; } Set<TextMateBracePair> result = new HashSet<>(); List<Preferences> preferencesForSelector = TextMateService.getInstance().getPreferenceRegistry().getPreferences(selector); for (Preferences preferences : preferencesForSelector) { final Set<TextMateBracePair> highlightingPairs = preferences.getHighlightingPairs(); if (highlightingPairs != null) { if (highlightingPairs.isEmpty()) { // smart typing pairs can be defined in preferences but can be empty (in order to disable smart typing completely) return Collections.emptySet(); } result.addAll(highlightingPairs); } } return result; } | getAllPairsForMatcher |
27,950 | Set<TextMateAutoClosingPair> (@Nullable TextMateScope currentScope) { if (currentScope == null) { return Constants.DEFAULT_SMART_TYPING_BRACE_PAIRS; } List<Preferences> preferencesForSelector = TextMateService.getInstance().getPreferenceRegistry().getPreferences(currentScope); final HashSet<TextMateAutoClosingPair> result = new HashSet<>(); for (Preferences preferences : preferencesForSelector) { final @Nullable Set<TextMateAutoClosingPair> smartTypingPairs = preferences.getSmartTypingPairs(); if (smartTypingPairs != null) { if (smartTypingPairs.isEmpty()) { // smart typing pairs defined in preferences and can be empty (in order to disable smart typing completely) return Collections.emptySet(); } result.addAll(smartTypingPairs); } } return result; } | getSmartTypingPairs |
27,951 | void (@NotNull CharSequence fileName, @NotNull Processor<? super CharSequence> processor) { if (!processor.process(fileName)) { return; } int index = StringUtil.indexOf(fileName, '.'); while (index >= 0) { CharSequence extension = fileName.subSequence(index + 1, fileName.length()); if (extension.isEmpty()) break; if (!processor.process(extension)) { return; } index = StringUtil.indexOf(fileName, '.', index + 1); } } | processExtensions |
27,952 | String (@NotNull CustomTemplateCallback callback) { CharSequence result = ""; Editor editor = callback.getEditor(); CharSequence sequence = editor.getDocument().getImmutableCharSequence(); Collection<TextMateSnippet> availableSnippets = getAvailableSnippets(editor); for (TextMateSnippet snippet : availableSnippets) { CharSequence prefix = getPrefixForSnippet(sequence, editor.getCaretModel().getOffset(), snippet); if (prefix != null && prefix.length() > result.length()) { result = prefix; } } return !availableSnippets.isEmpty() ? result.toString() : null; } | computeTemplateKeyWithoutContextChecking |
27,953 | String (@NotNull CustomTemplateCallback callback) { int offset = callback.getEditor().getCaretModel().getOffset(); CharSequence charsSequence = callback.getEditor().getDocument().getImmutableCharSequence(); for (TextMateSnippet snippet : getAvailableSnippets(callback.getEditor())) { String key = snippet.getKey(); if (key.length() <= offset && StringUtil.equals(key, charsSequence.subSequence(offset - key.length(), offset))) { return key; } } return null; } | computeTemplateKey |
27,954 | void (@NotNull String key, @NotNull CustomTemplateCallback callback) { //todo parse content and build template/templates TextMateService service = TextMateService.getInstance(); if (service != null) { SnippetsRegistry snippetsRegistry = service.getSnippetRegistry(); Editor editor = callback.getEditor(); TextMateScope scope = TextMateEditorUtils.getCurrentScopeSelector(((EditorEx)editor)); Collection<TextMateSnippet> snippets = snippetsRegistry.findSnippet(key, scope); if (snippets.size() > 1) { LookupImpl lookup = (LookupImpl)LookupManager.getInstance(callback.getProject()) .createLookup(editor, LookupElement.EMPTY_ARRAY, "", new LookupArranger.DefaultArranger()); for (TextMateSnippet snippet : snippets) { lookup.addItem(new TextMateSnippetLookupElement(snippet), new PlainPrefixMatcher(key)); } Project project = editor.getProject(); lookup.addLookupListener(new MyLookupAdapter(project, editor, callback.getFile())); lookup.refreshUi(false, true); lookup.showLookup(); } else if (snippets.size() == 1) { TextMateSnippet snippet = ContainerUtil.getFirstItem(snippets); assert snippet != null; expand(editor, snippet); } } } | expand |
27,955 | void (@NotNull String selection, @NotNull CustomTemplateCallback callback) { // todo } | wrap |
27,956 | void (CompletionParameters parameters, CompletionResultSet result) { int endOffset = parameters.getOffset(); Editor editor = parameters.getEditor(); CharSequence sequence = editor.getDocument().getImmutableCharSequence(); for (TextMateSnippet snippet : getAvailableSnippets(editor)) { CharSequence prefix = getPrefixForSnippet(sequence, endOffset, snippet); if (prefix != null && StringUtil.startsWith(snippet.getKey(), prefix)) { result.withPrefixMatcher(result.getPrefixMatcher().cloneWithPrefix(prefix.toString())) .addElement(new TextMateSnippetLookupElement(snippet)); } } } | addCompletions |
27,957 | boolean (@NotNull CustomTemplateCallback callback, int offset, boolean wrapping) { PsiFile file = callback.getFile(); return file instanceof TextMateFile && ApplicationManager.getApplication().isInternal(); } | isApplicable |
27,958 | boolean (@NotNull CustomTemplateCallback callback, int offset) { return isApplicable(callback, offset, false); } | hasCompletionItem |
27,959 | char () { // todo settings return '\t'; } | getShortcut |
27,960 | boolean () { return true; } | supportsWrapping |
27,961 | String () { return TextMateBundle.message("textmate.live.template.name"); } | getTitle |
27,962 | Collection<TextMateSnippet> (@NotNull Editor editor) { TextMateService service = TextMateService.getInstance(); if (service != null) { SnippetsRegistry snippetsRegistry = service.getSnippetRegistry(); TextMateScope scope = TextMateEditorUtils.getCurrentScopeSelector(((EditorEx)editor)); return snippetsRegistry.getAvailableSnippets(scope); } return Collections.emptyList(); } | getAvailableSnippets |
27,963 | CharSequence (@NotNull CharSequence sequence, int offset, @NotNull TextMateSnippet snippet) { int startOffset = Math.max(offset - snippet.getKey().length(), 0); for (int i = startOffset; i <= offset; i++) { if (i == 0 || StringUtil.isWhiteSpace(sequence.charAt(i - 1))) { CharSequence prefix = sequence.subSequence(i, offset); if (StringUtil.startsWith(snippet.getKey(), prefix)) { return prefix; } } } return null; } | getPrefixForSnippet |
27,964 | void (@NotNull Editor editor, @NotNull TextMateSnippet snippet) { String key = snippet.getKey(); int offset = editor.getCaretModel().getOffset(); int newOffset = Math.max(offset - key.length(), 0); editor.getDocument().deleteString(newOffset, offset); editor.getCaretModel().moveToOffset(newOffset); EditorModificationUtilEx.insertStringAtCaret(editor, snippet.getContent()); } | expand |
27,965 | void (@NotNull final LookupEvent event) { final LookupElement item = event.getItem(); assert item instanceof CustomLiveTemplateLookupElement; if (myFile != null) { WriteCommandAction.runWriteCommandAction(myProject, TextMateBundle.message("textmate.expand.live.template.command.name"), null, () -> ((CustomLiveTemplateLookupElement)item).expandTemplate(myEditor, myFile), myFile); } } | itemSelected |
27,966 | void (@NotNull Editor editor, @NotNull PsiFile file) { expand(editor, mySnippet); } | expandTemplate |
27,967 | void (@NotNull LookupElementPresentation presentation) { super.renderElement(presentation); presentation.setTypeText(mySnippet.getName()); presentation.setTypeGrayed(true); } | renderElement |
27,968 | void (char c, @NotNull PsiFile file, @NotNull Editor editor) { } | beforeCharDeleted |
27,969 | boolean (char c, PsiFile file, @NotNull Editor editor) { if (file.getFileType() == TextMateFileType.INSTANCE) { final int offset = editor.getCaretModel().getOffset(); EditorHighlighter highlighter = editor.getHighlighter(); HighlighterIterator iterator = highlighter.createIterator(offset); if (offset == 0 && iterator.atEnd()) { return false; } final IElementType tokenType = iterator.getTokenType(); if (tokenType instanceof TextMateElementType) { TextMateScope scopeSelector = ((TextMateElementType)tokenType).getScope(); final TextMateAutoClosingPair pairForChar = findSingleCharSmartTypingPair(c, scopeSelector); if (pairForChar != null) { final Document document = editor.getDocument(); int endOffset = offset + pairForChar.getRight().length(); if (endOffset < document.getTextLength()) { if (StringUtil.equals(pairForChar.getRight(), document.getCharsSequence().subSequence(offset, endOffset))) { document.deleteString(offset, endOffset); return true; } } } } } return false; } | charDeleted |
27,970 | TextMateAutoClosingPair (char openingChar, @Nullable TextMateScope currentSelector) { if (!TextMateService.getInstance().getPreferenceRegistry().isPossibleLeftSmartTypingBrace(openingChar)) { return null; } Set<TextMateAutoClosingPair> pairs = getSmartTypingPairs(currentSelector); for (TextMateAutoClosingPair pair : pairs) { if (pair.getLeft().length() == 1 && pair.getLeft().charAt(0) == openingChar) { return pair; } } return null; } | findSingleCharSmartTypingPair |
27,971 | ActionUpdateThread () { return ActionUpdateThread.BGT; } | getActionUpdateThread |
27,972 | void (@NotNull final AnActionEvent e) { Project project = e.getData(CommonDataKeys.PROJECT); if (project == null || project.isDefault()) { e.getPresentation().setEnabledAndVisible(false); return; } if (project.getService(GHHostedRepositoriesManager.class).getKnownRepositoriesState().getValue().isEmpty()) { e.getPresentation().setEnabledAndVisible(false); return; } Editor editor = e.getData(CommonDataKeys.EDITOR); VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE); VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY); boolean hasFilesWithContent = FILE_WITH_CONTENT.value(file) || (files != null && ContainerUtil.exists(files, FILE_WITH_CONTENT)); if (!hasFilesWithContent || editor != null && editor.getDocument().getTextLength() == 0) { e.getPresentation().setEnabledAndVisible(false); return; } e.getPresentation().setEnabledAndVisible(true); } | update |
27,973 | void (@NotNull final AnActionEvent e) { final Project project = e.getData(CommonDataKeys.PROJECT); if (project == null || project.isDefault()) { return; } final Editor editor = e.getData(CommonDataKeys.EDITOR); final VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE); final VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY); if (editor == null && file == null && files == null) { return; } createGistAction(project, editor, FILE_WITH_CONTENT.value(file) ? file : null, filterFilesWithContent(files)); } | actionPerformed |
27,974 | void (@NotNull final Project project, @Nullable final Editor editor, @Nullable final VirtualFile file, final VirtualFile @Nullable [] files) { GithubSettings settings = GithubSettings.getInstance(); // Ask for description and other params GithubCreateGistDialog dialog = new GithubCreateGistDialog(project, getFileName(editor, files), settings.isPrivateGist(), settings.isOpenInBrowserGist(), settings.isCopyURLGist()); if (!dialog.showAndGet()) { return; } settings.setPrivateGist(dialog.isSecret()); settings.setOpenInBrowserGist(dialog.isOpenInBrowser()); settings.setCopyURLGist(dialog.isCopyURL()); GithubAccount account = requireNonNull(dialog.getAccount()); final Ref<String> url = new Ref<>(); new Task.Backgroundable(project, GithubBundle.message("create.gist.process")) { @Override public void run(@NotNull ProgressIndicator indicator) { String token = GHCompatibilityUtil.getOrRequestToken(account, project); if (token == null) return; GithubApiRequestExecutor requestExecutor = GithubApiRequestExecutor.Factory.getInstance().create(token); List<FileContent> contents = collectContents(project, editor, file, files); if (contents.isEmpty()) return; String gistUrl = createGist(project, requestExecutor, indicator, account.getServer(), contents, dialog.isSecret(), dialog.getDescription(), dialog.getFileName()); url.set(gistUrl); } @Override public void onSuccess() { if (url.isNull()) { return; } if (dialog.isCopyURL()) { StringSelection stringSelection = new StringSelection(url.get()); CopyPasteManager.getInstance().setContents(stringSelection); } if (dialog.isOpenInBrowser()) { BrowserUtil.browse(url.get()); } else { GithubNotifications .showInfoURL(project, GithubNotificationIdsHolder.GIST_CREATED, GithubBundle.message("create.gist.success"), GithubBundle.message("create.gist.url"), url.get()); } } }.queue(); } | createGistAction |
27,975 | void (@NotNull ProgressIndicator indicator) { String token = GHCompatibilityUtil.getOrRequestToken(account, project); if (token == null) return; GithubApiRequestExecutor requestExecutor = GithubApiRequestExecutor.Factory.getInstance().create(token); List<FileContent> contents = collectContents(project, editor, file, files); if (contents.isEmpty()) return; String gistUrl = createGist(project, requestExecutor, indicator, account.getServer(), contents, dialog.isSecret(), dialog.getDescription(), dialog.getFileName()); url.set(gistUrl); } | run |
27,976 | void () { if (url.isNull()) { return; } if (dialog.isCopyURL()) { StringSelection stringSelection = new StringSelection(url.get()); CopyPasteManager.getInstance().setContents(stringSelection); } if (dialog.isOpenInBrowser()) { BrowserUtil.browse(url.get()); } else { GithubNotifications .showInfoURL(project, GithubNotificationIdsHolder.GIST_CREATED, GithubBundle.message("create.gist.success"), GithubBundle.message("create.gist.url"), url.get()); } } | onSuccess |
27,977 | String (@Nullable Editor editor, VirtualFile @Nullable [] files) { if (files != null && files.length == 1 && !files[0].isDirectory()) { return files[0].getName(); } if (editor != null) { return ""; } return null; } | getFileName |
27,978 | List<FileContent> (@NotNull Project project, @Nullable Editor editor, @Nullable VirtualFile file, VirtualFile @Nullable [] files) { if (editor != null) { String content = getContentFromEditor(editor); if (content == null) { return Collections.emptyList(); } if (file != null) { return Collections.singletonList(new FileContent(file.getName(), content)); } else { return Collections.singletonList(new FileContent("", content)); } } if (files != null) { List<FileContent> contents = new ArrayList<>(); for (VirtualFile vf : files) { contents.addAll(getContentFromFile(vf, project, null)); } return contents; } if (file != null) { return getContentFromFile(file, project, null); } LOG.error("File, files and editor can't be null all at once!"); throw new IllegalStateException("File, files and editor can't be null all at once!"); } | collectContents |
27,979 | String (@NotNull Project project, @NotNull GithubApiRequestExecutor executor, @NotNull ProgressIndicator indicator, @NotNull GithubServerPath server, @NotNull List<? extends FileContent> contents, final boolean isSecret, @NotNull final String description, @Nullable String filename) { if (contents.isEmpty()) { GithubNotifications.showWarning(project, GithubNotificationIdsHolder.GIST_CANNOT_CREATE, GithubBundle.message("cannot.create.gist"), GithubBundle.message("create.gist.error.empty")); return null; } if (contents.size() == 1 && filename != null) { FileContent entry = contents.iterator().next(); contents = Collections.singletonList(new FileContent(filename, entry.getContent())); } try { return executor.execute(indicator, GithubApiRequests.Gists.create(server, contents, description, !isSecret)).getHtmlUrl(); } catch (IOException e) { GithubNotifications.showError(project, GithubNotificationIdsHolder.GIST_CANNOT_CREATE, GithubBundle.message("cannot.create.gist"), e); return null; } } | createGist |
27,980 | String (@NotNull final Editor editor) { String text = ReadAction.compute(() -> editor.getSelectionModel().getSelectedText()); if (text == null) { text = editor.getDocument().getText(); } if (StringUtil.isEmptyOrSpaces(text)) { return null; } return text; } | getContentFromEditor |
27,981 | List<FileContent> (@NotNull final VirtualFile file, @NotNull Project project, @Nullable String prefix) { if (file.isDirectory()) { return getContentFromDirectory(file, project, prefix); } if (file.getFileType().isBinary()) { GithubNotifications .showWarning(project, GithubNotificationIdsHolder.GIST_CANNOT_CREATE, GithubBundle.message("cannot.create.gist"), GithubBundle.message("create.gist.error.binary.file", file.getName())); return Collections.emptyList(); } String content = ReadAction.compute(() -> { try { Document document = FileDocumentManager.getInstance().getDocument(file); if (document != null) { return document.getText(); } else { return new String(file.contentsToByteArray(), file.getCharset()); } } catch (IOException e) { LOG.info("Couldn't read contents of the file " + file, e); return null; } }); if (content == null) { GithubNotifications .showWarning(project, GithubNotificationIdsHolder.GIST_CANNOT_CREATE, GithubBundle.message("cannot.create.gist"), GithubBundle.message("create.gist.error.content.read", file.getName())); return Collections.emptyList(); } if (StringUtil.isEmptyOrSpaces(content)) { return Collections.emptyList(); } String filename = addPrefix(file.getName(), prefix, false); return Collections.singletonList(new FileContent(filename, content)); } | getContentFromFile |
27,982 | List<FileContent> (@NotNull VirtualFile dir, @NotNull Project project, @Nullable String prefix) { List<FileContent> contents = new ArrayList<>(); for (VirtualFile file : dir.getChildren()) { if (!isFileIgnored(file, project)) { String pref = addPrefix(dir.getName(), prefix, true); contents.addAll(getContentFromFile(file, project, pref)); } } return contents; } | getContentFromDirectory |
27,983 | String (@NotNull String name, @Nullable String prefix, boolean addTrailingSlash) { String pref = prefix == null ? "" : prefix; pref += name; if (addTrailingSlash) { pref += "_"; } return pref; } | addPrefix |
27,984 | boolean (@NotNull VirtualFile file, @NotNull Project project) { ChangeListManager manager = ChangeListManager.getInstance(project); return manager.isIgnoredFile(file) || FileTypeManager.getInstance().isFileIgnored(file); } | isFileIgnored |
27,985 | ActionUpdateThread () { return ActionUpdateThread.BGT; } | getActionUpdateThread |
27,986 | void (@NotNull AnActionEvent e) { e.getPresentation().setEnabledAndVisible(isEnabledAndVisible(e)); } | update |
27,987 | void (@NotNull AnActionEvent e) { FileDocumentManager.getInstance().saveAllDocuments(); Project project = Objects.requireNonNull(e.getData(CommonDataKeys.PROJECT)); GitRepositoryManager gitRepositoryManager = project.getServiceIfCreated(GitRepositoryManager.class); if (gitRepositoryManager == null) { LOG.warn("Unable to get the GitRepositoryManager service"); return; } if (gitRepositoryManager.getRepositories().size() > 1) { GithubNotifications.showError(project, GithubNotificationIdsHolder.REBASE_MULTI_REPO_NOT_SUPPORTED, GithubBundle.message("rebase.error"), GithubBundle.message("rebase.error.multi.repo.not.supported")); return; } GHHostedRepositoriesManager ghRepositoriesManager = project.getServiceIfCreated(GHHostedRepositoriesManager.class); if (ghRepositoriesManager == null) { LOG.warn("Unable to get the GHProjectRepositoriesManager service"); return; } Set<GHGitRepositoryMapping> repositories = HostedGitRepositoriesManagerKt.getKnownRepositories(ghRepositoriesManager); GHGitRepositoryMapping originMapping = ContainerUtil.find(repositories, mapping -> mapping.getRemote().getRemote().getName().equals(ORIGIN_REMOTE_NAME)); if (originMapping == null) { GithubNotifications.showError(project, GithubNotificationIdsHolder.REBASE_REMOTE_ORIGIN_NOT_FOUND, GithubBundle.message("rebase.error"), GithubBundle.message("rebase.error.remote.origin.not.found")); return; } GHAccountManager accountManager = ApplicationManager.getApplication().getService(GHAccountManager.class); GithubServerPath serverPath = originMapping.getRepository().getServerPath(); GithubAccount githubAccount; List<GithubAccount> accounts = ContainerUtil.filter(accountManager.getAccountsState().getValue(), account -> serverPath.equals(account.getServer())); if (accounts.size() == 0) { githubAccount = GHCompatibilityUtil.requestNewAccountForServer(serverPath, project); } else if (accounts.size() == 1) { githubAccount = accounts.get(0); } else { GithubChooseAccountDialog chooseAccountDialog = new GithubChooseAccountDialog(project, null, accounts, GithubBundle.message("account.choose.for", serverPath), false, true); DialogManager.show(chooseAccountDialog); if (chooseAccountDialog.isOK()) { githubAccount = chooseAccountDialog.getAccount(); } else { GithubNotifications.showError(project, GithubNotificationIdsHolder.REBASE_ACCOUNT_NOT_FOUND, GithubBundle.message("rebase.error"), GithubBundle.message("rebase.error.no.suitable.account.found")); return; } } if (githubAccount == null) { GithubNotifications.showError(project, GithubNotificationIdsHolder.REBASE_ACCOUNT_NOT_FOUND, GithubBundle.message("rebase.error"), GithubBundle.message("rebase.error.no.suitable.account.found")); return; } new SyncForkTask(project, Git.getInstance(), githubAccount, originMapping.getRemote().getRepository(), originMapping.getRepository().getRepositoryPath()).queue(); } | actionPerformed |
27,988 | boolean (@NotNull AnActionEvent e) { Project project = e.getData(CommonDataKeys.PROJECT); if (project == null || project.isDefault()) return false; GHHostedRepositoriesManager repositoriesManager = project.getServiceIfCreated(GHHostedRepositoriesManager.class); if (repositoriesManager == null) return false; Set<GHGitRepositoryMapping> repositories = HostedGitRepositoriesManagerKt.getKnownRepositories(repositoriesManager); return !repositories.isEmpty(); } | isEnabledAndVisible |
27,989 | void (@NotNull ProgressIndicator indicator) { String token = GHCompatibilityUtil.getOrRequestToken(myAccount, myProject); if (token == null) return; GithubApiRequestExecutor executor = GithubApiRequestExecutor.Factory.getInstance().create(token); myRepository.update(); GithubRepo parentRepo = validateRepoAndLoadParent(executor, indicator); if (parentRepo == null) return; GitRemote parentRemote = configureParentRemote(indicator, parentRepo.getFullPath()); if (parentRemote == null) return; String branchName = parentRepo.getDefaultBranch(); if (branchName == null) { GithubNotifications.showError(myProject, GithubNotificationIdsHolder.REBASE_REPO_NOT_FOUND, GithubBundle.message("rebase.error"), GithubBundle.message("rebase.error.no.default.branch")); return; } if (!fetchParent(indicator, parentRemote)) { return; } rebaseCurrentBranch(indicator, parentRemote, branchName); } | run |
27,990 | GithubRepo (@NotNull GithubApiRequestExecutor executor, @NotNull ProgressIndicator indicator) { try { GithubRepoDetailed repositoryInfo = executor.execute(indicator, GithubApiRequests.Repos.get(myAccount.getServer(), myRepoPath.getOwner(), myRepoPath.getRepository())); if (repositoryInfo == null) { GithubNotifications.showError(myProject, GithubNotificationIdsHolder.REBASE_REPO_NOT_FOUND, GithubBundle.message("rebase.error"), GithubBundle.message("rebase.error.repo.not.found", myRepoPath.toString())); return null; } GithubRepo parentRepo = repositoryInfo.getParent(); if (!repositoryInfo.isFork() || parentRepo == null) { GithubNotifications.showWarningURL(myProject, GithubNotificationIdsHolder.REBASE_REPO_IS_NOT_A_FORK, GithubBundle.message("rebase.error"), "GitHub repository ", "'" + repositoryInfo.getName() + "'", " is not a fork", repositoryInfo.getHtmlUrl()); return null; } return parentRepo; } catch (IOException e) { GithubNotifications.showError(myProject, GithubNotificationIdsHolder.REBASE_CANNOT_LOAD_REPO_INFO, GithubBundle.message("cannot.load.repo.info"), e); return null; } } | validateRepoAndLoadParent |
27,991 | GitRemote (@NotNull ProgressIndicator indicator, @NotNull GHRepositoryPath parentRepoPath) { LOG.info("Configuring upstream remote"); indicator.setText(GithubBundle.message("rebase.process.configuring.upstream.remote")); GitRemote upstreamRemote = findRemote(parentRepoPath); if (upstreamRemote != null) { LOG.info("Correct upstream remote already exists"); return upstreamRemote; } LOG.info("Adding GitHub parent as a remote host"); indicator.setText(GithubBundle.message("rebase.process.adding.github.parent.as.remote.host")); String parentRepoUrl = GithubGitHelper.getInstance().getRemoteUrl(myAccount.getServer(), parentRepoPath); try { myGit.addRemote(myRepository, UPSTREAM_REMOTE_NAME, parentRepoUrl).throwOnError(); } catch (VcsException e) { GithubNotifications.showError(myProject, GithubNotificationIdsHolder.REBASE_CANNOT_CONFIGURE_UPSTREAM_REMOTE, GithubBundle.message("rebase.error"), GithubBundle.message("cannot.configure.remote", UPSTREAM_REMOTE_NAME, e.getMessage())); return null; } myRepository.update(); upstreamRemote = findRemote(parentRepoPath); if (upstreamRemote == null) { GithubNotifications.showError(myProject, GithubNotificationIdsHolder.REBASE_CANNOT_CONFIGURE_UPSTREAM_REMOTE, GithubBundle.message("rebase.error"), GithubBundle.message("rebase.error.upstream.not.found", UPSTREAM_REMOTE_NAME)); } return upstreamRemote; } | configureParentRemote |
27,992 | GitRemote (@NotNull GHRepositoryPath repoPath) { return ContainerUtil.find(myRepository.getRemotes(), remote -> { String url = remote.getFirstUrl(); if (url == null || !GitHostingUrlUtil.match(myAccount.getServer().toURI(), url)) return false; GHRepositoryPath remotePath = GithubUrlUtil.getUserAndRepositoryFromRemoteUrl(url); return repoPath.equals(remotePath); }); } | findRemote |
27,993 | boolean (@NotNull ProgressIndicator indicator, @NotNull GitRemote remote) { LOG.info("Fetching upstream"); indicator.setText(GithubBundle.message("rebase.process.fetching.upstream")); return fetchSupport(myProject).fetch(myRepository, remote).showNotificationIfFailed(); } | fetchParent |
27,994 | void (@NotNull ProgressIndicator indicator, @NotNull GitRemote parentRemote, @NotNull @NlsSafe String branch) { String onto = parentRemote.getName() + "/" + branch; LOG.info("Rebasing current branch"); indicator.setText(GithubBundle.message("rebase.process.rebasing.branch.onto", onto)); try (AccessToken ignore = DvcsUtil.workingTreeChangeStarted(myProject, GitBundle.message("rebase.git.operation.name"))) { List<VirtualFile> rootsToSave = Collections.singletonList(myRepository.getRoot()); GitSaveChangesPolicy saveMethod = GitVcsSettings.getInstance(myProject).getSaveChangesPolicy(); GitPreservingProcess process = new GitPreservingProcess(myProject, myGit, rootsToSave, GithubBundle.message("rebase.process.operation.title"), onto, saveMethod, indicator, () -> doRebaseCurrentBranch(indicator, onto)); process.execute(); } } | rebaseCurrentBranch |
27,995 | void (@NotNull ProgressIndicator indicator, @NotNull String onto) { GitRepositoryManager repositoryManager = GitUtil.getRepositoryManager(myProject); GitRebaser rebaser = new GitRebaser(myProject, myGit, indicator); VirtualFile root = myRepository.getRoot(); GitLineHandler handler = new GitLineHandler(myProject, root, GitCommand.REBASE); handler.setStdoutSuppressed(false); handler.addParameters(onto); final GitRebaseProblemDetector rebaseConflictDetector = new GitRebaseProblemDetector(); handler.addLineListener(rebaseConflictDetector); final GitUntrackedFilesOverwrittenByOperationDetector untrackedFilesDetector = new GitUntrackedFilesOverwrittenByOperationDetector(root); final GitLocalChangesWouldBeOverwrittenDetector localChangesDetector = new GitLocalChangesWouldBeOverwrittenDetector(root, CHECKOUT); handler.addLineListener(untrackedFilesDetector); handler.addLineListener(localChangesDetector); handler.addLineListener(GitStandardProgressAnalyzer.createListener(indicator)); String oldText = indicator.getText(); indicator.setText(GithubBundle.message("rebase.process.rebasing.onto", onto)); GitCommandResult rebaseResult = myGit.runCommand(handler); indicator.setText(oldText); repositoryManager.updateRepository(root); if (rebaseResult.success()) { root.refresh(false, true); GithubNotifications.showInfo(myProject, GithubNotificationIdsHolder.REBASE_SUCCESS, GithubBundle.message("rebase.process.success"), ""); } else { GitUpdateResult result = rebaser.handleRebaseFailure(handler, root, rebaseResult, rebaseConflictDetector, untrackedFilesDetector, localChangesDetector); if (result == GitUpdateResult.NOTHING_TO_UPDATE || result == GitUpdateResult.SUCCESS || result == GitUpdateResult.SUCCESS_WITH_RESOLVED_CONFLICTS) { GithubNotifications.showInfo(myProject, GithubNotificationIdsHolder.REBASE_SUCCESS, GithubBundle.message("rebase.process.success"), ""); } } } | doRebaseCurrentBranch |
27,996 | boolean (@NotNull Throwable e) { return e instanceof GithubOperationCanceledException || e instanceof ProcessCanceledException; } | isOperationCanceled |
27,997 | void (@NotNull Project project, @NonNls @Nullable String displayId, @NotificationTitle @NotNull String title, @NotificationContent @NotNull String message) { LOG.info(title + "; " + message); VcsNotifier.getInstance(project).notifyImportantInfo(displayId, title, message); } | showInfo |
27,998 | void (@NotNull Project project, @NonNls @Nullable String displayId, @NotificationTitle @NotNull String title, @NotificationContent @NotNull String message) { LOG.info(title + "; " + message); VcsNotifier.getInstance(project).notifyImportantWarning(displayId, title, message); } | showWarning |
27,999 | void (@NotNull Project project, @NonNls @Nullable String displayId, @NotificationTitle @NotNull String title, @NotificationContent @NotNull String message) { LOG.info(title + "; " + message); VcsNotifier.getInstance(project).notifyError(displayId, title, message); } | showError |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.