Search in sources :

Example 6 with LinkedHashMap

use of com.intellij.util.containers.hash.LinkedHashMap in project intellij-community by JetBrains.

the class EditorListenerTracker method checkListenersLeak.

public void checkListenersLeak() throws AssertionError {
    try {
        // listeners may hang on default project
        if (myDefaultProjectInitialized != ((ProjectManagerImpl) ProjectManager.getInstance()).isDefaultProjectInitialized())
            return;
        EditorEventMulticasterImpl multicaster = (EditorEventMulticasterImpl) EditorFactory.getInstance().getEventMulticaster();
        Map<Class, List> after = multicaster.getListeners();
        Map<Class, List> leaked = new LinkedHashMap<>();
        for (Map.Entry<Class, List> entry : after.entrySet()) {
            Class aClass = entry.getKey();
            List beforeList = before.get(aClass);
            List afterList = entry.getValue();
            if (beforeList != null) {
                afterList.removeAll(beforeList);
            }
            if (!afterList.isEmpty()) {
                leaked.put(aClass, afterList);
            }
        }
        for (Map.Entry<Class, List> entry : leaked.entrySet()) {
            Class aClass = entry.getKey();
            List list = entry.getValue();
            Assert.fail("Listeners leaked for " + aClass + ":\n" + list);
        }
    } finally {
        before.clear();
    }
}
Also used : List(java.util.List) EditorEventMulticasterImpl(com.intellij.openapi.editor.impl.event.EditorEventMulticasterImpl) Map(java.util.Map) LinkedHashMap(com.intellij.util.containers.hash.LinkedHashMap) LinkedHashMap(com.intellij.util.containers.hash.LinkedHashMap)

Example 7 with LinkedHashMap

use of com.intellij.util.containers.hash.LinkedHashMap in project intellij-community by JetBrains.

the class AttachToLocalProcessAction method addToHistory.

public static void addToHistory(@NotNull Project project, @NotNull AttachItem item) {
    LinkedHashMap<String, HistoryItem> history = project.getUserData(HISTORY_KEY);
    if (history == null) {
        project.putUserData(HISTORY_KEY, history = new LinkedHashMap<>());
    }
    ProcessInfo processInfo = item.getProcessInfo();
    history.remove(processInfo.getCommandLine());
    history.put(processInfo.getCommandLine(), new HistoryItem(processInfo, item.getGroup(), item.getSelectedDebugger().getDebuggerDisplayName()));
    while (history.size() > 4) {
        history.remove(history.keySet().iterator().next());
    }
}
Also used : ProcessInfo(com.intellij.execution.process.ProcessInfo) LinkedHashMap(com.intellij.util.containers.hash.LinkedHashMap)

Example 8 with LinkedHashMap

use of com.intellij.util.containers.hash.LinkedHashMap in project intellij-community by JetBrains.

the class InspectionValidatorWrapper method runInspectionTool.

private static Map<ProblemDescriptor, HighlightDisplayLevel> runInspectionTool(final PsiFile file, final LocalInspectionTool inspectionTool, final HighlightDisplayLevel level) {
    Map<ProblemDescriptor, HighlightDisplayLevel> problemsMap = new LinkedHashMap<>();
    for (ProblemDescriptor descriptor : runInspectionOnFile(file, inspectionTool)) {
        final ProblemHighlightType highlightType = descriptor.getHighlightType();
        final HighlightDisplayLevel highlightDisplayLevel;
        if (highlightType == ProblemHighlightType.WEAK_WARNING) {
            highlightDisplayLevel = HighlightDisplayLevel.WEAK_WARNING;
        } else if (highlightType == ProblemHighlightType.INFORMATION) {
            highlightDisplayLevel = HighlightDisplayLevel.DO_NOT_SHOW;
        } else {
            highlightDisplayLevel = level;
        }
        problemsMap.put(descriptor, highlightDisplayLevel);
    }
    return problemsMap;
}
Also used : HighlightDisplayLevel(com.intellij.codeHighlighting.HighlightDisplayLevel) LinkedHashMap(com.intellij.util.containers.hash.LinkedHashMap)

Example 9 with LinkedHashMap

use of com.intellij.util.containers.hash.LinkedHashMap in project intellij-community by JetBrains.

the class TemplateImplUtil method parseVariables.

public static LinkedHashMap<String, Variable> parseVariables(CharSequence text) {
    LinkedHashMap<String, Variable> variables = new LinkedHashMap<>();
    TemplateTextLexer lexer = new TemplateTextLexer();
    lexer.start(text);
    while (true) {
        IElementType tokenType = lexer.getTokenType();
        if (tokenType == null)
            break;
        int start = lexer.getTokenStart();
        int end = lexer.getTokenEnd();
        String token = text.subSequence(start, end).toString();
        if (tokenType == TemplateTokenType.VARIABLE) {
            String name = token.substring(1, token.length() - 1);
            if (!variables.containsKey(name)) {
                variables.put(name, new Variable(name, "", "", true));
            }
        }
        lexer.advance();
    }
    return variables;
}
Also used : IElementType(com.intellij.psi.tree.IElementType) LinkedHashMap(com.intellij.util.containers.hash.LinkedHashMap)

Example 10 with LinkedHashMap

use of com.intellij.util.containers.hash.LinkedHashMap in project intellij-community by JetBrains.

the class LookupArranger method prefixReplaced.

public final void prefixReplaced(Lookup lookup, String newPrefix) {
    //noinspection unchecked
    Map<LookupElement, PrefixMatcher> newMatchers = new LinkedHashMap(EqualityPolicy.IDENTITY);
    for (LookupElement item : myItems) {
        if (item.isValid()) {
            PrefixMatcher matcher = itemMatcher(item).cloneWithPrefix(newPrefix);
            if (matcher.prefixMatches(item)) {
                newMatchers.put(item, matcher);
            }
        }
    }
    myMatchers.clear();
    myMatchers.putAll(newMatchers);
    myItems.clear();
    myItems.addAll(newMatchers.keySet());
    prefixChanged(lookup);
}
Also used : PrefixMatcher(com.intellij.codeInsight.completion.PrefixMatcher) LinkedHashMap(com.intellij.util.containers.hash.LinkedHashMap)

Aggregations

LinkedHashMap (com.intellij.util.containers.hash.LinkedHashMap)12 HighlightDisplayLevel (com.intellij.codeHighlighting.HighlightDisplayLevel)2 AnAction (com.intellij.openapi.actionSystem.AnAction)2 RelativePoint (com.intellij.ui.awt.RelativePoint)2 List (java.util.List)2 NotNull (org.jetbrains.annotations.NotNull)2 PrefixMatcher (com.intellij.codeInsight.completion.PrefixMatcher)1 AnnotationHolderImpl (com.intellij.codeInsight.daemon.impl.AnnotationHolderImpl)1 HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)1 CopyPastePreProcessor (com.intellij.codeInsight.editorActions.CopyPastePreProcessor)1 Variable (com.intellij.codeInsight.template.impl.Variable)1 HyperlinkInfo (com.intellij.execution.filters.HyperlinkInfo)1 ProcessInfo (com.intellij.execution.process.ProcessInfo)1 DocumentWindow (com.intellij.injected.editor.DocumentWindow)1 GroupDescriptor (com.intellij.internal.statistic.beans.GroupDescriptor)1 Annotation (com.intellij.lang.annotation.Annotation)1 AnnotationSession (com.intellij.lang.annotation.AnnotationSession)1 ExternalAnnotator (com.intellij.lang.annotation.ExternalAnnotator)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 CommonDataKeys (com.intellij.openapi.actionSystem.CommonDataKeys)1