private static void addDynamicAnnotation( HighlightInfo info, GrReferenceExpression referenceExpression, HighlightDisplayKey key) { final PsiFile containingFile = referenceExpression.getContainingFile(); if (containingFile != null) { VirtualFile file = containingFile.getVirtualFile(); if (file == null) return; } else { return; } if (isCall(referenceExpression)) { PsiType[] argumentTypes = PsiUtil.getArgumentTypes(referenceExpression, false); if (argumentTypes != null) { QuickFixAction.registerQuickFixAction( info, referenceExpression.getTextRange(), new DynamicMethodFix(referenceExpression, argumentTypes), key); } } else { QuickFixAction.registerQuickFixAction( info, referenceExpression.getTextRange(), new DynamicPropertyFix(referenceExpression), key); } }
@Nullable public static PsiElement getOriginalElement(PsiClass clazz, PsiFile containingFile) { VirtualFile vFile = containingFile.getVirtualFile(); final JavaPsiFacade facade = JavaPsiFacade.getInstance(clazz.getProject()); final ProjectFileIndex idx = ProjectRootManager.getInstance(facade.getProject()).getFileIndex(); if (vFile == null || !idx.isInLibrarySource(vFile)) return clazz; final String qName = clazz.getQualifiedName(); if (qName == null) return null; final List<OrderEntry> orderEntries = idx.getOrderEntriesForFile(vFile); PsiClass original = facade.findClass( qName, new GlobalSearchScope(facade.getProject()) { public int compare(VirtualFile file1, VirtualFile file2) { return 0; } public boolean contains(VirtualFile file) { // order for file and vFile has non empty intersection. List<OrderEntry> entries = idx.getOrderEntriesForFile(file); //noinspection ForLoopReplaceableByForEach for (int i = 0; i < entries.size(); i++) { final OrderEntry entry = entries.get(i); if (orderEntries.contains(entry)) return true; } return false; } public boolean isSearchInModuleContent(@NotNull Module aModule) { return false; } public boolean isSearchInLibraries() { return true; } }); return original != null ? original : clazz; }
private void error(String descr) { PsiFile file = myScope.getContainingFile(); String fileText = file != null ? file.getText() : null; LogMessageEx.error(LOG, descr, myScope.getText(), "\n------------------\n", fileText); }