Search in sources :

Example 61 with THashMap

use of gnu.trove.THashMap in project intellij-plugins by JetBrains.

the class ResolveExternalInlineStyleSourceActionTest method testFindComponent2.

@JSTestOptions({ JSTestOption.WithCssSupportLoader, JSTestOption.WithJsSupportLoader, JSTestOption.WithGumboSdk, JSTestOption.WithFlexFacet })
public void testFindComponent2() throws Exception {
    Map<String, String> styles = new THashMap<>();
    styles.put("left", "10");
    styles.put("right", "10");
    styles.put("top", "4");
    ResolveExternalInlineStyleSourceAction action = new ResolveExternalInlineStyleSourceAction("innerComponentInDeclarations", "spark.components.Button", "left", styles, myModule);
    PsiElement element = (PsiElement) action.find();
    assertNotNull(element);
    assertEquals(1808, element.getTextOffset());
}
Also used : THashMap(gnu.trove.THashMap) PsiElement(com.intellij.psi.PsiElement) JSTestOptions(com.intellij.lang.javascript.JSTestOptions)

Example 62 with THashMap

use of gnu.trove.THashMap in project intellij-plugins by JetBrains.

the class FlashBuilderImporter method commit.

public List<Module> commit(final Project project, final ModifiableModuleModel model, final ModulesProvider modulesProvider, final ModifiableArtifactModel artifactModel) {
    //FlexModuleBuilder.setupResourceFilePatterns(project);
    final boolean needToCommit = model == null;
    final ModifiableModuleModel moduleModel = model != null ? model : ModuleManager.getInstance(project).getModifiableModel();
    final List<String> paths = getList();
    final boolean isArchive = paths.size() == 1 && FlashBuilderProjectFinder.hasArchiveExtension(paths.get(0));
    final List<String> dotProjectPaths = getDotProjectPaths(project);
    final List<FlashBuilderProject> flashBuilderProjects = FlashBuilderProjectLoadUtil.loadProjects(dotProjectPaths, isArchive);
    final Map<FlashBuilderProject, ModifiableRootModel> flashBuilderProjectToModifiableModelMap = new THashMap<>();
    final Map<Module, ModifiableRootModel> moduleToModifiableModelMap = new THashMap<>();
    final Set<String> moduleNames = new THashSet<>(flashBuilderProjects.size());
    final FlexProjectConfigurationEditor currentFlexEditor = FlexBuildConfigurationsExtension.getInstance().getConfigurator().getConfigEditor();
    assert needToCommit == (currentFlexEditor == null);
    for (FlashBuilderProject flashBuilderProject : flashBuilderProjects) {
        final String moduleName = makeUnique(flashBuilderProject.getName(), moduleNames);
        moduleNames.add(moduleName);
        final String moduleFilePath = flashBuilderProject.getProjectRootPath() + "/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION;
        if (LocalFileSystem.getInstance().findFileByPath(moduleFilePath) != null) {
            ApplicationManager.getApplication().runWriteAction(() -> ModuleBuilder.deleteModuleFile(moduleFilePath));
        }
        final Module module = moduleModel.newModule(moduleFilePath, FlexModuleType.getInstance().getId());
        final ModifiableRootModel rootModel = currentFlexEditor != null ? currentFlexEditor.getModifiableRootModel(module) : ModuleRootManager.getInstance(module).getModifiableModel();
        flashBuilderProjectToModifiableModelMap.put(flashBuilderProject, rootModel);
        moduleToModifiableModelMap.put(module, rootModel);
    }
    final FlexProjectConfigurationEditor flexConfigEditor = currentFlexEditor != null ? currentFlexEditor : FlexProjectConfigurationEditor.createEditor(project, moduleToModifiableModelMap, null, null);
    final FlashBuilderSdkFinder sdkFinder = new FlashBuilderSdkFinder(project, getParameters().myInitiallySelectedPath, flashBuilderProjects);
    final FlashBuilderModuleImporter flashBuilderModuleImporter = new FlashBuilderModuleImporter(project, flexConfigEditor, flashBuilderProjects, sdkFinder);
    for (final FlashBuilderProject flashBuilderProject : flashBuilderProjects) {
        flashBuilderModuleImporter.setupModule(flashBuilderProjectToModifiableModelMap.get(flashBuilderProject), flashBuilderProject);
    }
    if (needToCommit) {
        try {
            flexConfigEditor.commit();
        } catch (ConfigurationException e) {
            Logger.getInstance(FlashBuilderImporter.class).error(e);
        }
        ApplicationManager.getApplication().runWriteAction(() -> {
            ModifiableModelCommitter.multiCommit(moduleToModifiableModelMap.values(), moduleModel);
        });
    }
    return new ArrayList<>(moduleToModifiableModelMap.keySet());
}
Also used : THashSet(gnu.trove.THashSet) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel) THashMap(gnu.trove.THashMap) ConfigurationException(com.intellij.openapi.options.ConfigurationException) Module(com.intellij.openapi.module.Module)

Example 63 with THashMap

use of gnu.trove.THashMap in project intellij-plugins by JetBrains.

the class FlashBuilderModuleImporter method loadEclipsePathVariables.

private static Map<String, String> loadEclipsePathVariables(final String workspacePath) {
    final Map<String, String> eclipsePathVariables = new THashMap<>();
    final VirtualFile prefsFile = LocalFileSystem.getInstance().findFileByPath(workspacePath + CORE_RESOURCES_PREFS_REL_PATH);
    if (prefsFile == null)
        return eclipsePathVariables;
    final Properties properties = new Properties();
    try {
        properties.load(prefsFile.getInputStream());
        for (final Map.Entry<Object, Object> entry : properties.entrySet()) {
            final String key = (String) entry.getKey();
            if (key.startsWith(PATHVARIABLE_DOT)) {
                eclipsePathVariables.put(key.substring(PATHVARIABLE_DOT.length()), (String) entry.getValue());
            }
        }
    } catch (IOException e) {
    /*ignore*/
    }
    return eclipsePathVariables;
}
Also used : THashMap(gnu.trove.THashMap) IOException(java.io.IOException) SystemProperties(com.intellij.util.SystemProperties) FlexLibraryProperties(com.intellij.lang.javascript.flex.library.FlexLibraryProperties) THashMap(gnu.trove.THashMap)

Example 64 with THashMap

use of gnu.trove.THashMap in project intellij-plugins by JetBrains.

the class LibrarySorter method sort.

public SortResult sort(List<Library> libraries, File outFile, Condition<String> isExternal, boolean returnDefinitionMap) throws IOException {
    final THashMap<CharSequence, Definition> definitionMap = new THashMap<>(libraries.size() * 128, AbcTranscoder.HASHING_STRATEGY);
    final List<LibrarySetItem> unsortedItems = collectItems(libraries, definitionMap, isExternal);
    final AbcMerger abcMerger = new AbcMerger(definitionMap, outFile, definitionProcessor);
    try {
        final ArrayList<Library> resourceOrStyleHolders = new ArrayList<>(unsortedItems.size());
        for (LibrarySetItem item : unsortedItems) {
            if (!item.hasDefinitions()) {
                if (item.library.hasResourceBundles()) {
                    resourceOrStyleHolders.add(item.library);
                }
                continue;
            }
            if (item.library.hasResourceBundles() || item.library.isStyleOwner()) {
                resourceOrStyleHolders.add(item.library);
            }
            abcMerger.process(item.library);
        }
        if (definitionMapProcessor != null) {
            definitionMapProcessor.process(definitionMap, abcMerger);
        }
        final List<Decoder> decoders = new ArrayList<>(definitionMap.size());
        final String[] singleStringArray = new String[1];
        definitionMap.forEachValue(definition -> {
            if (definition.doAbcData != null && (definition.resolved == ResolvedState.YES || (definition.resolved == ResolvedState.UNKNOWN && processDependencies(decoders, definition, definitionMap, singleStringArray)))) {
                decoders.add(createDecoder(definition));
            }
            return true;
        });
        abcMerger.end(decoders, new Encoder());
        return new SortResult(returnDefinitionMap ? definitionMap : null, resourceOrStyleHolders);
    } finally {
        abcMerger.close();
    }
}
Also used : ArrayList(java.util.ArrayList) Decoder(com.intellij.flex.uiDesigner.abc.Decoder) THashMap(gnu.trove.THashMap) Encoder(com.intellij.flex.uiDesigner.abc.Encoder)

Example 65 with THashMap

use of gnu.trove.THashMap in project intellij-plugins by JetBrains.

the class NodeClassInfo method getNodeClassInfo.

static NodeClassInfo getNodeClassInfo(@NotNull final JSClass jsClass) {
    final JSAttributeList classAttributes = jsClass.getAttributeList();
    final boolean dynamic = classAttributes != null && classAttributes.hasModifier(JSAttributeList.ModifierType.DYNAMIC);
    final Map<String, Icon> ownStaticFields = new THashMap<>();
    final Map<String, Icon> ownStaticProperties = new THashMap<>();
    final Map<String, Icon> ownFields = new THashMap<>();
    final Map<String, Icon> ownProperties = new THashMap<>();
    final Map<String, Icon> inheritedStaticFields = new THashMap<>();
    final Map<String, Icon> inheritedStaticProperties = new THashMap<>();
    final Map<String, Icon> inheritedFields = new THashMap<>();
    final Map<String, Icon> inheritedProperties = new THashMap<>();
    fillMapsForClass(jsClass, ownStaticFields, ownStaticProperties, ownFields, ownProperties);
    fillMapsForSupersRecursively(jsClass, new THashSet<>(), inheritedStaticFields, inheritedStaticProperties, inheritedFields, inheritedProperties);
    return new NodeClassInfo(normalizeIfVector(jsClass.getQualifiedName()), dynamic, ownStaticFields, ownStaticProperties, ownFields, ownProperties, inheritedStaticFields, inheritedStaticProperties, inheritedFields, inheritedProperties);
}
Also used : JSAttributeList(com.intellij.lang.javascript.psi.ecmal4.JSAttributeList) THashMap(gnu.trove.THashMap)

Aggregations

THashMap (gnu.trove.THashMap)129 NotNull (org.jetbrains.annotations.NotNull)33 THashSet (gnu.trove.THashSet)26 VirtualFile (com.intellij.openapi.vfs.VirtualFile)18 Element (org.jdom.Element)18 PsiElement (com.intellij.psi.PsiElement)16 IOException (java.io.IOException)16 File (java.io.File)15 Nullable (org.jetbrains.annotations.Nullable)10 Project (com.intellij.openapi.project.Project)9 List (java.util.List)9 Module (com.intellij.openapi.module.Module)8 Pair (com.intellij.openapi.util.Pair)7 PsiFile (com.intellij.psi.PsiFile)7 Map (java.util.Map)7 java.util (java.util)6 ArrayList (java.util.ArrayList)6 ApplicationManager (com.intellij.openapi.application.ApplicationManager)5 Document (com.intellij.openapi.editor.Document)5 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)5