Search in sources :

Example 1 with NavigatableAdapter

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

the class MavenNavigationUtil method createNavigatableForDependency.

@Nullable
public static Navigatable createNavigatableForDependency(final Project project, final VirtualFile file, final MavenArtifact artifact) {
    return new NavigatableAdapter() {

        public void navigate(boolean requestFocus) {
            if (!file.isValid())
                return;
            MavenDomProjectModel projectModel = MavenDomUtil.getMavenDomProjectModel(project, file);
            if (projectModel == null)
                return;
            MavenDomDependency dependency = findDependency(projectModel, artifact.getGroupId(), artifact.getArtifactId());
            if (dependency == null)
                return;
            XmlTag artifactId = dependency.getArtifactId().getXmlTag();
            if (artifactId == null)
                return;
            navigate(project, artifactId.getContainingFile().getVirtualFile(), artifactId.getTextOffset() + artifactId.getName().length() + 2, requestFocus);
        }
    };
}
Also used : MavenDomProjectModel(org.jetbrains.idea.maven.dom.model.MavenDomProjectModel) NavigatableAdapter(com.intellij.pom.NavigatableAdapter) MavenDomDependency(org.jetbrains.idea.maven.dom.model.MavenDomDependency) XmlTag(com.intellij.psi.xml.XmlTag) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with NavigatableAdapter

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

the class RepositoryBrowserComponent method getData.

@Nullable
public Object getData(@NonNls String dataId) {
    if (CommonDataKeys.NAVIGATABLE.is(dataId)) {
        final Project project = myVCS.getProject();
        if (project == null || project.isDefault()) {
            return null;
        }
        final VirtualFile vcsFile = getSelectedVcsFile();
        // (because of progress dialog)
        return vcsFile != null ? new NavigatableAdapter() {

            @Override
            public void navigate(boolean requestFocus) {
                navigate(project, vcsFile, requestFocus);
            }
        } : null;
    } else if (CommonDataKeys.PROJECT.is(dataId)) {
        return myVCS.getProject();
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) Project(com.intellij.openapi.project.Project) NavigatableAdapter(com.intellij.pom.NavigatableAdapter) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with NavigatableAdapter

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

the class EditorHyperlinkSupport method getNextOccurrence.

@Nullable
public static OccurenceNavigator.OccurenceInfo getNextOccurrence(final Editor editor, final int delta, final Consumer<RangeHighlighter> action) {
    final List<RangeHighlighter> ranges = getHyperlinks(0, editor.getDocument().getTextLength(), editor);
    if (ranges.isEmpty()) {
        return null;
    }
    int i;
    for (i = 0; i < ranges.size(); i++) {
        RangeHighlighter range = ranges.get(i);
        if (range.getUserData(OLD_HYPERLINK_TEXT_ATTRIBUTES) != null) {
            break;
        }
    }
    i %= ranges.size();
    int newIndex = i;
    while (newIndex < ranges.size() && newIndex >= 0) {
        newIndex = (newIndex + delta + ranges.size()) % ranges.size();
        final RangeHighlighter next = ranges.get(newIndex);
        HyperlinkInfo info = getHyperlinkInfo(next);
        assert info != null;
        if (info.includeInOccurenceNavigation()) {
            boolean inCollapsedRegion = editor.getFoldingModel().getCollapsedRegionAtOffset(next.getStartOffset()) != null;
            if (!inCollapsedRegion) {
                return new OccurenceNavigator.OccurenceInfo(new NavigatableAdapter() {

                    @Override
                    public void navigate(final boolean requestFocus) {
                        action.consume(next);
                        linkFollowed(editor, ranges, next);
                    }
                }, newIndex == -1 ? -1 : newIndex + 1, ranges.size());
            }
        }
        if (newIndex == i) {
            // cycled through everything, found no next/prev hyperlink
            break;
        }
    }
    return null;
}
Also used : RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) NavigatableAdapter(com.intellij.pom.NavigatableAdapter) RelativePoint(com.intellij.ui.awt.RelativePoint) HyperlinkInfo(com.intellij.execution.filters.HyperlinkInfo) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with NavigatableAdapter

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

the class AlwaysPresentGoSyncPlugin method validateProjectView.

@Override
public boolean validateProjectView(@Nullable Project project, BlazeContext context, ProjectViewSet projectViewSet, WorkspaceLanguageSettings workspaceLanguageSettings) {
    if (workspaceLanguageSettings.isLanguageActive(LanguageClass.GO) && !isGoPluginSupported()) {
        IssueOutput.error(String.format("Go is no longer supported by the %s plugin with IntelliJ Community Edition.\n" + "Please install Ultimate Edition and upgrade to the JetBrains Go plugin", Blaze.defaultBuildSystemName())).submit(context);
        return false;
    }
    if (goWorkspaceTypeSupported() || !workspaceLanguageSettings.isWorkspaceType(WorkspaceType.GO)) {
        return true;
    }
    ProjectViewFile topLevelProjectViewFile = projectViewSet.getTopLevelProjectViewFile();
    String msg = "Go workspace_type is no longer supported. Please add 'go' to " + "additional_languages instead";
    boolean fixable = project != null && topLevelProjectViewFile != null && topLevelProjectViewFile.projectView.getScalarValue(WorkspaceTypeSection.KEY) == WorkspaceType.GO;
    msg += fixable ? ". Click here to fix your .blazeproject and resync." : ", then resync.";
    IssueOutput.error(msg).navigatable(!fixable ? null : new NavigatableAdapter() {

        @Override
        public void navigate(boolean requestFocus) {
            fixLanguageSupport(project);
        }
    }).submit(context);
    return false;
}
Also used : ProjectViewFile(com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile) NavigatableAdapter(com.intellij.pom.NavigatableAdapter)

Example 5 with NavigatableAdapter

use of com.intellij.pom.NavigatableAdapter 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)

Aggregations

NavigatableAdapter (com.intellij.pom.NavigatableAdapter)6 Nullable (org.jetbrains.annotations.Nullable)3 ProjectViewFile (com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile)2 HyperlinkInfo (com.intellij.execution.filters.HyperlinkInfo)1 RangeHighlighter (com.intellij.openapi.editor.markup.RangeHighlighter)1 Project (com.intellij.openapi.project.Project)1 VcsVirtualFile (com.intellij.openapi.vcs.vfs.VcsVirtualFile)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Navigatable (com.intellij.pom.Navigatable)1 XmlTag (com.intellij.psi.xml.XmlTag)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1 MavenDomDependency (org.jetbrains.idea.maven.dom.model.MavenDomDependency)1 MavenDomProjectModel (org.jetbrains.idea.maven.dom.model.MavenDomProjectModel)1