use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class PerFileMappingsBase method loadState.
@Override
public void loadState(final Element state) {
synchronized (myMappings) {
final THashMap<String, T> dialectMap = new THashMap<>();
for (T dialect : getAvailableValues()) {
String key = serialize(dialect);
if (key != null) {
dialectMap.put(key, dialect);
}
}
myMappings.clear();
final List<Element> files = state.getChildren("file");
for (Element fileElement : files) {
final String url = fileElement.getAttributeValue("url");
final String dialectID = fileElement.getAttributeValue(getValueAttribute());
final VirtualFile file = url.equals("PROJECT") ? null : VirtualFileManager.getInstance().findFileByUrl(url);
T dialect = dialectMap.get(dialectID);
if (dialect == null) {
dialect = handleUnknownMapping(file, dialectID);
if (dialect == null)
continue;
}
if (file != null || url.equals("PROJECT")) {
myMappings.put(file, dialect);
}
}
}
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class Configuration method loadState.
@Override
public void loadState(final Element element) {
myInjections.clear();
List<Element> injectionElements = element.getChildren("injection");
if (!injectionElements.isEmpty()) {
final Map<String, LanguageInjectionSupport> supports = new THashMap<>();
for (LanguageInjectionSupport support : InjectorUtils.getActiveInjectionSupports()) {
supports.put(support.getId(), support);
}
for (Element child : injectionElements) {
final String key = child.getAttributeValue("injector-id");
final LanguageInjectionSupport support = supports.get(key);
final BaseInjection injection = support == null ? new BaseInjection(key) : support.createInjection(child);
injection.loadState(child);
InjectionPlace[] places = dropKnownInvalidPlaces(injection.getInjectionPlaces());
if (places != null) {
// not all places were removed
injection.setInjectionPlaces(places);
myInjections.get(key).add(injection);
}
}
}
importPlaces(getDefaultInjections());
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class RevisionsList method updateData.
public void updateData(HistoryDialogModel model) {
Set<Long> sel = new THashSet<>();
MyModel m = (MyModel) table.getModel();
for (int i : table.getSelectedRows()) {
if (i >= m.getRowCount())
continue;
sel.add(m.getValueAt(i, 0).revision.getChangeSetId());
}
List<RevisionItem> newRevs = model.getRevisions();
Date today = new Date();
Map<RevisionItem, Period> periods = new THashMap<>();
for (int i = 0; i < newRevs.size(); i++) {
RevisionItem each = newRevs.get(i);
boolean recent = today.getTime() - each.revision.getTimestamp() < 1000 * 60 * 60 * RECENT_PERIOD;
if (recent) {
if (i == 0) {
periods.put(each, Period.RECENT);
}
} else {
periods.put(each, periods.isEmpty() ? Period.OLD : Period.OLDER);
break;
}
}
table.setModel(new MyModel(newRevs, periods));
for (int i = 0; i < newRevs.size(); i++) {
RevisionItem r = newRevs.get(i);
if (sel.contains(r.revision.getChangeSetId())) {
table.getSelectionModel().addSelectionInterval(i, i);
}
}
if (table.getSelectionModel().isSelectionEmpty()) {
table.getSelectionModel().addSelectionInterval(0, 0);
}
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class GeneralCommandLine method setupEnvironment.
protected void setupEnvironment(@NotNull Map<String, String> environment) {
environment.clear();
if (myParentEnvironmentType != ParentEnvironmentType.NONE) {
environment.putAll(getParentEnvironment());
}
if (SystemInfo.isUnix) {
File workDirectory = getWorkDirectory();
if (workDirectory != null) {
environment.put("PWD", FileUtil.toSystemDependentName(workDirectory.getAbsolutePath()));
}
}
if (!myEnvParams.isEmpty()) {
if (SystemInfo.isWindows) {
THashMap<String, String> envVars = new THashMap<>(CaseInsensitiveStringHashingStrategy.INSTANCE);
envVars.putAll(environment);
envVars.putAll(myEnvParams);
environment.clear();
environment.putAll(envVars);
} else {
environment.putAll(myEnvParams);
}
}
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class SharedProcessingContext method put.
public <T> void put(@NotNull Key<T> key, Object element, T value) {
Map map = (Map) myMap.get(key);
if (map == null) {
map = new THashMap();
myMap.put(key, map);
}
map.put(element, value);
}
Aggregations