use of com.intellij.navigation.NavigationItem in project intellij-community by JetBrains.
the class PsiElementListCellRenderer method getNavigationItemAttributes.
@Nullable
protected TextAttributes getNavigationItemAttributes(Object value) {
TextAttributes attributes = null;
if (value instanceof NavigationItem) {
TextAttributesKey attributesKey = null;
final ItemPresentation presentation = ((NavigationItem) value).getPresentation();
if (presentation instanceof ColoredItemPresentation)
attributesKey = ((ColoredItemPresentation) presentation).getTextAttributesKey();
if (attributesKey != null) {
attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attributesKey);
}
}
return attributes;
}
use of com.intellij.navigation.NavigationItem in project intellij-community by JetBrains.
the class GotoImplementationHandler method getChooserTitle.
@Override
@NotNull
protected String getChooserTitle(@NotNull PsiElement sourceElement, String name, int length, boolean finished) {
ItemPresentation presentation = ((NavigationItem) sourceElement).getPresentation();
String fullName;
if (presentation == null) {
fullName = name;
} else {
PsiElement container = getContainer(sourceElement);
ItemPresentation containerPresentation = container == null || container instanceof PsiFile ? null : ((NavigationItem) container).getPresentation();
String containerText = containerPresentation == null ? null : containerPresentation.getPresentableText();
fullName = (containerText == null ? "" : containerText + ".") + presentation.getPresentableText();
}
return CodeInsightBundle.message("goto.implementation.chooserTitle", fullName, length, finished ? "" : " so far");
}
use of com.intellij.navigation.NavigationItem in project intellij-community by JetBrains.
the class AbstractMvcPsiNodeDescriptor method updateImpl.
@Override
protected void updateImpl(final PresentationData data) {
final PsiElement psiElement = extractPsiFromValue();
if (psiElement instanceof NavigationItem) {
final ItemPresentation presentation = ((NavigationItem) psiElement).getPresentation();
assert presentation != null;
data.setPresentableText(presentation.getPresentableText());
}
}
use of com.intellij.navigation.NavigationItem in project intellij-community by JetBrains.
the class XsltElementImpl method navigate.
@Override
public void navigate(boolean b) {
final XmlAttributeValue nameElement = getNameElement();
assert nameElement != null;
((NavigationItem) nameElement).navigate(b);
}
use of com.intellij.navigation.NavigationItem in project intellij-community by JetBrains.
the class SourceCodeChecker method check.
private static ThreeState check(Location location, SourcePosition position, Project project) {
Method method = DebuggerUtilsEx.getMethod(location);
// for now skip constructors, bridges, lambdas etc.
if (method == null || method.isConstructor() || method.isSynthetic() || method.isBridge() || method.isStaticInitializer() || (method.declaringType() instanceof ClassType && ((ClassType) method.declaringType()).isEnum()) || DebuggerUtilsEx.isLambda(method)) {
return ThreeState.UNSURE;
}
List<Location> locations = DebuggerUtilsEx.allLineLocations(method);
if (ContainerUtil.isEmpty(locations)) {
return ThreeState.UNSURE;
}
if (position != null) {
return ReadAction.compute(() -> {
PsiFile psiFile = position.getFile();
if (!psiFile.getLanguage().isKindOf(JavaLanguage.INSTANCE)) {
// only for java for now
return ThreeState.UNSURE;
}
Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
if (document == null) {
return ThreeState.UNSURE;
}
boolean res = false;
PsiElement psiMethod = DebuggerUtilsEx.getContainingMethod(position);
if (psiMethod != null) {
TextRange range = psiMethod.getTextRange();
if (psiMethod instanceof PsiDocCommentOwner) {
PsiDocComment comment = ((PsiDocCommentOwner) psiMethod).getDocComment();
if (comment != null) {
range = new TextRange(comment.getTextRange().getEndOffset() + 1, range.getEndOffset());
}
}
int startLine = document.getLineNumber(range.getStartOffset()) + 1;
int endLine = document.getLineNumber(range.getEndOffset()) + 1;
res = getLinesStream(locations, psiFile).allMatch(line -> startLine <= line && line <= endLine);
if (!res) {
LOG.debug("Source check failed: Method " + method.name() + ", source: " + ((NavigationItem) psiMethod).getName() + "\nLines: " + getLinesStream(locations, psiFile).joining(", ") + "\nExpected range: " + startLine + "-" + endLine);
}
} else {
LOG.debug("Source check failed: method " + method.name() + " not found in sources");
}
if (!res) {
FileEditor editor = FileEditorManager.getInstance(project).getSelectedEditor(position.getFile().getVirtualFile());
if (editor instanceof TextEditor) {
AppUIUtil.invokeOnEdt(() -> HintManager.getInstance().showErrorHint(((TextEditor) editor).getEditor(), DebuggerBundle.message("warning.source.code.not.match")));
} else {
XDebugSessionImpl.NOTIFICATION_GROUP.createNotification(DebuggerBundle.message("warning.source.code.not.match"), NotificationType.WARNING).notify(project);
}
return ThreeState.NO;
}
return ThreeState.YES;
});
}
return ThreeState.YES;
}
Aggregations