com.intellij.psi.PsiCompiledElement Java Examples
The following examples show how to use
com.intellij.psi.PsiCompiledElement.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractDelombokAction.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
private boolean isValidForFile(@NotNull Editor editor, @NotNull PsiFile file) { if (!(file instanceof PsiJavaFile)) { return false; } if (file instanceof PsiCompiledElement) { return false; } if (!file.isWritable()) { return false; } PsiClass targetClass = getTargetClass(editor, file); return targetClass != null && isValidForClass(targetClass); }
Example #2
Source File: FindUsagesHelper.java From consulo with Apache License 2.0 | 5 votes |
public static boolean processUsagesInText(@Nonnull final PsiElement element, @Nonnull Collection<String> stringToSearch, @Nonnull GlobalSearchScope searchScope, @Nonnull Processor<UsageInfo> processor) { final TextRange elementTextRange = ApplicationManager.getApplication().runReadAction(new NullableComputable<TextRange>() { @Override public TextRange compute() { if (!element.isValid() || element instanceof PsiCompiledElement) return null; return element.getTextRange(); } }); UsageInfoFactory factory = new UsageInfoFactory() { @Override public UsageInfo createUsageInfo(@Nonnull PsiElement usage, int startOffset, int endOffset) { if (elementTextRange != null && usage.getContainingFile() == element.getContainingFile() && elementTextRange.contains(startOffset) && elementTextRange.contains(endOffset)) { return null; } PsiReference someReference = usage.findReferenceAt(startOffset); if (someReference != null) { PsiElement refElement = someReference.getElement(); for (PsiReference ref : PsiReferenceService.getService().getReferences(refElement, new PsiReferenceService.Hints(element, null))) { if (element.getManager().areElementsEquivalent(ref.resolve(), element)) { TextRange range = ref.getRangeInElement().shiftRight(refElement.getTextRange().getStartOffset() - usage.getTextRange().getStartOffset()); return new UsageInfo(usage, range.getStartOffset(), range.getEndOffset(), true); } } } return new UsageInfo(usage, startOffset, endOffset, true); } }; for (String s : stringToSearch) { if (!PsiSearchHelperImpl.processTextOccurrences(element, s, searchScope, processor, factory)) return false; } return true; }
Example #3
Source File: SurroundWithHandler.java From consulo with Apache License 2.0 | 5 votes |
public static void invoke(@Nonnull Project project, @Nonnull Editor editor, @Nonnull PsiFile file, Surrounder surrounder) { if (!CodeInsightUtilBase.prepareEditorForWrite(editor)) return; if (file instanceof PsiCompiledElement) { HintManager.getInstance().showErrorHint(editor, "Can't modify decompiled code"); return; } List<AnAction> applicable = buildSurroundActions(project, editor, file, surrounder); if (applicable != null) { showPopup(editor, applicable); } else if (!ApplicationManager.getApplication().isUnitTestMode()) { HintManager.getInstance().showErrorHint(editor, "Couldn't find Surround With variants applicable to the current context"); } }
Example #4
Source File: ImageOrColorPreviewManager.java From consulo with Apache License 2.0 | 5 votes |
private void registerListeners(final Editor editor) { if (editor.isOneLineMode()) { return; } Project project = editor.getProject(); if (project == null || project.isDisposed()) { return; } PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (psiFile == null || psiFile instanceof PsiCompiledElement || !isSupportedFile(psiFile)) { return; } editor.addEditorMouseMotionListener(this); KeyListener keyListener = new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SHIFT && !editor.isOneLineMode()) { PointerInfo pointerInfo = MouseInfo.getPointerInfo(); if (pointerInfo != null) { Point location = pointerInfo.getLocation(); SwingUtilities.convertPointFromScreen(location, editor.getContentComponent()); alarm.cancelAllRequests(); alarm.addRequest(new PreviewRequest(location, editor, true), 100); } } } }; editor.getContentComponent().addKeyListener(keyListener); EDITOR_LISTENER_ADDED.set(editor, keyListener); }
Example #5
Source File: ImageOrColorPreviewManager.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static Collection<PsiElement> getPsiElementsAt(Point point, Editor editor) { if (editor.isDisposed()) { return Collections.emptySet(); } Project project = editor.getProject(); if (project == null || project.isDisposed()) { return Collections.emptySet(); } final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project); final Document document = editor.getDocument(); PsiFile psiFile = documentManager.getPsiFile(document); if (psiFile == null || psiFile instanceof PsiCompiledElement || !psiFile.isValid()) { return Collections.emptySet(); } final Set<PsiElement> elements = Collections.newSetFromMap(ContainerUtil.createWeakMap()); final int offset = editor.logicalPositionToOffset(editor.xyToLogicalPosition(point)); if (documentManager.isCommitted(document)) { ContainerUtil.addIfNotNull(elements, InjectedLanguageUtil.findElementAtNoCommit(psiFile, offset)); } for (PsiFile file : psiFile.getViewProvider().getAllFiles()) { ContainerUtil.addIfNotNull(elements, file.findElementAt(offset)); } return elements; }
Example #6
Source File: NavBarModelBuilderImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private static PsiElement getOriginalElement(@Nullable PsiElement e) { if (e == null || !e.isValid()) return null; PsiFile containingFile = e.getContainingFile(); if (containingFile != null && containingFile.getVirtualFile() == null) return null; PsiElement orig = e.getOriginalElement(); return !(e instanceof PsiCompiledElement) && orig instanceof PsiCompiledElement ? e : orig; }
Example #7
Source File: MemberChooser.java From consulo with Apache License 2.0 | 5 votes |
@Override public int compare(ElementNode n1, ElementNode n2) { if (n1.getDelegate() instanceof ClassMemberWithElement && n2.getDelegate() instanceof ClassMemberWithElement) { PsiElement element1 = ((ClassMemberWithElement)n1.getDelegate()).getElement(); PsiElement element2 = ((ClassMemberWithElement)n2.getDelegate()).getElement(); if (!(element1 instanceof PsiCompiledElement) && !(element2 instanceof PsiCompiledElement)) { return element1.getTextOffset() - element2.getTextOffset(); } } return n1.getOrder() - n2.getOrder(); }
Example #8
Source File: PsiTypeUtils.java From intellij-quarkus with Eclipse Public License 2.0 | 4 votes |
public static boolean isBinary(PsiModifierListOwner psiMember) { return psiMember instanceof PsiCompiledElement; }
Example #9
Source File: DefaultChooseByNameItemProvider.java From consulo with Apache License 2.0 | 4 votes |
private static boolean isCompiledWithoutSource(Object o) { return o instanceof PsiCompiledElement && ((PsiCompiledElement)o).getNavigationElement() == o; }