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);
}
};
}
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;
}
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;
}
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;
}
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);
}
Aggregations