Search in sources :

Example 36 with Navigatable

use of com.intellij.pom.Navigatable in project intellij by bazelbuild.

the class BlazeTypescriptSyncPlugin method invalidProjectViewError.

private void invalidProjectViewError(BlazeContext context, BuildSystemProvider buildSystemProvider) {
    String errorNote = "For Typescript support you must add both `additional_languages: typescript`" + " and the `ts_config_rules` attribute.";
    String documentationUrl = buildSystemProvider.getLanguageSupportDocumentationUrl("dynamic-languages-typescript");
    Navigatable navigatable = null;
    if (documentationUrl != null) {
        errorNote += " Click to open the relevant docs.";
        navigatable = new NavigatableAdapter() {

            @Override
            public void navigate(boolean requestFocus) {
                BrowserLauncher.getInstance().open(documentationUrl);
            }
        };
    }
    IssueOutput.error(errorNote).navigatable(navigatable).submit(context);
}
Also used : NavigatableAdapter(com.intellij.pom.NavigatableAdapter) Navigatable(com.intellij.pom.Navigatable)

Example 37 with Navigatable

use of com.intellij.pom.Navigatable in project buck by facebook.

the class GoToBuckFile method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getProject();
    if (project == null) {
        return;
    }
    Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
    if (editor == null) {
        return;
    }
    final Document document = editor.getDocument();
    if (document == null) {
        return;
    }
    VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document);
    final VirtualFile file = BuckFileUtil.getBuckFile(virtualFile);
    if (file != null) {
        final OpenFileDescriptor descriptor = new OpenFileDescriptor(project, file);
        // This is for better cursor position.
        final Navigatable n = descriptor.setUseCurrentWindow(false);
        if (!n.canNavigate()) {
            return;
        }
        n.navigate(true);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) Editor(com.intellij.openapi.editor.Editor) Document(com.intellij.openapi.editor.Document) Navigatable(com.intellij.pom.Navigatable)

Example 38 with Navigatable

use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.

the class ProblemsView method addMessage.

public final void addMessage(CompilerMessage message, @NotNull UUID sessionId) {
    final VirtualFile file = message.getVirtualFile();
    Navigatable navigatable = message.getNavigatable();
    if (navigatable == null && file != null) {
        navigatable = new OpenFileDescriptor(myProject, file, -1, -1);
    }
    final CompilerMessageCategory category = message.getCategory();
    final int type = CompilerTask.translateCategory(category);
    final String[] text = convertMessage(message);
    final String groupName = file != null ? file.getPresentableUrl() : category.getPresentableText();
    addMessage(type, text, groupName, navigatable, message.getExportTextPrefix(), message.getRenderTextPrefix(), sessionId);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CompilerMessageCategory(com.intellij.openapi.compiler.CompilerMessageCategory) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) Navigatable(com.intellij.pom.Navigatable)

Example 39 with Navigatable

use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.

the class ExcludeFromValidationAction method getExcludedConfigurationAndFile.

@Nullable
private static Pair<ExcludesConfiguration, VirtualFile> getExcludedConfigurationAndFile(final AnActionEvent event, Project project) {
    Navigatable navigatable = event.getData(CommonDataKeys.NAVIGATABLE);
    if (project != null && navigatable instanceof OpenFileDescriptor) {
        final VirtualFile file = ((OpenFileDescriptor) navigatable).getFile();
        final ExcludesConfiguration configuration = ValidationConfiguration.getExcludedEntriesConfiguration(project);
        return Pair.create(configuration, file);
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ExcludesConfiguration(com.intellij.openapi.compiler.options.ExcludesConfiguration) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) Navigatable(com.intellij.pom.Navigatable) Nullable(org.jetbrains.annotations.Nullable)

Example 40 with Navigatable

use of com.intellij.pom.Navigatable in project android by JetBrains.

the class GradleBuildTreeViewPanel method navigateToSource.

private void navigateToSource(boolean focusEditor) {
    NavigatableMessageElement element = getSelectedMessageElement();
    if (element == null) {
        return;
    }
    Navigatable navigatable = element.getNavigatable();
    if (navigatable.canNavigate()) {
        navigatable.navigate(focusEditor);
    }
}
Also used : Navigatable(com.intellij.pom.Navigatable)

Aggregations

Navigatable (com.intellij.pom.Navigatable)70 VirtualFile (com.intellij.openapi.vfs.VirtualFile)22 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)19 Project (com.intellij.openapi.project.Project)14 Nullable (org.jetbrains.annotations.Nullable)14 PsiElement (com.intellij.psi.PsiElement)11 ArrayList (java.util.ArrayList)9 PsiFile (com.intellij.psi.PsiFile)7 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)7 TreePath (javax.swing.tree.TreePath)7 NotNull (org.jetbrains.annotations.NotNull)6 Editor (com.intellij.openapi.editor.Editor)4 List (java.util.List)4 TextRange (com.intellij.openapi.util.TextRange)3 XmlTag (com.intellij.psi.xml.XmlTag)3 BlazeConsoleView (com.google.idea.blaze.base.console.BlazeConsoleView)2 IssueOutput (com.google.idea.blaze.base.scope.output.IssueOutput)2 DataContext (com.intellij.openapi.actionSystem.DataContext)2 Logger (com.intellij.openapi.diagnostic.Logger)2 Document (com.intellij.openapi.editor.Document)2