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();
}
}
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());
}
}
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;
}
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;
}
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);
}
Aggregations