Java Code Examples for gnu.trove.THashMap

The following examples show how to use gnu.trove.THashMap. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: consulo   Author: consulo   File: MapInputDataDiffBuilder.java    License: Apache License 2.0 6 votes vote down vote up
private void processAllKeysAsDeleted(final RemovedKeyProcessor<? super Key> removeProcessor) throws StorageException {
  if (myMap instanceof THashMap) {
    final StorageException[] exception = new StorageException[]{null};
    ((THashMap<Key, Value>)myMap).forEachEntry(new TObjectObjectProcedure<Key, Value>() {
      @Override
      public boolean execute(Key k, Value v) {
        try {
          removeProcessor.process(k, myInputId);
        }
        catch (StorageException e) {
          exception[0] = e;
          return false;
        }
        return true;
      }
    });
    if (exception[0] != null) throw exception[0];
  }
  else {
    for (Key key : myMap.keySet()) {
      removeProcessor.process(key, myInputId);
    }
  }
}
 
Example #2
Source Project: consulo   Author: consulo   File: LogicalRootsManagerImpl.java    License: Apache License 2.0 6 votes vote down vote up
private synchronized  Map<Module, MultiValuesMap<LogicalRootType, LogicalRoot>> getRoots(final ModuleManager moduleManager) {
  if (myRoots == null) {
    myRoots = new THashMap<Module, MultiValuesMap<LogicalRootType, LogicalRoot>>();

    final Module[] modules = moduleManager.getModules();
    for (Module module : modules) {
      final MultiValuesMap<LogicalRootType, LogicalRoot> map = new MultiValuesMap<LogicalRootType, LogicalRoot>();
      for (Map.Entry<LogicalRootType, Collection<NotNullFunction>> entry : myProviders.entrySet()) {
        final Collection<NotNullFunction> functions = entry.getValue();
        for (NotNullFunction function : functions) {
          map.putAll(entry.getKey(), (List<LogicalRoot>) function.fun(module));
        }
      }
      myRoots.put(module, map);
    }
  }

  return myRoots;
}
 
Example #3
Source Project: consulo   Author: consulo   File: UpdateFoldRegionsOperation.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
  EditorFoldingInfo info = EditorFoldingInfo.get(myEditor);
  FoldingModelEx foldingModel = (FoldingModelEx)myEditor.getFoldingModel();
  Map<TextRange, Boolean> rangeToExpandStatusMap = new THashMap<>();

  removeInvalidRegions(info, foldingModel, rangeToExpandStatusMap);

  Map<FoldRegion, Boolean> shouldExpand = new THashMap<>();
  Map<FoldingGroup, Boolean> groupExpand = new THashMap<>();
  List<FoldRegion> newRegions = addNewRegions(info, foldingModel, rangeToExpandStatusMap, shouldExpand, groupExpand);

  applyExpandStatus(newRegions, shouldExpand, groupExpand);

  foldingModel.clearDocumentRangesModificationStatus();
}
 
Example #4
Source Project: semafor-semantic-parser   Author: Noahs-ARK   File: LogLogisticRegressionModel.java    License: GNU General Public License v3.0 6 votes vote down vote up
protected void initializeParameterIndexes() {
	A = new Alphabet();
	V = new LDouble[PARAMETER_TABLE_INITIAL_CAPACITY];
	G = new LDouble[PARAMETER_TABLE_INITIAL_CAPACITY];
	m_trainingData = new ArrayList<TDoubleArrayList>(1000);
	m_trainingLabels = new TIntArrayList(1000);
	m_testData = new ArrayList<TDoubleArrayList>(100);
	m_testLabels = new TIntArrayList(100);
	m_devData = new ArrayList<TDoubleArrayList>(100);
	m_devLabels = new TIntArrayList(100);
	savedValues = new TObjectDoubleHashMap<String>(1000);
	m_savedFormulas = new ArrayList<LogFormula>(FORMULA_LIST_INITIAL_CAPACITY);
	m_current = 0;
	m_savedLLFormulas = new ArrayList<LazyLookupLogFormula>(LLFORMULA_LIST_INITIAL_CAPACITY);
	m_llcurrent = 0;
	mLookupChart = new THashMap<Integer,LogFormula>(PARAMETER_TABLE_INITIAL_CAPACITY);
}
 
Example #5
Source Project: idea-php-drupal-symfony2-bridge   Author: Haehnchen   File: PermissionIndex.java    License: MIT License 6 votes vote down vote up
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {

    return inputData -> {

        Map<String, Void> map = new THashMap<>();

        PsiFile psiFile = inputData.getPsiFile();
        if(!(psiFile instanceof YAMLFile) || !psiFile.getName().endsWith(".permissions.yml")) {
            return map;
        }

        for (YAMLKeyValue yamlKeyValue : YamlHelper.getTopLevelKeyValues((YAMLFile) psiFile)) {
            String keyText = yamlKeyValue.getKeyText();
            if(StringUtils.isBlank(keyText)) {
                continue;
            }

            map.put(keyText, null);
        }

        return map;
    };
}
 
Example #6
Source Project: consulo   Author: consulo   File: WSLDistribution.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @return environment map of the default user in wsl
 */
@Nonnull
public Map<String, String> getEnvironment() {
  try {
    ProcessOutput processOutput = executeOnWsl(5000, "env");
    Map<String, String> result = new THashMap<>();
    for (String string : processOutput.getStdoutLines()) {
      int assignIndex = string.indexOf('=');
      if (assignIndex == -1) {
        result.put(string, "");
      }
      else {
        result.put(string.substring(0, assignIndex), string.substring(assignIndex + 1));
      }
    }
    return result;
  }
  catch (ExecutionException e) {
    LOG.warn(e);
  }

  return Collections.emptyMap();
}
 
Example #7
Source Project: consulo   Author: consulo   File: StdArrangementExtendableSettings.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public List<ArrangementSectionRule> getExtendedSectionRules() {
  synchronized (myExtendedSectionRules) {
    if (myExtendedSectionRules.isEmpty()) {
      final Map<String, StdArrangementRuleAliasToken> tokenIdToDefinition = new THashMap<String, StdArrangementRuleAliasToken>(myRulesAliases.size());
      for (StdArrangementRuleAliasToken alias : myRulesAliases) {
        final String id = alias.getId();
        tokenIdToDefinition.put(id, alias);
      }

      final List<ArrangementSectionRule> sections = getSections();
      for (ArrangementSectionRule section : sections) {
        final List<StdArrangementMatchRule> extendedRules = new ArrayList<StdArrangementMatchRule>();
        for (StdArrangementMatchRule rule : section.getMatchRules()) {
          appendExpandedRules(rule, extendedRules, tokenIdToDefinition);
        }
        myExtendedSectionRules.add(ArrangementSectionRule.create(section.getStartComment(), section.getEndComment(), extendedRules));
      }
    }
  }
  return myExtendedSectionRules;
}
 
Example #8
Source Project: consulo   Author: consulo   File: Win32FsCache.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
FileAttributes getAttributes(@Nonnull VirtualFile file) {
  VirtualFile parent = file.getParent();
  int parentId = parent instanceof VirtualFileWithId ? ((VirtualFileWithId)parent).getId() : -((VirtualFileWithId)file).getId();
  TIntObjectHashMap<THashMap<String, FileAttributes>> map = getMap();
  THashMap<String, FileAttributes> nestedMap = map.get(parentId);
  String name = file.getName();
  FileAttributes attributes = nestedMap != null ? nestedMap.get(name) : null;

  if (attributes == null) {
    if (nestedMap != null && !(nestedMap instanceof IncompleteChildrenMap)) {
      return null; // our info from parent doesn't mention the child in this refresh session
    }
    FileInfo info = myKernel.getInfo(file.getPath());
    if (info == null) {
      return null;
    }
    attributes = info.toFileAttributes();
    if (nestedMap == null) {
      nestedMap = new IncompleteChildrenMap<>(FileUtil.PATH_HASHING_STRATEGY);
      map.put(parentId, nestedMap);
    }
    nestedMap.put(name, attributes);
  }
  return attributes;
}
 
Example #9
Source Project: semafor-semantic-parser   Author: Noahs-ARK   File: PaperEvaluation.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void convertGoldTestToFramesFile()
{
	String goldFile = malRootDir+"/testdata/johansson.fulltest.sentences.frames";
	String outFile = malRootDir+"/FrameStructureExtraction/release/temp_johansson_full/file.frame.elements";
	ArrayList<String> inLines = ParsePreparation.readSentencesFromFile(goldFile);
	ArrayList<String> outLines = new ArrayList<String>();
	THashMap<String,THashSet<String>> frameMap = (THashMap<String,THashSet<String>>)SerializedObjects.readSerializedObject("lrdata/framenet.original.map");
	for(String inLine: inLines)
	{	
		String[] toks = inLine.split("\t");
		if(!frameMap.contains(toks[0]))
				continue;
		String outLine = "1\t"+toks[0]+"\t"+toks[1]+"\t"+toks[2]+"\t"+toks[3]+"\t"+toks[4];
		outLines.add(outLine);
	}
	ParsePreparation.writeSentencesToTempFile(outFile, outLines);
}
 
Example #10
Source Project: semafor-semantic-parser   Author: Noahs-ARK   File: PaperEvaluation.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void convertGoldJohanssonToFramesFile()
{
	String goldFile = malRootDir+"/testdata/semeval.fulltest.sentences.frame.elements";
	String outFile = malRootDir+"/testdata/file.frame.elements";
	ArrayList<String> inLines = ParsePreparation.readSentencesFromFile(goldFile);
	ArrayList<String> outLines = new ArrayList<String>();
	THashMap<String,THashSet<String>> frameMap = (THashMap<String,THashSet<String>>)SerializedObjects.readSerializedObject("lrdata/framenet.original.map");
	for(String inLine: inLines)
	{	
		String[] toks = inLine.split("\t");
		if(!frameMap.contains(toks[1]))
				continue;
		String outLine = "1\t"+toks[1]+"\t"+toks[2]+"\t"+toks[3]+"\t"+toks[4]+"\t"+toks[5];
		outLines.add(outLine);
	}
	ParsePreparation.writeSentencesToTempFile(outFile, outLines);
}
 
Example #11
Source Project: consulo   Author: consulo   File: AbstractCollectionBinding.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
private synchronized Map<Class<?>, Binding> getElementBindings() {
  if (itemBindings == null) {
    Binding binding = XmlSerializerImpl.getBinding(itemType);
    if (annotation == null || annotation.elementTypes().length == 0) {
      itemBindings = binding == null ? Collections.<Class<?>, Binding>emptyMap() : Collections.<Class<?>, Binding>singletonMap(itemType, binding);
    }
    else {
      itemBindings = new THashMap<Class<?>, Binding>();
      if (binding != null) {
        itemBindings.put(itemType, binding);
      }
      for (Class aClass : annotation.elementTypes()) {
        Binding b = XmlSerializerImpl.getBinding(aClass);
        if (b != null) {
          itemBindings.put(aClass, b);
        }
      }
      if (itemBindings.isEmpty()) {
        itemBindings = Collections.emptyMap();
      }
    }
  }
  return itemBindings;
}
 
Example #12
Source Project: semafor-semantic-parser   Author: Noahs-ARK   File: FixTokenization.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void fixTokenization(String inputFile, String outputFile, THashMap<String, String> conv)
{
	try
	{
		BufferedReader bReader = new BufferedReader(new FileReader(inputFile));
		BufferedWriter bWriter = new BufferedWriter(new FileWriter(outputFile));
		String line = null;
		while((line=bReader.readLine())!=null)
		{	
			line = line.trim();
			System.out.println(line);
			line = fixDoubleQuotes(line,conv);
			line = fixOpeningQuote(line,conv);
			line = fixClosingQuote(line,conv);
			bWriter.write(line+"\n");
		}			
		bReader.close();
		bWriter.close();
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}		
}
 
Example #13
Source Project: idea-php-symfony2-plugin   Author: Haehnchen   File: TwigIncludeStubIndex.java    License: MIT License 6 votes vote down vote up
@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;
    };

}
 
Example #14
Source Project: consulo   Author: consulo   File: LocalFileSystemRefreshWorker.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param fileOrDir
 * @param refreshContext
 * @param childrenToRefresh  null means all
 * @param existingPersistentChildren
 */
RefreshingFileVisitor(@Nonnull NewVirtualFile fileOrDir,
                      @Nonnull RefreshContext refreshContext,
                      @Nullable Collection<String> childrenToRefresh,
                      @Nonnull Collection<? extends VirtualFile> existingPersistentChildren) {
  myFileOrDir = fileOrDir;
  myRefreshContext = refreshContext;
  myPersistentChildren = new THashMap<>(existingPersistentChildren.size(), refreshContext.strategy);
  myChildrenWeAreInterested = childrenToRefresh == null ? null : new THashSet<>(childrenToRefresh, refreshContext.strategy);

  for (VirtualFile child : existingPersistentChildren) {
    String name = child.getName();
    myPersistentChildren.put(name, child);
    if (myChildrenWeAreInterested != null) myChildrenWeAreInterested.add(name);
  }
}
 
Example #15
Source Project: idea-php-laravel-plugin   Author: Haehnchen   File: BladeStackStubIndex.java    License: MIT License 6 votes vote down vote up
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
    return fileContent -> {
        final Map<String, Void> map = new THashMap<>();
        PsiFile psiFile = fileContent.getPsiFile();

        if(!(psiFile instanceof BladeFileImpl)) {
            return map;
        }

        psiFile.acceptChildren(new BladeDirectivePsiElementWalkingVisitor(BladeTokenTypes.STACK_DIRECTIVE, map));

        return map;
    };
}
 
Example #16
Source Project: consulo-csharp   Author: consulo   File: ThisKindProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
@Override
public void process(@Nonnull CSharpResolveOptions options,
		@Nonnull DotNetGenericExtractor defaultExtractor,
		@Nullable PsiElement forceQualifierElement,
		@Nonnull Processor<ResolveResult> processor)
{
	DotNetTypeDeclaration thisTypeDeclaration = PsiTreeUtil.getContextOfType(options.getElement(), DotNetTypeDeclaration.class);
	if(thisTypeDeclaration != null)
	{
		thisTypeDeclaration = CSharpCompositeTypeDeclaration.selectCompositeOrSelfType(thisTypeDeclaration);

		DotNetGenericExtractor genericExtractor = DotNetGenericExtractor.EMPTY;
		int genericParametersCount = thisTypeDeclaration.getGenericParametersCount();
		if(genericParametersCount > 0)
		{
			Map<DotNetGenericParameter, DotNetTypeRef> map = new THashMap<>(genericParametersCount);
			for(DotNetGenericParameter genericParameter : thisTypeDeclaration.getGenericParameters())
			{
				map.put(genericParameter, new CSharpTypeRefFromGenericParameter(genericParameter));
			}
			genericExtractor = CSharpGenericExtractor.create(map);
		}
		processor.process(new CSharpResolveResultWithExtractor(thisTypeDeclaration, genericExtractor));
	}
}
 
Example #17
Source Project: intellij-haxe   Author: HaxeFoundation   File: HaxeSymbolIndex.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@NotNull
public Map<String, Void> map(@NotNull final FileContent inputData) {
  final PsiFile psiFile = inputData.getPsiFile();
  final List<HaxeClass> classes = HaxeResolveUtil.findComponentDeclarations(psiFile);
  if (classes.isEmpty()) {
    return Collections.emptyMap();
  }
  final Map<String, Void> result = new THashMap<>();
  for (HaxeClass haxeClass : classes) {
    final String className = haxeClass.getName();
    if (className == null) {
      continue;
    }
    result.put(className, null);
    for (HaxeNamedComponent namedComponent : getNamedComponents(haxeClass)) {
      result.put(namedComponent.getName(), null);
    }
  }
  return result;
}
 
Example #18
Source Project: consulo   Author: consulo   File: BTreeEnumeratorTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testAddEqualStringsAndMuchGarbage() throws IOException {
  final Map<Integer,String> strings = new THashMap<Integer, String>(10001);
  String s = "IntelliJ IDEA";
  final int index = myEnumerator.enumerate(s);
  strings.put(index, s);

  // clear strings and nodes cache
  for (int i = 0; i < 10000; ++i) {
    final String v = Integer.toString(i) + "Just another string";
    final int idx = myEnumerator.enumerate(v);
    assertEquals(v, myEnumerator.valueOf(idx));
    strings.put(idx, v);
  }

  for(Map.Entry<Integer, String> e:strings.entrySet()) {
    assertEquals((int)e.getKey(), myEnumerator.enumerate(e.getValue()));
  }

  final Set<String> enumerated = new HashSet<String>(myEnumerator.getAllDataObjects(null));
  assertEquals(new HashSet<String>(strings.values()), enumerated);
}
 
Example #19
Source Project: idea-php-drupal-symfony2-bridge   Author: Haehnchen   File: ConfigEntityTypeAnnotationIndex.java    License: MIT License 6 votes vote down vote up
@NotNull
@Override
public DataIndexer<String, String, FileContent> getIndexer() {
    return inputData -> {
        final Map<String, String> map = new THashMap<>();

        PsiFile psiFile = inputData.getPsiFile();
        if(!(psiFile instanceof PhpFile)) {
            return map;
        }

        if(!IndexUtil.isValidForIndex(inputData, psiFile)) {
            return map;
        }

        psiFile.accept(new MyPsiRecursiveElementWalkingVisitor(map));

        return map;
    };
}
 
Example #20
public static THashMap<String, THashMap<String, Double>> 
	readTrainDistFile(String trainDistFile) {
	THashMap<String, THashMap<String, Double>> result = 
		new THashMap<String, THashMap<String, Double>>();
	ArrayList<String> sents = ParsePreparation.readSentencesFromFile(trainDistFile);
	for (String sent: sents) {
		sent = sent.trim();
		String[] toks = sent.split("\t");
		String pred = toks[0];
		String[] toks1 = toks[1].trim().split(" ");
		THashMap<String, Double> map = new THashMap<String, Double>();
			for (int i = 0; i < toks1.length; i = i + 2) {
			String frame = toks1[i];
			double prob = new Double(toks1[i+1]);
			map.put(frame, prob);
		}
			result.put(pred, map);
	}
	return result;
}
 
Example #21
Source Project: consulo   Author: consulo   File: SemServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public <T extends SemElement> List<T> getSemElements(final SemKey<T> key, @Nonnull final PsiElement psi) {
  List<T> cached = _getCachedSemElements(key, true, psi);
  if (cached != null) {
    return cached;
  }

  ensureInitialized();

  RecursionGuard.StackStamp stamp = RecursionManager.createGuard("semService").markStack();

  LinkedHashSet<T> result = new LinkedHashSet<>();
  final Map<SemKey, List<SemElement>> map = new THashMap<>();
  for (final SemKey each : key.getInheritors()) {
    List<SemElement> list = createSemElements(each, psi);
    map.put(each, list);
    result.addAll((List<T>)list);
  }

  if (stamp.mayCacheNow()) {
    final SemCacheChunk persistent = getOrCreateChunk(psi);
    for (SemKey semKey : map.keySet()) {
      persistent.putSemElements(semKey, map.get(semKey));
    }
  }

  return new ArrayList<>(result);
}
 
Example #22
Source Project: Custom-Syntax-Highlighter   Author: mallowigi   File: JSColorSettings.java    License: MIT License 5 votes vote down vote up
private static Map<String, TextAttributesKey> createAdditionalHlAttrs() {
  final Map<String, TextAttributesKey> descriptors = new THashMap<>();
  descriptors.put("keyword", JSColorSettings.JSKEYWORD);
  descriptors.put("function", JSColorSettings.FUNCTION);
  descriptors.put("function_name", JSColorSettings.FUNCTION_NAME);
  descriptors.put("val", JSColorSettings.VAL);
  descriptors.put("local_variable", JSColorSettings.VARIABLE);
  descriptors.put("this", JSColorSettings.THIS_SUPER);
  descriptors.put("null", JSColorSettings.NULL);
  descriptors.put("debugger", JSColorSettings.DEBUGGER);
  descriptors.put("import", JSColorSettings.MODULE);

  return descriptors;
}
 
Example #23
Source Project: idea-php-typo3-plugin   Author: cedricziel   File: ResourcePathIndex.java    License: MIT License 5 votes vote down vote up
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
    return inputData -> {
        Map<String, Void> map = new THashMap<>();

        String path = inputData.getFile().getPath();
        if (path.contains("sysext") || path.contains("typo3conf/ext")) {
            map.putAll(compileId(inputData));

            return map;
        }

        VirtualFile extensionRootFolder = FilesystemUtil.findExtensionRootFolder(inputData.getFile());
        if (extensionRootFolder != null) {
            // 1. try to read sibling composer.json
            VirtualFile composerJsonFile = extensionRootFolder.findChild("composer.json");
            if (composerJsonFile != null) {
                String extensionKey = findExtensionKey(composerJsonFile);
                if (extensionKey != null) {
                    map.putAll(compileId(extensionRootFolder, extensionKey, inputData.getFile()));
                    return map;
                }
            }

            // 2. try to infer from directory name
            map.putAll(compileId(extensionRootFolder.getName(), extensionRootFolder.getPath(), inputData.getFile()));
        }

        return map;
    };
}
 
Example #24
Source Project: consulo   Author: consulo   File: InspectionEngine.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
public static Map<LocalInspectionToolWrapper, Set<String>> getToolsToSpecifiedLanguages(@Nonnull List<LocalInspectionToolWrapper> toolWrappers) {
  Map<LocalInspectionToolWrapper, Set<String>> toolToLanguages = new THashMap<>();
  for (LocalInspectionToolWrapper wrapper : toolWrappers) {
    ProgressManager.checkCanceled();
    Set<String> specifiedLangIds = getDialectIdsSpecifiedForTool(wrapper);
    toolToLanguages.put(wrapper, specifiedLangIds);
  }
  return toolToLanguages;
}
 
Example #25
Source Project: consulo   Author: consulo   File: CachingChildrenTreeNode.java    License: Apache License 2.0 5 votes vote down vote up
private Map<Group, GroupWrapper> createGroupNodes(Collection<Group> groups) {
  Map<Group, GroupWrapper> result = new THashMap<Group, GroupWrapper>();
  for (Group group : groups) {
    result.put(group, createGroupWrapper(getProject(), group, myTreeModel));
  }
  return result;
}
 
Example #26
Source Project: intellij-haxe   Author: HaxeFoundation   File: HaxeGenericSpecialization.java    License: Apache License 2.0 5 votes vote down vote up
@NotNull
public HaxeGenericSpecialization getInnerSpecialization(PsiElement element) {
  final String prefixToRemove = getGenericKey(element, "");
  final Map<String, HaxeClassResolveResult> result = new THashMap<String, HaxeClassResolveResult>();
  for (String key : map.keySet()) {
    final HaxeClassResolveResult value = map.get(key);
    String newKey = key;
    if (newKey.startsWith(prefixToRemove)) {
      newKey = newKey.substring(prefixToRemove.length());
    }
    result.put(newKey, value);
  }
  return new HaxeGenericSpecialization(result);
}
 
Example #27
Source Project: idea-php-drupal-symfony2-bridge   Author: Haehnchen   File: ConfigSchemaIndex.java    License: MIT License 5 votes vote down vote up
@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(!(psiFile instanceof YAMLFile) || !isValidForIndex(psiFile)) {
            return map;
        }

        for(YAMLKeyValue yamlKeyValue: YamlHelper.getTopLevelKeyValues((YAMLFile) psiFile)) {
            String key = PsiElementUtils.trimQuote(yamlKeyValue.getKeyText());

            if(StringUtils.isBlank(key) || key.contains("*")) {
                continue;
            }

            Set<String> mappings = new HashSet<>();
            YAMLKeyValue mapping = YamlHelper.getYamlKeyValue(yamlKeyValue, "mapping");
            if(mapping == null) {
                continue;
            }

            Set<String> keySet = YamlHelper.getKeySet(mapping);
            if(keySet != null) {
                mappings.addAll(keySet);
            }

            map.put(key, mappings);
        }

        return map;
    };

}
 
Example #28
Source Project: idea-php-typo3-plugin   Author: cedricziel   File: FluidUtil.java    License: MIT License 5 votes vote down vote up
public static Map<String, FluidVariable> collectControllerVariables(FluidFile templateFile) {
    Map<String, FluidVariable> collected = new THashMap<>();
    String controllerName = inferControllerNameFromTemplateFile(templateFile);
    String actionName = inferActionNameFromTemplateFile(templateFile);

    findPossibleMethodTargetsForControllerAction(templateFile.getProject(), controllerName, actionName).forEach(c -> {
        ControllerMethodWalkerVisitor visitor = new ControllerMethodWalkerVisitor();
        c.accept(visitor);

        collected.putAll(visitor.variables);
    });

    return collected;
}
 
Example #29
Source Project: consulo   Author: consulo   File: XDebuggerUtilImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public <B extends XBreakpoint<?>> XBreakpointType<B, ?> findBreakpointType(@Nonnull Class<? extends XBreakpointType<B, ?>> typeClass) {
  if (myBreakpointTypeByClass == null) {
    myBreakpointTypeByClass = new THashMap<Class<? extends XBreakpointType>, XBreakpointType<?, ?>>();
    for (XBreakpointType<?, ?> breakpointType : XBreakpointUtil.getBreakpointTypes()) {
      myBreakpointTypeByClass.put(breakpointType.getClass(), breakpointType);
    }
  }
  XBreakpointType<?, ?> type = myBreakpointTypeByClass.get(typeClass);
  //noinspection unchecked
  return (XBreakpointType<B, ?>)type;
}
 
Example #30
Source Project: idea-php-typo3-plugin   Author: cedricziel   File: InTemplateDeclarationVariableProvider.java    License: MIT License 5 votes vote down vote up
private Map<String, FluidVariable> collectXmlMapViewHelperSetVariables(PsiElement psiElement) {
    if (!containsLanguage(HTMLLanguage.INSTANCE, psiElement)) {
        return new THashMap<>();
    }

    PsiFile psi = extractLanguagePsiForElement(HTMLLanguage.INSTANCE, psiElement);
    if (psi == null) {
        return new THashMap<>();
    }

    XmlFAliasVisitor visitor = new XmlFAliasVisitor();
    psi.accept(visitor);

    return visitor.variables;
}