public static ClassFilter[] readFilters(List<Element> children) throws InvalidDataException { if (ContainerUtil.isEmpty(children)) { return ClassFilter.EMPTY_ARRAY; } ClassFilter[] filters = new ClassFilter[children.size()]; for (int i = 0, size = children.size(); i < size; i++) { filters[i] = create(children.get(i)); } return filters; }
private static boolean elementListsEqual(List<Element> l1, List<Element> l2) { if (l1 == null) return l2 == null; if (l2 == null) return false; if (l1.size() != l2.size()) return false; Iterator<Element> i1 = l1.iterator(); for (Element aL2 : l2) { Element elem1 = i1.next(); if (!elementsEqual(elem1, aL2)) return false; } return true; }
/** * @param context * @return all CodeFragmentFactoryProviders that provide code fragment factories suitable in the * context given */ public static List<CodeFragmentFactory> getCodeFragmentFactories(@Nullable PsiElement context) { final DefaultCodeFragmentFactory defaultFactory = DefaultCodeFragmentFactory.getInstance(); final CodeFragmentFactory[] providers = ApplicationManager.getApplication().getExtensions(CodeFragmentFactory.EXTENSION_POINT_NAME); final List<CodeFragmentFactory> suitableFactories = new ArrayList<CodeFragmentFactory>(providers.length); if (providers.length > 0) { for (CodeFragmentFactory factory : providers) { if (factory != defaultFactory && factory.isContextAccepted(context)) { suitableFactories.add(factory); } } } suitableFactories.add(defaultFactory); // let default factory be the last one return suitableFactories; }
public static List<PsiLambdaExpression> collectLambdas( @NotNull SourcePosition position, final boolean onlyOnTheLine) { ApplicationManager.getApplication().assertReadAccessAllowed(); PsiFile file = position.getFile(); final int line = position.getLine(); final Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file); if (document == null || line >= document.getLineCount()) { return Collections.emptyList(); } PsiElement element = position.getElementAt(); final TextRange lineRange = DocumentUtil.getLineTextRange(document, line); do { PsiElement parent = element.getParent(); if (parent == null || (parent.getTextOffset() < lineRange.getStartOffset())) { break; } element = parent; } while (true); final List<PsiLambdaExpression> lambdas = new ArrayList<PsiLambdaExpression>(3); final PsiElementVisitor lambdaCollector = new JavaRecursiveElementVisitor() { @Override public void visitLambdaExpression(PsiLambdaExpression expression) { super.visitLambdaExpression(expression); if (!onlyOnTheLine || getFirstElementOnTheLine(expression, document, line) != null) { lambdas.add(expression); } } }; element.accept(lambdaCollector); // add initial lambda if we're inside already PsiElement method = getContainingMethod(element); if (method instanceof PsiLambdaExpression) { lambdas.add((PsiLambdaExpression) method); } for (PsiElement sibling = getNextElement(element); sibling != null; sibling = getNextElement(sibling)) { if (!intersects(lineRange, sibling)) { break; } sibling.accept(lambdaCollector); } return lambdas; }
private static boolean attributeListsEqual(List<Attribute> l1, List<Attribute> l2) { if (l1 == null) return l2 == null; if (l2 == null) return false; if (l1.size() != l2.size()) return false; Iterator<Attribute> i1 = l1.iterator(); for (Attribute aL2 : l2) { Attribute attr1 = i1.next(); if (!Comparing.equal(attr1.getName(), aL2.getName()) || !Comparing.equal(attr1.getValue(), aL2.getValue())) { return false; } } return true; }
public static void addThreadDump( Project project, List<ThreadState> threads, final RunnerLayoutUi ui, DebuggerSession session) { final TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(project); consoleBuilder.filters(ExceptionFilters.getFilters(session.getSearchScope())); final ConsoleView consoleView = consoleBuilder.getConsole(); final DefaultActionGroup toolbarActions = new DefaultActionGroup(); consoleView.allowHeavyFilters(); final ThreadDumpPanel panel = new ThreadDumpPanel(project, consoleView, toolbarActions, threads); final String id = THREAD_DUMP_CONTENT_PREFIX + " #" + myCurrentThreadDumpId; final Content content = ui.createContent(id, panel, id, null, null); content.putUserData(RunnerContentUi.LIGHTWEIGHT_CONTENT_MARKER, Boolean.TRUE); content.setCloseable(true); content.setDescription("Thread Dump"); ui.addContent(content); ui.selectAndFocus(content, true, true); myThreadDumpsCount++; myCurrentThreadDumpId++; Disposer.register( content, new Disposable() { @Override public void dispose() { myThreadDumpsCount--; if (myThreadDumpsCount == 0) { myCurrentThreadDumpId = 1; } } }); Disposer.register(content, consoleView); ui.selectAndFocus(content, true, false); if (threads.size() > 0) { panel.selectStackFrame(0); } }
@Override public void removeClassNameMapper(final NameMapper mapper) { myNameMappers.remove(mapper); }
@Override public void addClassNameMapper(final NameMapper mapper) { myNameMappers.add(mapper); }