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);
}
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);
}
}
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;
}
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);
}
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;
}
Aggregations