use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class ModuleManagerImpl method loadModules.
protected void loadModules(@NotNull ModuleModelImpl moduleModel) {
myFailedModulePaths.clear();
if (myModulePathsToLoad == null || myModulePathsToLoad.isEmpty()) {
return;
}
myFailedModulePaths.addAll(myModulePathsToLoad);
ProgressIndicator globalIndicator = ProgressIndicatorProvider.getGlobalProgressIndicator();
ProgressIndicator progressIndicator = myProject.isDefault() || globalIndicator == null ? new EmptyProgressIndicator() : globalIndicator;
progressIndicator.setText("Loading modules...");
progressIndicator.setText2("");
List<Module> modulesWithUnknownTypes = new SmartList<>();
List<ModuleLoadingErrorDescription> errors = Collections.synchronizedList(new ArrayList<>());
ModuleGroupInterner groupInterner = new ModuleGroupInterner();
ExecutorService service = AppExecutorUtil.createBoundedApplicationPoolExecutor("modules loader", JobSchedulerImpl.CORES_COUNT);
List<Pair<Future<Module>, ModulePath>> tasks = new ArrayList<>();
Set<String> paths = new THashSet<>();
boolean parallel = Registry.is("parallel.modules.loading");
for (ModulePath modulePath : myModulePathsToLoad) {
if (progressIndicator.isCanceled()) {
break;
}
try {
String path = modulePath.getPath();
if (!paths.add(path))
continue;
if (!parallel) {
tasks.add(Pair.create(null, modulePath));
continue;
}
ThrowableComputable<Module, IOException> computable = moduleModel.loadModuleInternal(path);
Future<Module> future = service.submit(() -> {
progressIndicator.setFraction(progressIndicator.getFraction() + myProgressStep);
try {
return computable.compute();
} catch (IOException e) {
reportError(errors, modulePath, e);
} catch (Exception e) {
LOG.error(e);
}
return null;
});
tasks.add(Pair.create(future, modulePath));
} catch (IOException e) {
reportError(errors, modulePath, e);
}
}
for (Pair<Future<Module>, ModulePath> task : tasks) {
if (progressIndicator.isCanceled()) {
break;
}
try {
Module module;
if (parallel) {
module = task.first.get();
} else {
module = moduleModel.loadModuleInternal(task.second.getPath()).compute();
progressIndicator.setFraction(progressIndicator.getFraction() + myProgressStep);
}
if (module == null)
continue;
if (isUnknownModuleType(module)) {
modulesWithUnknownTypes.add(module);
}
ModulePath modulePath = task.second;
final String groupPathString = modulePath.getGroup();
if (groupPathString != null) {
// model should be updated too
groupInterner.setModuleGroupPath(moduleModel, module, groupPathString.split(MODULE_GROUP_SEPARATOR));
}
myFailedModulePaths.remove(modulePath);
} catch (IOException e) {
reportError(errors, task.second, e);
} catch (Exception e) {
LOG.error(e);
}
}
service.shutdown();
progressIndicator.checkCanceled();
Application app = ApplicationManager.getApplication();
if (app.isInternal() || app.isEAP() || ApplicationInfo.getInstance().getBuild().isSnapshot()) {
Map<String, Module> track = new THashMap<>();
for (Module module : moduleModel.getModules()) {
for (String url : ModuleRootManager.getInstance(module).getContentRootUrls()) {
Module oldModule = track.put(url, module);
if (oldModule != null) {
//Map<String, VirtualFilePointer> track1 = ContentEntryImpl.track;
//VirtualFilePointer pointer = track1.get(url);
LOG.error("duplicated content url: " + url);
}
}
}
}
onModuleLoadErrors(moduleModel, errors);
showUnknownModuleTypeNotification(modulesWithUnknownTypes);
}
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;
}
use of gnu.trove.THashMap in project intellij-plugins by JetBrains.
the class SwcCatalogXmlUtil method parseTimestampsFromCatalogXml.
@SuppressWarnings({ "unchecked" })
private static THashMap<String, TObjectLongHashMap<String>> parseTimestampsFromCatalogXml(@NotNull final VirtualFile catalogFile) {
// <swc xmlns="http://www.adobe.com/flash/swccatalog/9">
// <libraries>
// <library path="library.swf"> take swf name here
// <script name="flash/sampler/StackFrame" mod="1256700285949" signatureChecksum="121164004" > name attribute is not FQN, take only mod here
// <def id="flash.sampler:Sample" /> multiple defs possible
// <def id="flash.sampler:clearSamples" />
// ...
final THashMap<String, TObjectLongHashMap<String>> swfNameToQnameWithTimestampMap = new THashMap<>(1);
try {
final Element rootElement = JDOMUtil.load(catalogFile.getInputStream());
if (rootElement != null && "swc".equals(rootElement.getName())) {
for (final Element librariesElement : rootElement.getChildren("libraries", rootElement.getNamespace())) {
for (final Element libraryElement : librariesElement.getChildren("library", librariesElement.getNamespace())) {
final String swfName = libraryElement.getAttributeValue("path");
if (StringUtil.isEmpty(swfName)) {
continue;
}
final TObjectLongHashMap<String> qNameWithTimestampMap = new TObjectLongHashMap<>();
swfNameToQnameWithTimestampMap.put(swfName, qNameWithTimestampMap);
for (final Element scriptElement : libraryElement.getChildren("script", libraryElement.getNamespace())) {
final String mod = scriptElement.getAttributeValue("mod");
if (StringUtil.isEmpty(mod)) {
continue;
}
try {
final long timestamp = Long.parseLong(mod);
for (final Element defElement : scriptElement.getChildren("def", scriptElement.getNamespace())) {
final String id = defElement.getAttributeValue("id");
if (!StringUtil.isEmpty(id)) {
final String fqn = id.replace(':', '.');
qNameWithTimestampMap.put(fqn, timestamp);
}
}
} catch (NumberFormatException ignored) {
/*ignore*/
}
}
}
}
}
} catch (JDOMException ignored) {
/*ignore*/
} catch (IOException ignored) {
/*ignore*/
}
return swfNameToQnameWithTimestampMap;
}
use of gnu.trove.THashMap in project intellij-plugins by JetBrains.
the class CompilerConfigGeneratorRt method addFilesIncludedInSwc.
private void addFilesIncludedInSwc(final Element rootElement) {
final JpsCompilerExcludes excludes = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(myModule.getProject()).getCompilerExcludes();
final Map<String, String> filePathToPathInSwc = new THashMap<>();
for (String path : myBC.getCompilerOptions().getFilesToIncludeInSWC()) {
final File fileOrDir = new File(path);
if (excludes.isExcluded(fileOrDir))
continue;
if (myProjectDescriptor.getIgnoredFileIndex().isIgnored(fileOrDir.getName()))
continue;
final String baseRelativePath = StringUtil.notNullize(FlexCommonUtils.getPathRelativeToSourceRoot(myModule, fileOrDir.getPath()), fileOrDir.getName());
if (fileOrDir.isDirectory()) {
processFilesRecursively(fileOrDir, file -> {
if (myProjectDescriptor.getIgnoredFileIndex().isIgnored(file.getName()))
return false;
if (!file.isDirectory() && !FlexCommonUtils.isSourceFile(file.getName()) && !excludes.isExcluded(file)) {
final String relativePath = FileUtil.getRelativePath(fileOrDir, file);
assert relativePath != null;
final String pathInSwc = baseRelativePath.isEmpty() ? relativePath : baseRelativePath + "/" + relativePath;
filePathToPathInSwc.put(file.getPath(), pathInSwc);
}
return true;
});
} else if (fileOrDir.isFile()) {
filePathToPathInSwc.put(fileOrDir.getPath(), baseRelativePath);
}
}
for (Map.Entry<String, String> entry : filePathToPathInSwc.entrySet()) {
final String value = FileUtil.toSystemIndependentName(entry.getValue()) + CompilerOptionInfo.LIST_ENTRY_PARTS_SEPARATOR + FileUtil.toSystemIndependentName(entry.getKey());
addOption(rootElement, CompilerOptionInfo.INCLUDE_FILE_INFO, value);
}
}
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();
}
}
Aggregations