Search in sources :

Example 41 with THashMap

use of gnu.trove.THashMap in project intellij-community by JetBrains.

the class MacroManagerTest method getContext.

public DataContext getContext(VirtualFile file) {
    Project project = myFixture.getProject();
    Map<String, Object> dataId2data = new THashMap<>();
    dataId2data.put(CommonDataKeys.PROJECT.getName(), project);
    dataId2data.put(CommonDataKeys.VIRTUAL_FILE.getName(), file);
    dataId2data.put(PlatformDataKeys.PROJECT_FILE_DIRECTORY.getName(), project.getBaseDir());
    return SimpleDataContext.getSimpleContext(dataId2data, null);
}
Also used : Project(com.intellij.openapi.project.Project) THashMap(gnu.trove.THashMap)

Example 42 with THashMap

use of gnu.trove.THashMap in project intellij-community by JetBrains.

the class RunConfigurationExtensionsManager method readExternal.

public void readExternal(@NotNull U configuration, @NotNull Element parentNode) throws InvalidDataException {
    Map<String, T> extensions = new THashMap<>();
    for (T extension : getApplicableExtensions(configuration)) {
        extensions.put(extension.getSerializationId(), extension);
    }
    List<Element> children = parentNode.getChildren(getExtensionRootAttr());
    // if some of extensions settings weren't found we should just keep it because some plugin with extension
    // may be turned off
    boolean found = true;
    for (Element element : children) {
        final T extension = extensions.remove(element.getAttributeValue(getIdAttrName()));
        if (extension != null) {
            extension.readExternal(configuration, element);
        } else {
            found = false;
        }
    }
    if (!found) {
        List<Element> copy = new ArrayList<>(children.size());
        for (Element child : children) {
            copy.add(child.clone());
        }
        configuration.putCopyableUserData(RUN_EXTENSIONS, copy);
    }
}
Also used : THashMap(gnu.trove.THashMap) Element(org.jdom.Element) ArrayList(java.util.ArrayList)

Example 43 with THashMap

use of gnu.trove.THashMap in project intellij-community by JetBrains.

the class OptionTableWithPreviewPanel method createOptionsTree.

protected TreeTable createOptionsTree(CodeStyleSettings settings) {
    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
    Map<String, DefaultMutableTreeNode> groupsMap = new THashMap<>();
    List<Option> sorted = sortOptions(ContainerUtil.concat(myOptions, myCustomOptions));
    for (Option each : sorted) {
        if (!(myCustomOptions.contains(each) || myAllowedOptions.contains(each.field.getName()) || myShowAllStandardOptions))
            continue;
        String group = each.groupName;
        MyTreeNode newNode = new MyTreeNode(each, each.title, settings);
        DefaultMutableTreeNode groupNode = groupsMap.get(group);
        if (groupNode != null) {
            groupNode.add(newNode);
        } else {
            String groupName;
            if (group == null) {
                groupName = each.title;
                groupNode = newNode;
            } else {
                groupName = group;
                groupNode = new DefaultMutableTreeNode(groupName);
                groupNode.add(newNode);
            }
            groupsMap.put(groupName, groupNode);
            rootNode.add(groupNode);
        }
    }
    ListTreeTableModel model = new ListTreeTableModel(rootNode, COLUMNS);
    TreeTable treeTable = new TreeTable(model) {

        @Override
        public TreeTableCellRenderer createTableRenderer(TreeTableModel treeTableModel) {
            TreeTableCellRenderer tableRenderer = super.createTableRenderer(treeTableModel);
            UIUtil.setLineStyleAngled(tableRenderer);
            tableRenderer.setRootVisible(false);
            tableRenderer.setShowsRootHandles(true);
            return tableRenderer;
        }

        @Override
        public TableCellRenderer getCellRenderer(int row, int column) {
            TreePath treePath = getTree().getPathForRow(row);
            if (treePath == null)
                return super.getCellRenderer(row, column);
            Object node = treePath.getLastPathComponent();
            @SuppressWarnings("unchecked") TableCellRenderer renderer = COLUMNS[column].getRenderer(node);
            return renderer == null ? super.getCellRenderer(row, column) : renderer;
        }

        @Override
        public TableCellEditor getCellEditor(int row, int column) {
            TreePath treePath = getTree().getPathForRow(row);
            if (treePath == null)
                return super.getCellEditor(row, column);
            Object node = treePath.getLastPathComponent();
            @SuppressWarnings("unchecked") TableCellEditor editor = COLUMNS[column].getEditor(node);
            return editor == null ? super.getCellEditor(row, column) : editor;
        }
    };
    new TreeTableSpeedSearch(treeTable).setComparator(new SpeedSearchComparator(false));
    treeTable.setRootVisible(false);
    final JTree tree = treeTable.getTree();
    tree.setCellRenderer(myTitleRenderer);
    tree.setShowsRootHandles(true);
    //myTreeTable.setRowHeight(new JComboBox(new String[]{"Sample Text"}).getPreferredSize().height);
    treeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    treeTable.setTableHeader(null);
    TreeUtil.expandAll(tree);
    treeTable.getColumnModel().getSelectionModel().setAnchorSelectionIndex(1);
    treeTable.getColumnModel().getSelectionModel().setLeadSelectionIndex(1);
    int maxWidth = tree.getPreferredScrollableViewportSize().width + 10;
    final TableColumn titleColumn = treeTable.getColumnModel().getColumn(0);
    titleColumn.setPreferredWidth(maxWidth);
    titleColumn.setMinWidth(maxWidth);
    titleColumn.setMaxWidth(maxWidth);
    titleColumn.setResizable(false);
    //final TableColumn levelColumn = treeTable.getColumnModel().getColumn(1);
    //TODO[max]: better preffered size...
    //TODO[kb]: Did I fixed it by making the last column floating?
    //levelColumn.setPreferredWidth(valueSize.width);
    //levelColumn.setMaxWidth(valueSize.width);
    //levelColumn.setMinWidth(valueSize.width);
    //levelColumn.setResizable(false);
    final Dimension valueSize = new JLabel(ApplicationBundle.message("option.table.sizing.text")).getPreferredSize();
    treeTable.setPreferredScrollableViewportSize(new Dimension(maxWidth + valueSize.width + 10, 20));
    return treeTable;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) TreeTableCellRenderer(com.intellij.ui.treeStructure.treetable.TreeTableCellRenderer) TreeTableSpeedSearch(com.intellij.ui.TreeTableSpeedSearch) TreeTable(com.intellij.ui.treeStructure.treetable.TreeTable) ListTreeTableModel(com.intellij.ui.treeStructure.treetable.ListTreeTableModel) TreeTableModel(com.intellij.ui.treeStructure.treetable.TreeTableModel) TableColumn(javax.swing.table.TableColumn) TreeTableCellRenderer(com.intellij.ui.treeStructure.treetable.TreeTableCellRenderer) THashMap(gnu.trove.THashMap) ListTreeTableModel(com.intellij.ui.treeStructure.treetable.ListTreeTableModel) AbstractTableCellEditor(com.intellij.util.ui.AbstractTableCellEditor) TableCellEditor(javax.swing.table.TableCellEditor) SpeedSearchComparator(com.intellij.ui.SpeedSearchComparator)

Example 44 with THashMap

use of gnu.trove.THashMap in project intellij-community by JetBrains.

the class RunManagerImpl method addConfigurationElement.

private void addConfigurationElement(@NotNull Element parentNode, RunnerAndConfigurationSettings settings, String elementType) {
    Element configurationElement = new Element(elementType);
    parentNode.addContent(configurationElement);
    try {
        ((RunnerAndConfigurationSettingsImpl) settings).writeExternal(configurationElement);
    } catch (WriteExternalException e) {
        throw new RuntimeException(e);
    }
    if (settings.getConfiguration() instanceof UnknownRunConfiguration) {
        return;
    }
    List<BeforeRunTask> tasks = new ArrayList<>(getBeforeRunTasks(settings.getConfiguration()));
    Map<Key<BeforeRunTask>, BeforeRunTask> templateTasks = new THashMap<>();
    List<BeforeRunTask> beforeRunTasks = settings.isTemplate() ? getHardcodedBeforeRunTasks(settings.getConfiguration()) : getBeforeRunTasks(getConfigurationTemplate(settings.getFactory()).getConfiguration());
    for (BeforeRunTask templateTask : beforeRunTasks) {
        templateTasks.put(templateTask.getProviderId(), templateTask);
        if (templateTask.isEnabled()) {
            boolean found = false;
            for (BeforeRunTask realTask : tasks) {
                if (realTask.getProviderId() == templateTask.getProviderId()) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                BeforeRunTask clone = templateTask.clone();
                clone.setEnabled(false);
                tasks.add(0, clone);
            }
        }
    }
    Element methodsElement = new Element(METHOD);
    for (int i = 0, size = tasks.size(); i < size; i++) {
        BeforeRunTask task = tasks.get(i);
        int j = 0;
        BeforeRunTask templateTask = null;
        for (Map.Entry<Key<BeforeRunTask>, BeforeRunTask> entry : templateTasks.entrySet()) {
            if (entry.getKey() == task.getProviderId()) {
                templateTask = entry.getValue();
                break;
            }
            j++;
        }
        if (task.equals(templateTask) && i == j) {
            // not necessary saving if the task is the same as template and on the same place
            continue;
        }
        Element child = new Element(OPTION);
        child.setAttribute(NAME_ATTR, task.getProviderId().toString());
        task.writeExternal(child);
        methodsElement.addContent(child);
    }
    configurationElement.addContent(methodsElement);
}
Also used : Element(org.jdom.Element) THashMap(gnu.trove.THashMap) HashMap(com.intellij.util.containers.HashMap) THashMap(gnu.trove.THashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) WeakHashMap(com.intellij.util.containers.WeakHashMap)

Example 45 with THashMap

use of gnu.trove.THashMap in project intellij-community by JetBrains.

the class GenericsHighlightUtil method checkOverrideEquivalentMethods.

static Collection<HighlightInfo> checkOverrideEquivalentMethods(@NotNull PsiClass aClass) {
    List<HighlightInfo> result = new ArrayList<>();
    final Collection<HierarchicalMethodSignature> signaturesWithSupers = aClass.getVisibleSignatures();
    PsiManager manager = aClass.getManager();
    Map<MethodSignature, MethodSignatureBackedByPsiMethod> sameErasureMethods = new THashMap<>(MethodSignatureUtil.METHOD_PARAMETERS_ERASURE_EQUALITY);
    final Set<MethodSignature> foundProblems = new THashSet<>(MethodSignatureUtil.METHOD_PARAMETERS_ERASURE_EQUALITY);
    for (HierarchicalMethodSignature signature : signaturesWithSupers) {
        HighlightInfo info = checkSameErasureNotSubSignatureInner(signature, manager, aClass, sameErasureMethods);
        if (info != null && foundProblems.add(signature)) {
            result.add(info);
        }
        if (aClass instanceof PsiTypeParameter) {
            info = HighlightMethodUtil.checkMethodIncompatibleReturnType(signature, signature.getSuperSignatures(), true, HighlightNamesUtil.getClassDeclarationTextRange(aClass));
            if (info != null) {
                result.add(info);
            }
        }
    }
    return result.isEmpty() ? null : result;
}
Also used : HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo) THashSet(gnu.trove.THashSet) THashMap(gnu.trove.THashMap)

Aggregations

THashMap (gnu.trove.THashMap)132 NotNull (org.jetbrains.annotations.NotNull)33 THashSet (gnu.trove.THashSet)27 VirtualFile (com.intellij.openapi.vfs.VirtualFile)19 Element (org.jdom.Element)18 PsiElement (com.intellij.psi.PsiElement)17 IOException (java.io.IOException)17 File (java.io.File)15 Map (java.util.Map)11 Nullable (org.jetbrains.annotations.Nullable)10 Project (com.intellij.openapi.project.Project)9 List (java.util.List)9 Module (com.intellij.openapi.module.Module)8 Pair (com.intellij.openapi.util.Pair)7 PsiFile (com.intellij.psi.PsiFile)7 ArrayList (java.util.ArrayList)7 java.util (java.util)6 ApplicationManager (com.intellij.openapi.application.ApplicationManager)5 Document (com.intellij.openapi.editor.Document)5 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)5