use of com.intellij.pom.Navigatable in project android by JetBrains.
the class OpenFileHyperlink method execute.
@Override
protected void execute(@NotNull Project project) {
VirtualFile projectFile = project.getProjectFile();
if (projectFile == null) {
// This is the default project. This will NEVER happen.
return;
}
VirtualFile file = projectFile.getParent().getFileSystem().findFileByPath(myFilePath);
if (file != null) {
Navigatable openFile = new OpenFileDescriptor(project, file, myLineNumber, myColumn, false);
if (openFile.canNavigate()) {
openFile.navigate(true);
}
}
}
use of com.intellij.pom.Navigatable in project intellij-plugins by JetBrains.
the class ResolveExternalInlineStyleSourceAction method find.
private Navigatable find(XmlTag parent, boolean firstLevel) {
for (XmlTag xmlTag : parent.getSubTags()) {
String localName = xmlTag.getLocalName();
if (firstLevel && ignoredRootTags.contains(localName)) {
continue;
}
XmlElementDescriptor xmlTagDescriptor = xmlTag.getDescriptor();
if (xmlTagDescriptor instanceof ClassBackedElementDescriptor) {
Navigatable result;
if (xmlTagDescriptor.getQualifiedName().equals(elementFqn)) {
result = findTargetIfStyleDeclarationOwner(xmlTag);
if (result != null) {
return result;
}
}
result = find(xmlTag, false);
if (result != null) {
return result;
}
}
}
return null;
}
use of com.intellij.pom.Navigatable in project intellij-plugins by JetBrains.
the class ResolveExternalInlineStyleSourceAction method findTargetIfStyleDeclarationOwner.
private Navigatable findTargetIfStyleDeclarationOwner(XmlTag parent) {
int foundCount = 0;
Navigatable target = null;
for (XmlAttribute attribute : parent.getAttributes()) {
XmlAttributeDescriptor descriptor = attribute.getDescriptor();
// 8
if (descriptor instanceof AnnotationBackedDescriptor) {
String ourValue = properties.get(descriptor.getName());
if (ourValue != null) {
if (attribute.getDisplayValue().equals(ourValue)) {
foundCount++;
if (descriptor.getName().equals(targetStyleName)) {
target = (Navigatable) attribute;
}
if (foundCount == properties.size()) {
return target;
}
}
}
}
}
for (XmlTag tag : parent.getSubTags()) {
XmlElementDescriptor descriptor = tag.getDescriptor();
if (descriptor instanceof AnnotationBackedDescriptor && ((PsiPresentableMetaData) descriptor).getTypeName().equals(FlexAnnotationNames.STYLE)) {
String ourValue = properties.get(descriptor.getName());
if (ourValue != null) {
if (tag.getSubTags().length == 0 && tag.getValue().getTrimmedText().equals(ourValue)) {
foundCount++;
if (descriptor.getName().equals(targetStyleName)) {
target = (Navigatable) tag;
}
if (foundCount == properties.size()) {
return target;
}
}
}
}
}
return null;
}
use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class SlicePanel method createTree.
@NotNull
private JTree createTree() {
DefaultMutableTreeNode root = new DefaultMutableTreeNode();
final Tree tree = new Tree(new DefaultTreeModel(root));
tree.setOpaque(false);
tree.setToggleClickCount(-1);
SliceUsageCellRendererBase renderer = myProvider.getRenderer();
renderer.setOpaque(false);
tree.setCellRenderer(renderer);
UIUtil.setLineStyleAngled(tree);
tree.setRootVisible(false);
tree.setShowsRootHandles(true);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.setSelectionPath(new TreePath(root.getPath()));
//ActionGroup group = (ActionGroup)ActionManager.getInstance().getAction(IdeActions.GROUP_METHOD_HIERARCHY_POPUP);
//PopupHandler.installPopupHandler(tree, group, ActionPlaces.METHOD_HIERARCHY_VIEW_POPUP, ActionManager.getInstance());
EditSourceOnDoubleClickHandler.install(tree);
new TreeSpeedSearch(tree);
TreeUtil.installActions(tree);
ToolTipManager.sharedInstance().registerComponent(tree);
myAutoScrollToSourceHandler.install(tree);
tree.getSelectionModel().addTreeSelectionListener(e -> treeSelectionChanged());
tree.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (KeyEvent.VK_ENTER == e.getKeyCode()) {
List<Navigatable> navigatables = getNavigatables();
if (navigatables.isEmpty())
return;
for (Navigatable navigatable : navigatables) {
if (navigatable instanceof AbstractTreeNode && ((AbstractTreeNode) navigatable).getValue() instanceof Usage) {
navigatable = (Usage) ((AbstractTreeNode) navigatable).getValue();
}
if (navigatable.canNavigateToSource()) {
navigatable.navigate(false);
if (navigatable instanceof Usage) {
((Usage) navigatable).highlightInEditor();
}
}
}
e.consume();
}
}
});
tree.addTreeWillExpandListener(new TreeWillExpandListener() {
@Override
public void treeWillCollapse(TreeExpansionEvent event) {
}
@Override
public void treeWillExpand(TreeExpansionEvent event) {
TreePath path = event.getPath();
SliceNode node = fromPath(path);
node.calculateDupNode();
}
});
return tree;
}
use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class XDebuggerUtilImpl method createPositionByElement.
@Override
@Nullable
public XSourcePosition createPositionByElement(PsiElement element) {
if (element == null)
return null;
PsiFile psiFile = element.getContainingFile();
if (psiFile == null)
return null;
final VirtualFile file = psiFile.getVirtualFile();
if (file == null)
return null;
final SmartPsiElementPointer<PsiElement> pointer = SmartPointerManager.getInstance(element.getProject()).createSmartPsiElementPointer(element);
return new XSourcePosition() {
private volatile XSourcePosition myDelegate;
private XSourcePosition getDelegate() {
if (myDelegate == null) {
myDelegate = ReadAction.compute(() -> {
PsiElement elem = pointer.getElement();
return XSourcePositionImpl.createByOffset(pointer.getVirtualFile(), elem != null ? elem.getTextOffset() : -1);
});
}
return myDelegate;
}
@Override
public int getLine() {
return getDelegate().getLine();
}
@Override
public int getOffset() {
return getDelegate().getOffset();
}
@NotNull
@Override
public VirtualFile getFile() {
return file;
}
@NotNull
@Override
public Navigatable createNavigatable(@NotNull Project project) {
// no need to create delegate here, it may be expensive
if (myDelegate != null) {
return myDelegate.createNavigatable(project);
}
PsiElement elem = pointer.getElement();
if (elem instanceof Navigatable) {
return ((Navigatable) elem);
}
return NonNavigatable.INSTANCE;
}
};
}
Aggregations