Search in sources :

Example 91 with THashMap

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

the class PerFileMappingsBase method loadState.

@Override
public void loadState(final Element state) {
    synchronized (myMappings) {
        final THashMap<String, T> dialectMap = new THashMap<>();
        for (T dialect : getAvailableValues()) {
            String key = serialize(dialect);
            if (key != null) {
                dialectMap.put(key, dialect);
            }
        }
        myMappings.clear();
        final List<Element> files = state.getChildren("file");
        for (Element fileElement : files) {
            final String url = fileElement.getAttributeValue("url");
            final String dialectID = fileElement.getAttributeValue(getValueAttribute());
            final VirtualFile file = url.equals("PROJECT") ? null : VirtualFileManager.getInstance().findFileByUrl(url);
            T dialect = dialectMap.get(dialectID);
            if (dialect == null) {
                dialect = handleUnknownMapping(file, dialectID);
                if (dialect == null)
                    continue;
            }
            if (file != null || url.equals("PROJECT")) {
                myMappings.put(file, dialect);
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) THashMap(gnu.trove.THashMap) Element(org.jdom.Element)

Example 92 with THashMap

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

the class Configuration method loadState.

@Override
public void loadState(final Element element) {
    myInjections.clear();
    List<Element> injectionElements = element.getChildren("injection");
    if (!injectionElements.isEmpty()) {
        final Map<String, LanguageInjectionSupport> supports = new THashMap<>();
        for (LanguageInjectionSupport support : InjectorUtils.getActiveInjectionSupports()) {
            supports.put(support.getId(), support);
        }
        for (Element child : injectionElements) {
            final String key = child.getAttributeValue("injector-id");
            final LanguageInjectionSupport support = supports.get(key);
            final BaseInjection injection = support == null ? new BaseInjection(key) : support.createInjection(child);
            injection.loadState(child);
            InjectionPlace[] places = dropKnownInvalidPlaces(injection.getInjectionPlaces());
            if (places != null) {
                // not all places were removed
                injection.setInjectionPlaces(places);
                myInjections.get(key).add(injection);
            }
        }
    }
    importPlaces(getDefaultInjections());
}
Also used : LanguageInjectionSupport(org.intellij.plugins.intelliLang.inject.LanguageInjectionSupport) THashMap(gnu.trove.THashMap) PsiElement(com.intellij.psi.PsiElement) PsiCompiledElement(com.intellij.psi.PsiCompiledElement) Element(org.jdom.Element) InjectionPlace(org.intellij.plugins.intelliLang.inject.config.InjectionPlace) BaseInjection(org.intellij.plugins.intelliLang.inject.config.BaseInjection)

Example 93 with THashMap

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

the class RevisionsList method updateData.

public void updateData(HistoryDialogModel model) {
    Set<Long> sel = new THashSet<>();
    MyModel m = (MyModel) table.getModel();
    for (int i : table.getSelectedRows()) {
        if (i >= m.getRowCount())
            continue;
        sel.add(m.getValueAt(i, 0).revision.getChangeSetId());
    }
    List<RevisionItem> newRevs = model.getRevisions();
    Date today = new Date();
    Map<RevisionItem, Period> periods = new THashMap<>();
    for (int i = 0; i < newRevs.size(); i++) {
        RevisionItem each = newRevs.get(i);
        boolean recent = today.getTime() - each.revision.getTimestamp() < 1000 * 60 * 60 * RECENT_PERIOD;
        if (recent) {
            if (i == 0) {
                periods.put(each, Period.RECENT);
            }
        } else {
            periods.put(each, periods.isEmpty() ? Period.OLD : Period.OLDER);
            break;
        }
    }
    table.setModel(new MyModel(newRevs, periods));
    for (int i = 0; i < newRevs.size(); i++) {
        RevisionItem r = newRevs.get(i);
        if (sel.contains(r.revision.getChangeSetId())) {
            table.getSelectionModel().addSelectionInterval(i, i);
        }
    }
    if (table.getSelectionModel().isSelectionEmpty()) {
        table.getSelectionModel().addSelectionInterval(0, 0);
    }
}
Also used : RevisionItem(com.intellij.history.integration.ui.models.RevisionItem) THashMap(gnu.trove.THashMap) THashSet(gnu.trove.THashSet)

Example 94 with THashMap

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

the class GeneralCommandLine method setupEnvironment.

protected void setupEnvironment(@NotNull Map<String, String> environment) {
    environment.clear();
    if (myParentEnvironmentType != ParentEnvironmentType.NONE) {
        environment.putAll(getParentEnvironment());
    }
    if (SystemInfo.isUnix) {
        File workDirectory = getWorkDirectory();
        if (workDirectory != null) {
            environment.put("PWD", FileUtil.toSystemDependentName(workDirectory.getAbsolutePath()));
        }
    }
    if (!myEnvParams.isEmpty()) {
        if (SystemInfo.isWindows) {
            THashMap<String, String> envVars = new THashMap<>(CaseInsensitiveStringHashingStrategy.INSTANCE);
            envVars.putAll(environment);
            envVars.putAll(myEnvParams);
            environment.clear();
            environment.putAll(envVars);
        } else {
            environment.putAll(myEnvParams);
        }
    }
}
Also used : THashMap(gnu.trove.THashMap) File(java.io.File)

Example 95 with THashMap

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

the class SharedProcessingContext method put.

public <T> void put(@NotNull Key<T> key, Object element, T value) {
    Map map = (Map) myMap.get(key);
    if (map == null) {
        map = new THashMap();
        myMap.put(key, map);
    }
    map.put(element, value);
}
Also used : THashMap(gnu.trove.THashMap) Map(java.util.Map) 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