use of com.intellij.openapi.editor.Editor in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoGenerateTestMethodActionGroup method getChildren.
@NotNull
@Override
public AnAction[] getChildren(@Nullable AnActionEvent e) {
if (e == null) {
return AnAction.EMPTY_ARRAY;
}
Project project = e.getProject();
Editor editor = e.getData(CommonDataKeys.EDITOR);
if (project == null || editor == null)
return AnAction.EMPTY_ARRAY;
PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project);
ArrayList<AnAction> children = ContainerUtil.newArrayList();
for (GoTestFramework framework : GoTestFramework.all()) {
if (framework.isAvailableOnFile(file)) {
children.addAll(framework.getGenerateMethodActions());
}
}
return !children.isEmpty() ? children.toArray(new AnAction[children.size()]) : AnAction.EMPTY_ARRAY;
}
use of com.intellij.openapi.editor.Editor in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoDocumentationProviderTest method doTest.
private void doTest() {
myFixture.configureByFile(getTestName(true) + ".go");
Editor editor = myFixture.getEditor();
PsiFile file = myFixture.getFile();
PsiElement originalElement = file.findElementAt(editor.getCaretModel().getOffset());
assertNotNull(originalElement);
PsiElement docElement = DocumentationManager.getInstance(getProject()).findTargetElement(editor, file);
DocumentationProvider documentationProvider = DocumentationManager.getProviderFromElement(originalElement);
String actualDoc = StringUtil.notNullize(documentationProvider.generateDoc(docElement, originalElement));
String quickNavigateInfo = documentationProvider.getQuickNavigateInfo(docElement, originalElement);
actualDoc += "\n=====\n" + StringUtil.notNullize(quickNavigateInfo, "No navigation info");
List<String> urls = documentationProvider.getUrlFor(docElement, originalElement);
actualDoc += "\n=====\n" + (urls != null ? StringUtil.join(urls, "\n") : "No urls");
String localUrl = GoDocumentationProvider.getLocalUrlToElement(docElement);
actualDoc += "\n=====\n" + StringUtil.notNullize(localUrl, "No local urls");
assertSameLinesWithFile(getTestDataPath() + "/" + getTestName(true) + ".txt", actualDoc);
if (localUrl != null) {
PsiElement elementForLink = documentationProvider.getDocumentationElementForLink(myFixture.getPsiManager(), localUrl, originalElement);
assertNotNull("Link '" + localUrl + "' wasn't resolved", elementForLink);
assertEquals("Link was resolved to unexpected element.\nExpected: " + docElement.getText() + "\n" + "Actual: " + elementForLink.getText(), docElement, elementForLink);
}
}
use of com.intellij.openapi.editor.Editor in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoUnwrapTestCase method assertUnwrapped.
protected void assertUnwrapped(@NotNull String codeBefore, @NotNull String codeAfter, int option) {
myFixture.configureByText("a.go", normalizeCode(codeBefore));
UnwrapHandler h = new UnwrapHandler() {
@Override
protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) {
if (options.isEmpty())
return;
options.get(option).actionPerformed(null);
}
};
h.invoke(getProject(), myFixture.getEditor(), myFixture.getFile());
myFixture.checkResult(normalizeCode(codeAfter));
}
use of com.intellij.openapi.editor.Editor in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoUnwrapTestCase method assertOptions.
protected void assertOptions(@NotNull String code, String... expectedOptions) {
myFixture.configureByText("a.go", normalizeCode(code));
List<String> actualOptions = ContainerUtil.newArrayList();
UnwrapHandler h = new UnwrapHandler() {
@Override
protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) {
actualOptions.addAll(options.stream().map(each -> each.getTemplatePresentation().getText()).collect(Collectors.toList()));
}
};
h.invoke(getProject(), myFixture.getEditor(), myFixture.getFile());
assertOrderedEquals(actualOptions, expectedOptions);
}
use of com.intellij.openapi.editor.Editor in project intellij-elixir by KronicDeth.
the class Issue443 method isLBraceTokenBrace.
/*
* Private Instance Methods
*/
private boolean isLBraceTokenBrace() {
int offset = myFixture.getCaretOffset();
Editor editor = myFixture.getEditor();
CharSequence text = editor.getDocument().getCharsSequence();
FileType fileType = ElixirFileType.INSTANCE;
HighlighterIterator iterator = ((EditorEx) editor).getHighlighter().createIterator(offset);
return BraceMatchingUtil.isLBraceToken(iterator, text, fileType);
}
Aggregations