@Nullable private Map<String, String> maybeTestStartedAttributes() { Map<String, String> attributes = null; if (stackTraceLines != null && stackTraceLines.size() > 0) { String firstStackTraceLine = stackTraceLines.get(0); for (Pattern path_pattern : PATH_PATTERNS) { Matcher matcher = path_pattern.matcher(firstStackTraceLine); if (matcher.find()) { String file = matcher.group("file"); String line = matcher.group("line"); String locationHint = "file://" + file + ":" + line; attributes = new THashMap<>(2); attributes.put("locationHint", locationHint); String name = fileToTestName(file); attributes.put("name", name); break; } } } return attributes; }
protected void setupEnvironment(@NotNull Map<String, String> environment) { environment.clear(); environment.putAll(getParentEnvironment()); if (!myEnvParams.isEmpty()) { if (SystemInfo.isWindows) { THashMap<String, String> envVars = new THashMap<String, String>(CaseInsensitiveStringHashingStrategy.INSTANCE); envVars.putAll(environment); envVars.putAll(myEnvParams); environment.clear(); environment.putAll(envVars); } else { environment.putAll(myEnvParams); } } }
/** * Pruning duplicates reduces memory pressure from hprof bloat added in Marshmallow. */ void deduplicateGcRoots(Snapshot snapshot) { // THashMap has a smaller memory footprint than HashMap. final THashMap<String, RootObj> uniqueRootMap = new THashMap<>(); final Collection<RootObj> gcRoots = snapshot.getGCRoots(); for (RootObj root : gcRoots) { String key = generateRootKey(root); if (!uniqueRootMap.containsKey(key)) { uniqueRootMap.put(key, root); } } // Repopulate snapshot with unique GC roots. gcRoots.clear(); uniqueRootMap.forEach(new TObjectProcedure<String>() { @Override public boolean execute(String key) { return gcRoots.add(uniqueRootMap.get(key)); } }); }
lookupElementByElement = new THashMap<PsiElement, LookupElement>();
@NotNull @Override public DataIndexer<String, ServiceSerializable, FileContent> getIndexer() { return inputData -> { Map<String, ServiceSerializable> map = new THashMap<>(); PsiFile psiFile = inputData.getPsiFile(); if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject()) || !isValidForIndex(inputData, psiFile)) { return map; } for (ServiceSerializable service : ServiceContainerUtil.getServicesInFile(psiFile)) { map.put(service.getId().toLowerCase(), service); } return map; }; }
@NotNull private Map<String, Set<String>> getXlfStringMap(@NotNull FileContent inputData) { // testing files are not that nice String relativePath = VfsUtil.getRelativePath(inputData.getFile(), inputData.getProject().getBaseDir(), '/'); if(relativePath != null && (relativePath.contains("/Test/") || relativePath.contains("/Tests/") || relativePath.contains("/Fixture/") || relativePath.contains("/Fixtures/"))) { return Collections.emptyMap(); } // extract domain name String domainName = getDomainName(inputData.getFileName()); if(domainName == null) { return Collections.emptyMap(); } InputStream inputStream; try { inputStream = inputData.getFile().getInputStream(); } catch (IOException e) { return Collections.emptyMap(); } Set<String> set = TranslationUtil.getXliffTranslations(inputStream); if(set.size() == 0) { return Collections.emptyMap(); } // wrap with domain Map<String, Set<String>> map = new THashMap<>(); map.put(domainName, set); return map; }
Map<String, Set<String>> map = new THashMap<>();
@NotNull @Override public DataIndexer<String, FileResource, FileContent> getIndexer() { return inputData -> { PsiFile psiFile = inputData.getPsiFile(); if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject()) || !isValidForIndex(inputData, psiFile)) { return Collections.emptyMap(); } final Map<String, FileResource> items = new THashMap<>(); FileResourceVisitorUtil.visitFile(psiFile, consumer -> items.put(consumer.getResource(), consumer.createFileResource()) ); return items; }; }
@NotNull @Override public DataIndexer<String, Set<String>, FileContent> getIndexer() { return inputData -> { Map<String, Set<String>> map = new THashMap<>(); PsiFile psiFile = inputData.getPsiFile(); if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject())) { return map; } if (!ServicesDefinitionStubIndex.isValidForIndex(inputData, psiFile)) { return map; } if(psiFile instanceof YAMLFile) { map.putAll(FormUtil.getTags((YAMLFile) psiFile)); } if(psiFile instanceof XmlFile) { map.putAll(FormUtil.getTags((XmlFile) psiFile)); } return map; }; }
@NotNull @Override public DataIndexer<String, Void, FileContent> getIndexer() { return inputData -> { final Map<String, Void> map = new THashMap<>(); PsiFile psiFile = inputData.getPsiFile(); if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject())) { return map; } if(!(psiFile instanceof TwigFile)) { return map; } TwigUtil.visitTemplateIncludes((TwigFile) psiFile, templateInclude -> map.put(TwigUtil.normalizeTemplateName(templateInclude.getTemplateName()), null) ); return map; }; }
@NotNull @Override public Map<String, DoctrineModelSerializable> map(@NotNull FileContent fileContent) { Map<String, DoctrineModelSerializable> map = new THashMap<>(); PsiFile psiFile = fileContent.getPsiFile(); if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject()) || !isValidForIndex(fileContent, psiFile)) { return map; } Collection<Pair<String, String>> classRepositoryPair = DoctrineUtil.getClassRepositoryPair(psiFile); if(classRepositoryPair == null || classRepositoryPair.size() == 0) { return map; } for (Pair<String, String> pair : classRepositoryPair) { String first = pair.getFirst(); if(first == null || first.length() == 0) { continue; } map.put(first, new DoctrineModel(first, pair.getSecond())); } return map; } }
@NotNull @Override public DataIndexer<String, Void, FileContent> getIndexer() { return inputData -> { Map<String, Void> map = new THashMap<>(); PsiFile psiFile = inputData.getPsiFile(); if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject())) { return map; } if(!(psiFile instanceof TwigFile)) { return map; } PsiElement[] twigExtendsTags = PsiTreeUtil.collectElements(psiFile, psiElement -> psiElement instanceof TwigExtendsTag ); if(twigExtendsTags.length == 0) { return map; } for(PsiElement twigExtendsTag: twigExtendsTags) { for (String s : TwigUtil.getTwigExtendsTagTemplates((TwigExtendsTag) twigExtendsTag)) { map.put(TwigUtil.normalizeTemplateName(s), null); } } return map; }; }
@NotNull @Override public DataIndexer<String, ContainerBuilderCall, FileContent> getIndexer() { return inputData -> { Map<String, ContainerBuilderCall> map = new THashMap<>(); PsiFile psiFile = inputData.getPsiFile(); if(!(psiFile instanceof PhpFile) || !Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject()) || !isValidForIndex(inputData, psiFile) ){ return map; } psiFile.accept(new MyPsiRecursiveElementWalkingVisitor(map)); return map; }; }
@NotNull @Override public DataIndexer<String, TwigMacroTagIndex, FileContent> getIndexer() { return inputData -> { final Map<String, TwigMacroTagIndex> map = new THashMap<>(); PsiFile psiFile = inputData.getPsiFile(); if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject())) { return map; } if(!(psiFile instanceof TwigFile)) { return map; } TwigUtil.visitMacros(psiFile, pair -> { map.put(pair.getFirst().getName(), new TwigMacroTagIndex(pair.getFirst().getName(), pair.getFirst().getParameters())); }); return map; }; }
public DataIndexer<String, StubIndexedRoute, FileContent> getIndexer() { return inputData -> { Map<String, StubIndexedRoute> map = new THashMap<>();
private static <V> Map<PsiElement, V> psiMap(PsiElement k, V v) { Map<PsiElement, V> map = new THashMap<>(1, 1, CARDINALITY_HASHING_STRATEGY); map.put(k, v); return map; }
@NotNull @Contract(pure=true) public static <KEY, VALUE> Map<KEY, VALUE> map2Map(@NotNull Collection<Pair<KEY, VALUE>> collection) { final Map<KEY, VALUE> result = new THashMap<KEY, VALUE>(collection.size()); for (Pair<KEY, VALUE> pair : collection) { result.put(pair.first, pair.second); } return result; }
public static void resetUniverse() { DEFAULT = new Universe(); allProjectionCaches = new THashMap(); }
@NotNull @Contract(pure=true) public static <K, V> Map<K, V> union(@NotNull Map<? extends K, ? extends V> map, @NotNull Map<? extends K, ? extends V> map2) { Map<K, V> result = new THashMap<K, V>(map.size() + map2.size()); result.putAll(map); result.putAll(map2); return result; }
private void generateParserLambdas(@NotNull String parserClass) { Map<String, String> reversedLambdas = new THashMap<>(); take(myParserLambdas).forEach((name, body) -> { String call = reversedLambdas.get(body); if (call == null) { call = generateParserInstance(body); reversedLambdas.put(body, name); } out("static final Parser " + name + " = " + call + ";"); myRenderedLambdas.put(name, parserClass); }); }