use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class XmlLanguageInjector method getXmlAnnotatedElementsValue.
private Trinity<Long, Pattern, Collection<String>> getXmlAnnotatedElementsValue() {
Trinity<Long, Pattern, Collection<String>> index = myXmlIndex;
if (index == null || myConfiguration.getModificationCount() != index.first.longValue()) {
final Map<ElementPattern<?>, BaseInjection> map = new THashMap<>();
for (BaseInjection injection : myConfiguration.getInjections(XmlLanguageInjectionSupport.XML_SUPPORT_ID)) {
for (InjectionPlace place : injection.getInjectionPlaces()) {
if (!place.isEnabled() || place.getElementPattern() == null)
continue;
map.put(place.getElementPattern(), injection);
}
}
final Collection<String> stringSet = PatternValuesIndex.buildStringIndex(map.keySet());
index = Trinity.create(myConfiguration.getModificationCount(), buildPattern(stringSet), stringSet);
myXmlIndex = index;
}
return index;
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class AppEngineSdkUtil method computeWhiteList.
public static Map<String, Set<String>> computeWhiteList(final File toolsApiJarFile) {
try {
final THashMap<String, Set<String>> map = new THashMap<>();
final ClassLoader loader = UrlClassLoader.build().urls(toolsApiJarFile.toURI().toURL()).parent(AppEngineSdkUtil.class.getClassLoader()).get();
final Class<?> whiteListClass = Class.forName("com.google.apphosting.runtime.security.WhiteList", true, loader);
final Set<String> classes = (Set<String>) whiteListClass.getMethod("getWhiteList").invoke(null);
for (String qualifiedName : classes) {
final String packageName = StringUtil.getPackageName(qualifiedName);
Set<String> classNames = map.get(packageName);
if (classNames == null) {
classNames = new THashSet<>();
map.put(packageName, classNames);
}
classNames.add(StringUtil.getShortName(qualifiedName));
}
return map;
} catch (UnsupportedClassVersionError e) {
LOG.warn(e);
return Collections.emptyMap();
} catch (Exception e) {
LOG.error(e);
return Collections.emptyMap();
}
}
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-plugins by JetBrains.
the class SwcCatalogXmlUtil method getTimestampFromCatalogXml.
public static long getTimestampFromCatalogXml(@NotNull final PsiElement psiElement) {
final Long cachedTimestamp = psiElement.getUserData(TIMESTAMP_IN_CATALOG_XML);
if (cachedTimestamp != null) {
return cachedTimestamp;
}
if (!(psiElement instanceof JSQualifiedNamedElement)) {
return -1;
}
final String qName = ((JSQualifiedNamedElement) psiElement).getQualifiedName();
if (StringUtil.isEmpty(qName)) {
return -1;
}
final PsiFile psiFile = psiElement.getContainingFile();
if (JavaScriptIndex.ECMASCRIPT_JS2.equals(psiFile.getName()))
return Integer.MIN_VALUE;
final VirtualFile swfFile = psiFile.getVirtualFile();
final VirtualFile dir = swfFile != null && "swf".equalsIgnoreCase(swfFile.getExtension()) ? swfFile.getParent() : null;
final VirtualFile catalogFile = dir == null ? null : dir.findChild("catalog.xml");
if (catalogFile == null) {
return -1;
}
Pair<Long, THashMap<String, TObjectLongHashMap<String>>> modStampAndSwfNameToQnameWithTimestampMap = catalogFile.getUserData(MOD_STAMP_AND_SWF_NAME_TO_QNAME_WITH_TIMESTAMP_MAP);
if (modStampAndSwfNameToQnameWithTimestampMap == null || modStampAndSwfNameToQnameWithTimestampMap.first != catalogFile.getModificationStamp()) {
final THashMap<String, TObjectLongHashMap<String>> swfNameToQnameWithTimestampMap = parseTimestampsFromCatalogXml(catalogFile);
modStampAndSwfNameToQnameWithTimestampMap = Pair.create(catalogFile.getModificationStamp(), swfNameToQnameWithTimestampMap);
catalogFile.putUserData(MOD_STAMP_AND_SWF_NAME_TO_QNAME_WITH_TIMESTAMP_MAP, modStampAndSwfNameToQnameWithTimestampMap);
}
final TObjectLongHashMap<String> qnameWithTimestampMap = modStampAndSwfNameToQnameWithTimestampMap.second.get(swfFile.getName());
final long timestamp = qnameWithTimestampMap == null ? -1 : qnameWithTimestampMap.get(qName);
psiElement.putUserData(TIMESTAMP_IN_CATALOG_XML, timestamp);
return timestamp;
}
Aggregations