use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class GradleResourceCompilerConfigurationGenerator method generateBuildConfiguration.
public void generateBuildConfiguration(@NotNull final CompileContext context) {
if (shouldBeBuiltByExternalSystem(myProject))
return;
if (!hasGradleModules(context))
return;
final BuildManager buildManager = BuildManager.getInstance();
final File projectSystemDir = buildManager.getProjectSystemDirectory(myProject);
if (projectSystemDir == null)
return;
final File gradleConfigFile = new File(projectSystemDir, GradleProjectConfiguration.CONFIGURATION_FILE_RELATIVE_PATH);
final Map<String, GradleModuleResourceConfiguration> affectedGradleModuleConfigurations = generateAffectedGradleModulesConfiguration(context);
if (affectedGradleModuleConfigurations.isEmpty())
return;
boolean configurationUpdateRequired = context.isRebuild() || !gradleConfigFile.exists();
final Map<String, Integer> affectedConfigurationHash = new THashMap<>();
for (Map.Entry<String, GradleModuleResourceConfiguration> entry : affectedGradleModuleConfigurations.entrySet()) {
Integer moduleLastConfigurationHash = myModulesConfigurationHash.get(entry.getKey());
int moduleCurrentConfigurationHash = entry.getValue().computeConfigurationHash();
if (moduleLastConfigurationHash == null || moduleLastConfigurationHash.intValue() != moduleCurrentConfigurationHash) {
configurationUpdateRequired = true;
}
affectedConfigurationHash.put(entry.getKey(), moduleCurrentConfigurationHash);
}
final GradleProjectConfiguration projectConfig = loadLastConfiguration(gradleConfigFile);
// update with newly generated configuration
projectConfig.moduleConfigurations.putAll(affectedGradleModuleConfigurations);
final Element element = new Element("gradle-project-configuration");
XmlSerializer.serializeInto(projectConfig, element);
final boolean finalConfigurationUpdateRequired = configurationUpdateRequired;
buildManager.runCommand(() -> {
if (finalConfigurationUpdateRequired) {
buildManager.clearState(myProject);
}
FileUtil.createIfDoesntExist(gradleConfigFile);
try {
JdomKt.write(element, gradleConfigFile.toPath());
myModulesConfigurationHash.putAll(affectedConfigurationHash);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class ExternalProjectSerializer method configureKryo.
private void configureKryo() {
myKryo.setAutoReset(true);
myKryo.setRegistrationRequired(true);
Log.set(Log.LEVEL_WARN);
myKryo.register(ArrayList.class, new CollectionSerializer() {
@Override
protected Collection create(Kryo kryo, Input input, Class<Collection> type) {
return new ArrayList();
}
});
myKryo.register(HashMap.class, new MapSerializer() {
@Override
protected Map create(Kryo kryo, Input input, Class<Map> type) {
return new HashMap();
}
});
myKryo.register(HashSet.class, new CollectionSerializer() {
@Override
protected Collection create(Kryo kryo, Input input, Class<Collection> type) {
return new HashSet();
}
});
myKryo.register(File.class, new FileSerializer());
myKryo.register(DefaultExternalProject.class, new FieldSerializer<DefaultExternalProject>(myKryo, DefaultExternalProject.class) {
@Override
protected DefaultExternalProject create(Kryo kryo, Input input, Class<DefaultExternalProject> type) {
return new DefaultExternalProject();
}
});
myKryo.register(DefaultExternalTask.class, new FieldSerializer<DefaultExternalTask>(myKryo, DefaultExternalTask.class) {
@Override
protected DefaultExternalTask create(Kryo kryo, Input input, Class<DefaultExternalTask> type) {
return new DefaultExternalTask();
}
});
myKryo.register(DefaultExternalPlugin.class, new FieldSerializer<DefaultExternalPlugin>(myKryo, DefaultExternalPlugin.class) {
@Override
protected DefaultExternalPlugin create(Kryo kryo, Input input, Class<DefaultExternalPlugin> type) {
return new DefaultExternalPlugin();
}
});
myKryo.register(DefaultExternalSourceSet.class, new FieldSerializer<DefaultExternalSourceSet>(myKryo, DefaultExternalSourceSet.class) {
@Override
protected DefaultExternalSourceSet create(Kryo kryo, Input input, Class<DefaultExternalSourceSet> type) {
return new DefaultExternalSourceSet();
}
});
myKryo.register(DefaultExternalSourceDirectorySet.class, new FieldSerializer<DefaultExternalSourceDirectorySet>(myKryo, DefaultExternalSourceDirectorySet.class) {
@Override
protected DefaultExternalSourceDirectorySet create(Kryo kryo, Input input, Class<DefaultExternalSourceDirectorySet> type) {
return new DefaultExternalSourceDirectorySet();
}
});
myKryo.register(DefaultExternalFilter.class, new FieldSerializer<DefaultExternalFilter>(myKryo, DefaultExternalFilter.class) {
@Override
protected DefaultExternalFilter create(Kryo kryo, Input input, Class<DefaultExternalFilter> type) {
return new DefaultExternalFilter();
}
});
myKryo.register(ExternalSystemSourceType.class, new DefaultSerializers.EnumSerializer(ExternalSystemSourceType.class));
myKryo.register(DefaultExternalProjectDependency.class, new FieldSerializer<DefaultExternalProjectDependency>(myKryo, DefaultExternalProjectDependency.class) {
@Override
protected DefaultExternalProjectDependency create(Kryo kryo, Input input, Class<DefaultExternalProjectDependency> type) {
return new DefaultExternalProjectDependency();
}
});
myKryo.register(DefaultFileCollectionDependency.class, new FieldSerializer<DefaultFileCollectionDependency>(myKryo, DefaultFileCollectionDependency.class) {
@Override
protected DefaultFileCollectionDependency create(Kryo kryo, Input input, Class<DefaultFileCollectionDependency> type) {
return new DefaultFileCollectionDependency();
}
});
myKryo.register(DefaultExternalLibraryDependency.class, new FieldSerializer<DefaultExternalLibraryDependency>(myKryo, DefaultExternalLibraryDependency.class) {
@Override
protected DefaultExternalLibraryDependency create(Kryo kryo, Input input, Class<DefaultExternalLibraryDependency> type) {
return new DefaultExternalLibraryDependency();
}
});
myKryo.register(DefaultUnresolvedExternalDependency.class, new FieldSerializer<DefaultUnresolvedExternalDependency>(myKryo, DefaultUnresolvedExternalDependency.class) {
@Override
protected DefaultUnresolvedExternalDependency create(Kryo kryo, Input input, Class<DefaultUnresolvedExternalDependency> type) {
return new DefaultUnresolvedExternalDependency();
}
});
myKryo.register(DefaultExternalDependencyId.class, new FieldSerializer<DefaultExternalDependencyId>(myKryo, DefaultExternalDependencyId.class) {
@Override
protected DefaultExternalDependencyId create(Kryo kryo, Input input, Class<DefaultExternalDependencyId> type) {
return new DefaultExternalDependencyId();
}
});
myKryo.register(LinkedHashSet.class, new CollectionSerializer() {
@Override
protected Collection create(Kryo kryo, Input input, Class<Collection> type) {
return new LinkedHashSet();
}
});
myKryo.register(HashSet.class, new CollectionSerializer() {
@Override
protected Collection create(Kryo kryo, Input input, Class<Collection> type) {
return new HashSet();
}
});
myKryo.register(THashSet.class, new CollectionSerializer() {
@Override
protected Collection create(Kryo kryo, Input input, Class<Collection> type) {
return new THashSet();
}
});
myKryo.register(Set.class, new CollectionSerializer() {
@Override
protected Collection create(Kryo kryo, Input input, Class<Collection> type) {
return new HashSet();
}
});
myKryo.register(THashMap.class, new MapSerializer() {
@Override
protected Map create(Kryo kryo, Input input, Class<Map> type) {
return new THashMap();
}
});
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class PsiSearchHelperImpl method processRequests.
@Override
public boolean processRequests(@NotNull SearchRequestCollector collector, @NotNull Processor<PsiReference> processor) {
final Map<SearchRequestCollector, Processor<PsiReference>> collectors = ContainerUtil.newHashMap();
collectors.put(collector, processor);
ProgressIndicator progress = getOrCreateIndicator();
appendCollectorsFromQueryRequests(collectors);
boolean result;
do {
MultiMap<Set<IdIndexEntry>, RequestWithProcessor> globals = new MultiMap<>();
final List<Computable<Boolean>> customs = ContainerUtil.newArrayList();
final Set<RequestWithProcessor> locals = ContainerUtil.newLinkedHashSet();
Map<RequestWithProcessor, Processor<PsiElement>> localProcessors = new THashMap<>();
distributePrimitives(collectors, locals, globals, customs, localProcessors, progress);
result = processGlobalRequestsOptimized(globals, progress, localProcessors);
if (result) {
for (RequestWithProcessor local : locals) {
result = processSingleRequest(local.request, local.refProcessor);
if (!result)
break;
}
if (result) {
for (Computable<Boolean> custom : customs) {
result = custom.compute();
if (!result)
break;
}
}
if (!result)
break;
}
} while (appendCollectorsFromQueryRequests(collectors));
return result;
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class StdArrangementExtendableSettings method getExtendedSectionRules.
@Override
public List<ArrangementSectionRule> getExtendedSectionRules() {
synchronized (myExtendedSectionRules) {
if (myExtendedSectionRules.isEmpty()) {
final Map<String, StdArrangementRuleAliasToken> tokenIdToDefinition = new THashMap<>(myRulesAliases.size());
for (StdArrangementRuleAliasToken alias : myRulesAliases) {
final String id = alias.getId();
tokenIdToDefinition.put(id, alias);
}
final List<ArrangementSectionRule> sections = getSections();
for (ArrangementSectionRule section : sections) {
final List<StdArrangementMatchRule> extendedRules = new ArrayList<>();
for (StdArrangementMatchRule rule : section.getMatchRules()) {
appendExpandedRules(rule, extendedRules, tokenIdToDefinition);
}
myExtendedSectionRules.add(ArrangementSectionRule.create(section.getStartComment(), section.getEndComment(), extendedRules));
}
}
}
return myExtendedSectionRules;
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class DirectoryEntry method collectDifferencesWith.
@Override
public void collectDifferencesWith(Entry right, List<Difference> result) {
DirectoryEntry e = (DirectoryEntry) right;
if (!getPath().equals(e.getPath())) {
result.add(new Difference(false, this, e));
}
// most often we have the same children, so try processing it directly
int commonIndex = 0;
final int myChildrenSize = myChildren.size();
final int rightChildrenSize = e.myChildren.size();
final int minChildrenSize = Math.min(myChildrenSize, rightChildrenSize);
while (commonIndex < minChildrenSize) {
Entry childEntry = myChildren.get(commonIndex);
Entry rightChildEntry = e.myChildren.get(commonIndex);
if (childEntry.getNameId() == rightChildEntry.getNameId() && childEntry.isDirectory() == rightChildEntry.isDirectory()) {
childEntry.collectDifferencesWith(rightChildEntry, result);
} else {
break;
}
++commonIndex;
}
if (commonIndex == myChildrenSize && commonIndex == rightChildrenSize)
return;
TIntObjectHashMap<Entry> uniqueNameIdToMyChildEntries = new TIntObjectHashMap<>(myChildrenSize - commonIndex);
for (int i = commonIndex; i < myChildrenSize; ++i) {
Entry childEntry = myChildren.get(i);
uniqueNameIdToMyChildEntries.put(childEntry.getNameId(), childEntry);
}
TIntObjectHashMap<Entry> uniqueNameIdToRightChildEntries = new TIntObjectHashMap<>(rightChildrenSize - commonIndex);
TIntObjectHashMap<Entry> myNameIdToRightChildEntries = new TIntObjectHashMap<>(rightChildrenSize - commonIndex);
for (int i = commonIndex; i < rightChildrenSize; ++i) {
Entry rightChildEntry = e.myChildren.get(i);
int rightChildEntryNameId = rightChildEntry.getNameId();
Entry myChildEntry = uniqueNameIdToMyChildEntries.get(rightChildEntryNameId);
if (myChildEntry != null && myChildEntry.isDirectory() == rightChildEntry.isDirectory()) {
uniqueNameIdToMyChildEntries.remove(rightChildEntryNameId);
myNameIdToRightChildEntries.put(rightChildEntryNameId, rightChildEntry);
} else {
uniqueNameIdToRightChildEntries.put(rightChildEntryNameId, rightChildEntry);
}
}
if (!Paths.isCaseSensitive() && uniqueNameIdToMyChildEntries.size() > 0 && uniqueNameIdToRightChildEntries.size() > 0) {
THashMap<String, Entry> nameToEntryMap = new THashMap<>(uniqueNameIdToMyChildEntries.size(), CaseInsensitiveStringHashingStrategy.INSTANCE);
uniqueNameIdToMyChildEntries.forEachValue(myChildEntry -> {
nameToEntryMap.put(myChildEntry.getName(), myChildEntry);
return true;
});
uniqueNameIdToRightChildEntries.forEachValue(rightChildEntry -> {
Entry myChildEntry = nameToEntryMap.get(rightChildEntry.getName());
if (myChildEntry != null && rightChildEntry.isDirectory() == myChildEntry.isDirectory()) {
myNameIdToRightChildEntries.put(myChildEntry.getNameId(), rightChildEntry);
uniqueNameIdToMyChildEntries.remove(myChildEntry.getNameId());
uniqueNameIdToRightChildEntries.remove(rightChildEntry.getNameId());
}
return true;
});
}
for (Entry child : e.myChildren) {
if (uniqueNameIdToRightChildEntries.containsKey(child.getNameId())) {
child.collectCreatedDifferences(result);
}
}
for (Entry child : myChildren) {
if (uniqueNameIdToMyChildEntries.containsKey(child.getNameId())) {
child.collectDeletedDifferences(result);
} else {
Entry itsChild = myNameIdToRightChildEntries.get(child.getNameId());
if (itsChild != null)
child.collectDifferencesWith(itsChild, result);
}
}
}
Aggregations