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-plugins by JetBrains.
the class ValidateFlashConfigurationsPrecompileTask method checkSimilarOutputFiles.
private static boolean checkSimilarOutputFiles(final Collection<Pair<Module, FlexBuildConfiguration>> modulesAndBCsToCompile, final Consumer<Trinity<Module, FlexBuildConfiguration, FlashProjectStructureProblem>> errorConsumer) {
final Map<String, Pair<Module, FlexBuildConfiguration>> outputPathToModuleAndBC = new THashMap<>();
for (Pair<Module, FlexBuildConfiguration> moduleAndBC : modulesAndBCsToCompile) {
final FlexBuildConfiguration bc = moduleAndBC.second;
final String outputFilePath = bc.getActualOutputFilePath();
checkOutputPathUnique(outputFilePath, moduleAndBC, outputPathToModuleAndBC, errorConsumer);
}
return true;
}
use of gnu.trove.THashMap in project intellij-plugins by JetBrains.
the class ActionScriptSmartCompletionContributor method getEventsMap.
public static Map<String, String> getEventsMap(JSClass clazzToProcess) {
if (clazzToProcess == null)
return Collections.emptyMap();
final Map<String, String> eventsMap = new THashMap<>();
class EventsDataCollector extends ResolveProcessor implements ActionScriptResolveUtil.MetaDataProcessor {
public EventsDataCollector() {
super(null);
setToProcessHierarchy(true);
setToProcessMembers(false);
setTypeContext(true);
setLocalResolve(true);
}
@Override
public boolean process(@NotNull final JSAttribute jsAttribute) {
if ("Event".equals(jsAttribute.getName())) {
final JSAttributeNameValuePair eventAttr = jsAttribute.getValueByName("name");
JSAttributeNameValuePair typeAttr = jsAttribute.getValueByName("type");
if (eventAttr != null && typeAttr != null) {
final String simpleValue = eventAttr.getSimpleValue();
if (simpleValue != null) {
eventsMap.put(simpleValue, typeAttr.getSimpleValue());
}
}
}
return true;
}
@Override
public boolean handleOtherElement(final PsiElement el, final PsiElement context, final Ref<PsiElement> continuePassElement) {
return true;
}
@Override
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
if (element instanceof JSClass) {
ActionScriptResolveUtil.processMetaAttributesForClass(element, this, true);
}
return true;
}
}
final EventsDataCollector eventsDataCollector = new EventsDataCollector();
if (clazzToProcess instanceof XmlBackedJSClassImpl) {
XmlFile file = (XmlFile) clazzToProcess.getParent().getContainingFile();
if (file != null && JavaScriptSupportLoader.isFlexMxmFile(file)) {
final XmlDocument xmlDocument = file.getDocument();
final XmlTag rootTag = xmlDocument == null ? null : xmlDocument.getRootTag();
final XmlTag[] tags = rootTag == null ? XmlTag.EMPTY : MxmlJSClass.findLanguageSubTags(rootTag, FlexPredefinedTagNames.METADATA);
JSResolveUtil.JSInjectedFilesVisitor injectedFilesVisitor = new JSResolveUtil.JSInjectedFilesVisitor() {
@Override
protected void process(JSFile file) {
for (PsiElement element : file.getChildren()) {
if (element instanceof JSAttributeList) {
ActionScriptResolveUtil.processAttributeList(eventsDataCollector, null, (JSAttributeList) element, true, true);
}
}
}
};
for (XmlTag tag : tags) {
JSResolveUtil.processInjectedFileForTag(tag, injectedFilesVisitor);
}
}
}
clazzToProcess.processDeclarations(eventsDataCollector, ResolveState.initial(), clazzToProcess, clazzToProcess);
return eventsMap;
}
use of gnu.trove.THashMap in project intellij-plugins by JetBrains.
the class ResolveExternalInlineStyleSourceActionTest method testFindComponent.
@JSTestOptions({ JSTestOption.WithCssSupportLoader, JSTestOption.WithJsSupportLoader, JSTestOption.WithGumboSdk, JSTestOption.WithFlexFacet })
public void testFindComponent() throws Exception {
Map<String, String> styles = new THashMap<>();
styles.put("left", "10");
styles.put("right", "10");
ResolveExternalInlineStyleSourceAction action = new ResolveExternalInlineStyleSourceAction("innerComponentInDeclarations", "spark.components.Button", "left", styles, myModule);
PsiElement element = (PsiElement) action.find();
assertNotNull(element);
assertEquals(1717, element.getTextOffset());
}
Aggregations