List of usage examples for com.intellij.openapi.actionSystem IdeActions ACTION_COMMENT_LINE
String ACTION_COMMENT_LINE
To view the source code for com.intellij.openapi.actionSystem IdeActions ACTION_COMMENT_LINE.
Click Source Link
From source file:BuckCommenterTest.java
License:Apache License
public void testLineCommenter1() { doTest(IdeActions.ACTION_COMMENT_LINE); }
From source file:BuckCommenterTest.java
License:Apache License
public void testLineCommenter2() { doTest(IdeActions.ACTION_COMMENT_LINE); }
From source file:com.facebook.buck.intellij.ideabuck.endtoend.BcfgCommenterTest.java
License:Apache License
public void testBcfgCommentProperty() { doTest(IdeActions.ACTION_COMMENT_LINE); }
From source file:com.facebook.buck.intellij.ideabuck.endtoend.BcfgCommenterTest.java
License:Apache License
public void testBcfgCommentSection() { doTest(IdeActions.ACTION_COMMENT_LINE); }
From source file:com.facebook.buck.intellij.ideabuck.endtoend.BcfgCommenterTest.java
License:Apache License
public void testBcfgMultiline() { doTest(IdeActions.ACTION_COMMENT_LINE); }
From source file:com.intellij.codeInsight.generation.CommentByLineCommentHandler.java
License:Apache License
@RequiredDispatchThread @Override/* w w w . j a v a2 s. com*/ public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { if (!CodeInsightUtilBase.prepareEditorForWrite(editor)) return; myProject = project; myFile = file.getViewProvider().getPsi(file.getViewProvider().getBaseLanguage()); myEditor = editor; PsiElement context = InjectedLanguageManager.getInstance(myFile.getProject()).getInjectionHost(myFile); if (context != null && (context.textContains('\'') || context.textContains('\"'))) { String s = context.getText(); if (StringUtil.startsWith(s, "\"") || StringUtil.startsWith(s, "\'")) { myFile = context.getContainingFile(); myEditor = editor instanceof EditorWindow ? ((EditorWindow) editor).getDelegate() : editor; } } myDocument = myEditor.getDocument(); if (!FileDocumentManager.getInstance().requestWriting(myDocument, project)) { return; } PsiDocumentManager.getInstance(project).commitDocument(myDocument); FeatureUsageTracker.getInstance().triggerFeatureUsed("codeassists.comment.line"); myCodeStyleManager = CodeStyleManager.getInstance(myProject); final SelectionModel selectionModel = myEditor.getSelectionModel(); boolean hasSelection = selectionModel.hasSelection(); myStartOffset = selectionModel.getSelectionStart(); myEndOffset = selectionModel.getSelectionEnd(); FoldRegion fold = myEditor.getFoldingModel().getCollapsedRegionAtOffset(myStartOffset); if (fold != null && fold.shouldNeverExpand() && fold.getStartOffset() == myStartOffset && fold.getEndOffset() == myEndOffset) { // Foldings that never expand are automatically selected, so the fact it is selected must not interfer with commenter's logic hasSelection = false; } if (myDocument.getTextLength() == 0) return; while (true) { int lastLineEnd = myDocument.getLineEndOffset(myDocument.getLineNumber(myEndOffset)); FoldRegion collapsedAt = myEditor.getFoldingModel().getCollapsedRegionAtOffset(lastLineEnd); if (collapsedAt != null) { final int endOffset = collapsedAt.getEndOffset(); if (endOffset <= myEndOffset) { break; } myEndOffset = endOffset; } else { break; } } boolean wholeLinesSelected = !hasSelection || myStartOffset == myDocument .getLineStartOffset(myDocument.getLineNumber(myStartOffset)) && myEndOffset == myDocument.getLineEndOffset(myDocument.getLineNumber(myEndOffset - 1)) + 1; boolean startingNewLineComment = !hasSelection && isLineEmpty(myDocument.getLineNumber(myStartOffset)) && !Comparing.equal(IdeActions.ACTION_COMMENT_LINE, ActionManagerEx.getInstanceEx().getPrevPreformedActionId()); doComment(); if (startingNewLineComment) { final Commenter commenter = myCommenters[0]; if (commenter != null) { String prefix; if (commenter instanceof SelfManagingCommenter) { prefix = ((SelfManagingCommenter) commenter).getCommentPrefix(myStartLine, myDocument, myCommenterStateMap.get((SelfManagingCommenter) commenter)); if (prefix == null) prefix = ""; // TODO } else { prefix = commenter.getLineCommentPrefix(); if (prefix == null) prefix = commenter.getBlockCommentPrefix(); } int lineStart = myDocument.getLineStartOffset(myStartLine); lineStart = CharArrayUtil.shiftForward(myDocument.getCharsSequence(), lineStart, " \t"); lineStart += prefix.length(); lineStart = CharArrayUtil.shiftForward(myDocument.getCharsSequence(), lineStart, " \t"); if (lineStart > myDocument.getTextLength()) lineStart = myDocument.getTextLength(); myEditor.getCaretModel().moveToOffset(lineStart); myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); } } else { if (!hasSelection) { // Don't tweak caret position if we're already located on the last document line. LogicalPosition position = myEditor.getCaretModel().getLogicalPosition(); if (position.line < myDocument.getLineCount() - 1) { int verticalShift = 1 + myEditor.getSoftWrapModel().getSoftWrapsForLine(position.line).size() - position.softWrapLinesOnCurrentLogicalLine; myEditor.getCaretModel().moveCaretRelatively(0, verticalShift, false, false, true); } } else { if (wholeLinesSelected) { selectionModel.setSelection(myStartOffset, selectionModel.getSelectionEnd()); } } } }
From source file:com.intellij.coldFusion.CfmlCommenterTest.java
License:Apache License
public void testMultiLineByLineCommenter() throws Throwable { doTest(IdeActions.ACTION_COMMENT_LINE); }
From source file:com.intellij.coldFusion.CfmlCommenterTest.java
License:Apache License
public void testOneLineByLineCommenter() throws Throwable { doTest(IdeActions.ACTION_COMMENT_LINE); }