com.intellij.psi.SmartPointerManager#gnu.trove.THashSet源码实例Demo

下面列出了com.intellij.psi.SmartPointerManager#gnu.trove.THashSet 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: consulo   文件: ModuleGroup.java
public Collection<ModuleGroup> childGroups(ModifiableModuleModel model, Project project) {
  final Module[] allModules;
  if ( model != null ) {
    allModules = model.getModules();
  } else {
    allModules = ModuleManager.getInstance(project).getModules();
  }

  Set<ModuleGroup> result = new THashSet<ModuleGroup>();
  for (Module module : allModules) {
    String[] group;
    if ( model != null ) {
      group = model.getModuleGroupPath(module);
    } else {
      group = ModuleManager.getInstance(project).getModuleGroupPath(module);
    }
    if (group == null) continue;
    final String[] directChild = directChild(myGroupPath, group);
    if (directChild != null) {
      result.add(new ModuleGroup(directChild));
    }
  }

  return result;
}
 
源代码2 项目: intellij-haxe   文件: HaxeSuggestIndexNameMacro.java
@Override
public Result calculateResult(@NotNull Expression[] params, ExpressionContext context) {
  final PsiElement at = context.getPsiElementAtStartOffset();
  final Set<HaxeComponentName> variables = HaxeMacroUtil.findVariables(at);
  final Set<String> names = new THashSet<String>(ContainerUtil.map(variables, new Function<HaxeComponentName, String>() {
    @Override
    public String fun(HaxeComponentName name) {
      return name.getName();
    }
  }));
  for (char i = 'i'; i < 'z'; ++i) {
    if (!names.contains(Character.toString(i))) {
      return new TextResult(Character.toString(i));
    }
  }
  return null;
}
 
源代码3 项目: flutter-intellij   文件: DartVmServiceEvaluator.java
private LibraryRef findMatchingLibrary(Isolate isolate, List<VirtualFile> libraryFiles) {
  if (libraryFiles != null && !libraryFiles.isEmpty()) {
    final Set<String> uris = new THashSet<>();

    for (VirtualFile libraryFile : libraryFiles) {
      uris.addAll(myDebugProcess.getUrisForFile(libraryFile));
    }

    for (LibraryRef library : isolate.getLibraries()) {
      if (uris.contains(library.getUri())) {
        return library;
      }
    }
  }
  return isolate.getRootLib();
}
 
源代码4 项目: semafor-semantic-parser   文件: ScrapTest.java
public static THashSet<String> getSpans()
{
	THashSet<String> spans = new THashSet<String>();
	try
	{
		String line = null;
		BufferedReader bReader = new BufferedReader(new FileReader("lrdata/matched_spans"));
		while((line=bReader.readLine())!=null)
		{
			String[] toks = line.trim().split("\t");
			char first = toks[0].charAt(0);
			if((first>='a'&&first<='z')||(first>='A'&&first<='Z')||(first>='0'&&first<='9'))
			{
				spans.add(toks[0].trim());
			}
		}
		bReader.close();
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
	return spans;
}
 
源代码5 项目: consulo   文件: ModuleWithDependentsScope.java
private static Set<Module> buildDependents(Module module) {
  Set<Module> result = new THashSet<Module>();
  result.add(module);

  Set<Module> processedExporting = new THashSet<Module>();

  ModuleIndex index = getModuleIndex(module.getProject());

  Queue<Module> walkingQueue = new Queue<Module>(10);
  walkingQueue.addLast(module);

  while (!walkingQueue.isEmpty()) {
    Module current = walkingQueue.pullFirst();
    processedExporting.add(current);
    result.addAll(index.plainUsages.get(current));
    for (Module dependent : index.exportingUsages.get(current)) {
      result.add(dependent);
      if (processedExporting.add(dependent)) {
        walkingQueue.addLast(dependent);
      }
    }
  }
  return result;
}
 
源代码6 项目: consulo   文件: LocalFileSystemRefreshWorker.java
/**
 * @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);
  }
}
 
源代码7 项目: semafor-semantic-parser   文件: PaperEvaluation.java
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);
}
 
源代码8 项目: semafor-semantic-parser   文件: PaperEvaluation.java
public static void convertGoldTestToFramesFileOracleSpans()
{
	String goldFile = malRootDir+"/testdata/semeval.fulltest.sentences.frame.elements";
	String outFile = malRootDir+"/testdata/file.os.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;
		outLines.add(inLine);
	}
	ParsePreparation.writeSentencesToTempFile(outFile, outLines);
}
 
public static void printMap()
{
	String mapFile = "/mal2/dipanjan/experiments/FramenetParsing/framenet_1.3/ddData/framenet.original.map";
	THashMap<String,THashSet<String>> map = (THashMap<String,THashSet<String>>)SerializedObjects.readSerializedObject(mapFile);
	Set<String> set = map.keySet();
	for(String frame: set)
	{
		THashSet<String> val = map.get(frame);
		System.out.print(frame+": ");
		for(String unit: val)
		{
			System.out.print(unit+" ");
		}
		System.out.println();
	}
}
 
/**
 * From flat-text files with sentences and frame occurrence information, 
 * creates a map from frame names to target words observed as evoking that frame 
 * and stores that map as a serialized object
 * @author dipanjan
 */
public static void writeMapOfFrames()
{
	String tokenizedFrameNetFile = "/mal2/dipanjan/experiments/FramenetParsing/framenet_1.3/ddData/framenet.original.sentences.all.tags";
	ArrayList<String> sentences = ParsePreparation.readSentencesFromFile(tokenizedFrameNetFile);
	String frameNetFrameFile = "/mal2/dipanjan/experiments/FramenetParsing/framenet_1.3/ddData/framenet.original.sentences.frames";
	ArrayList<String> frames = ParsePreparation.readSentencesFromFile(frameNetFrameFile);
	THashMap<String,THashSet<String>> map = new THashMap<String,THashSet<String>>();
	fillMap(map,frames,sentences);
			
	tokenizedFrameNetFile = "/mal2/dipanjan/experiments/FramenetParsing/framenet_1.3/ddData/semeval.fulltrain.sentences.all.tags";
	sentences = ParsePreparation.readSentencesFromFile(tokenizedFrameNetFile);
	frameNetFrameFile = "/mal2/dipanjan/experiments/FramenetParsing/framenet_1.3/ddData/semeval.fulltrain.sentences.frames";
	frames = ParsePreparation.readSentencesFromFile(frameNetFrameFile);
	fillMap(map,frames,sentences);		
	
	System.out.println(map.size());
	String mapFile = "/mal2/dipanjan/experiments/FramenetParsing/framenet_1.3/ddData/framenet.original.map";
	SerializedObjects.writeSerializedObject(map, mapFile);
}
 
源代码11 项目: consulo   文件: CodeInsightUtilBase.java
@Override
public boolean preparePsiElementsForWrite(@Nonnull Collection<? extends PsiElement> elements) {
  if (elements.isEmpty()) return true;
  Set<VirtualFile> files = new THashSet<VirtualFile>();
  Project project = null;
  for (PsiElement element : elements) {
    if (element == null) continue;
    PsiFile file = element.getContainingFile();
    if (file == null || !file.isPhysical()) continue;
    project = file.getProject();
    VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile == null) continue;
    files.add(virtualFile);
  }
  if (!files.isEmpty()) {
    VirtualFile[] virtualFiles = VfsUtilCore.toVirtualFileArray(files);
    ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(virtualFiles);
    return !status.hasReadonlyFiles();
  }
  return true;
}
 
源代码12 项目: consulo   文件: BaseDataManager.java
@Nullable
public <T> T getDataFromProvider(@Nonnull final DataProvider provider, @Nonnull Key<T> dataId, @Nullable Set<Key> alreadyComputedIds) {
  if (alreadyComputedIds != null && alreadyComputedIds.contains(dataId)) {
    return null;
  }
  try {
    T data = provider.getDataUnchecked(dataId);
    if (data != null) return validated(data, dataId, provider);

    GetDataRule<T> dataRule = getDataRule(dataId);
    if (dataRule != null) {
      final Set<Key> ids = alreadyComputedIds == null ? new THashSet<>() : alreadyComputedIds;
      ids.add(dataId);
      data = dataRule.getData(id -> getDataFromProvider(provider, id, ids));

      if (data != null) return validated(data, dataId, provider);
    }

    return null;
  }
  finally {
    if (alreadyComputedIds != null) alreadyComputedIds.remove(dataId);
  }
}
 
private double getValueForFrame(String frame, int[] intTokNums, String[][] data)	
{
	THashSet<String> hiddenUnits = mFrameMap.get(frame);
	double result = 0.0;
	DependencyParse parse = DependencyParse.processFN(data, 0.0);
	for (String unit : hiddenUnits)
	{
		FeatureExtractor featex = new FeatureExtractor();
		IntCounter<String> valMap =  featex.extractFeatures(frame, intTokNums, unit, data, mWNR, "test", mWnRelationsCache,null,parse);
		Set<String> features = valMap.keySet();
		double featSum = 0.0;
		for (String feat : features)
		{
			double val = valMap.getT(feat);
			int ind = localA.get(feat);
			double paramVal = V[ind].exponentiate();
			double prod = val*paramVal;
			featSum+=prod;
		}
		double expVal = Math.exp(featSum);
		result+=expVal;
	}
	return result;
}
 
源代码14 项目: semafor-semantic-parser   文件: FeatureExtractor.java
public Set<String> getWNRelations(THashMap<String, THashSet<String>> wnCacheMap,String sWord, String tWord, WordNetRelations wnr)
{
	String pair = sWord.toLowerCase()+"\t"+tWord.toLowerCase();
	if(wnCacheMap==null)
	{
		return wnr.getRelations(sWord.toLowerCase(), tWord.toLowerCase());
	}
	else if(!wnCacheMap.contains(pair))
	{
		Set<String> relations = wnr.getRelations(sWord.toLowerCase(), tWord.toLowerCase());
		if(relations.contains(WordNetRelations.NO_RELATION))
			return relations;
		else
		{
			THashSet<String> nR = new THashSet<String>();
			for(String string:relations)
				nR.add(string);
			wnCacheMap.put(pair, nR);
			return relations;
		}
	}
	else
	{
		return wnCacheMap.get(pair);
	}
}
 
源代码15 项目: consulo   文件: ArchivesBuilder.java
private <T> void addFileToArchive(@Nonnull T archiveObject,
                                  @Nonnull ArchivePackageWriter<T> writer,
                                  @Nonnull File file,
                                  @Nonnull String relativePath,
                                  @Nonnull THashSet<String> writtenPaths) throws IOException {
  if (!file.exists()) {
    return;
  }

  if (!FileUtil.isFilePathAcceptable(file, myFileFilter)) {
    return;
  }

  if (!writtenPaths.add(relativePath)) {
    return;
  }

  relativePath = addParentDirectories(archiveObject, writer, writtenPaths, relativePath);

  myContext.getProgressIndicator().setText2(relativePath);

  try (FileInputStream fileOutputStream = new FileInputStream(file)) {
    writer.addFile(archiveObject, fileOutputStream, relativePath, file.length(), file.lastModified());
  }
}
 
源代码16 项目: semafor-semantic-parser   文件: Range.java
public static Set<Integer> intersect(List<? extends Range> ranges) {
	Set<Integer> union = union(ranges);
	Set<Integer> result = new THashSet<Integer>();
	for (int i : union) {
		boolean included = true;
		for (Range range : ranges) {
			if (!range.contains(i)) {
				included = false;
				break;
			}
			if (included)
				result.add(i);
		}
	}
	return result;
}
 
@RequiredUIAccess
@Nonnull
@Override
public AsyncResult<Void> configureTask(RunConfiguration runConfiguration, T task) {
  final Artifact[] artifacts = ArtifactManager.getInstance(myProject).getArtifacts();
  Set<ArtifactPointer> pointers = new THashSet<>();
  for (Artifact artifact : artifacts) {
    pointers.add(ArtifactPointerManager.getInstance(myProject).create(artifact));
  }
  pointers.addAll(task.getArtifactPointers());
  ArtifactChooser chooser = new ArtifactChooser(new ArrayList<>(pointers));
  chooser.markElements(task.getArtifactPointers());
  chooser.setPreferredSize(new Dimension(400, 300));

  DialogBuilder builder = new DialogBuilder(myProject);
  builder.setTitle(CompilerBundle.message("build.artifacts.before.run.selector.title"));
  builder.setDimensionServiceKey("#BuildArtifactsBeforeRunChooser");
  builder.addOkAction();
  builder.addCancelAction();
  builder.setCenterPanel(chooser);
  builder.setPreferredFocusComponent(chooser);

  AsyncResult<Void> result = builder.showAsync();
  result.doWhenDone(() -> task.setArtifactPointers(chooser.getMarkedElements()));
  return result;
}
 
源代码18 项目: consulo   文件: DesktopEditorsSplitters.java
@Override
@Nonnull
public FileEditor[] getSelectedEditors() {
  Set<DesktopEditorWindow> windows = new THashSet<>(myWindows);
  final EditorWindow currentWindow = getCurrentWindow();
  if (currentWindow != null) {
    windows.add((DesktopEditorWindow)currentWindow);
  }
  List<FileEditor> editors = new ArrayList<>();
  for (final DesktopEditorWindow window : windows) {
    final DesktopEditorWithProviderComposite composite = window.getSelectedEditor();
    if (composite != null) {
      editors.add(composite.getSelectedEditor());
    }
  }
  return editors.toArray(new FileEditor[editors.size()]);
}
 
源代码19 项目: consulo   文件: StdArrangementExtendableSettings.java
private Set<StdArrangementRuleAliasToken> cloneTokenDefinitions() {
  final Set<StdArrangementRuleAliasToken> definitions = new THashSet<StdArrangementRuleAliasToken>();
  for (StdArrangementRuleAliasToken definition : myRulesAliases) {
    definitions.add(definition.clone());
  }
  return definitions;
}
 
@NotNull
private Set<String> getNewIfNotPresent(@Nullable Set<String> siblingsToExclude) {
  if (siblingsToExclude == null) {
    return new THashSet<>();
  }
  return siblingsToExclude;
}
 
源代码21 项目: consulo   文件: FileIncludeManagerImpl.java
@Nonnull
private static Collection<String> getPossibleIncludeNames(@Nonnull PsiFile context, @Nonnull String originalName) {
  Collection<String> names = new THashSet<>();
  names.add(originalName);
  for (FileIncludeProvider provider : FileIncludeProvider.EP_NAME.getExtensions()) {
    String newName = provider.getIncludeName(context, originalName);
    if (newName != originalName) {
      names.add(newName);
    }
  }
  return names;
}
 
源代码22 项目: consulo   文件: PsiSearchHelperImpl.java
/**
 *
 * @param commonScope
 * @param data
 * @param keys
 * @return null means we did not find common container files
 */
@Nullable
private Set<VirtualFile> intersectionWithContainerNameFiles(@Nonnull GlobalSearchScope commonScope,
                                                            @Nonnull Collection<RequestWithProcessor> data,
                                                            @Nonnull Set<IdIndexEntry> keys) {
  String commonName = null;
  short searchContext = 0;
  boolean caseSensitive = true;
  for (RequestWithProcessor r : data) {
    String containerName = r.request.containerName;
    if (containerName != null) {
      if (commonName == null) {
        commonName = containerName;
        searchContext = r.request.searchContext;
        caseSensitive = r.request.caseSensitive;
      }
      else if (commonName.equals(containerName)) {
        searchContext |= r.request.searchContext;
        caseSensitive &= r.request.caseSensitive;
      }
      else {
        return null;
      }
    }
  }
  if (commonName == null) return null;

  List<IdIndexEntry> entries = getWordEntries(commonName, caseSensitive);
  if (entries.isEmpty()) return null;
  entries.addAll(keys); // should find words from both text and container names

  final short finalSearchContext = searchContext;
  Condition<Integer> contextMatches = context -> (context.intValue() & finalSearchContext) != 0;
  Set<VirtualFile> containerFiles = new THashSet<>();
  Processor<VirtualFile> processor = Processors.cancelableCollectProcessor(containerFiles);
  processFilesContainingAllKeys(myManager.getProject(), commonScope, contextMatches, entries, processor);

  return containerFiles;
}
 
/**
 * @param originalName name that is not sanitised
 * @param parent       parent MetadataNonPropertySuggestionNode node
 * @param belongsTo    file/jar containing this property
 * @return newly constructed group node
 */
public static MetadataNonPropertySuggestionNode newInstance(String originalName,
    @Nullable MetadataNonPropertySuggestionNode parent, String belongsTo) {
  MetadataNonPropertySuggestionNodeBuilder builder =
      MetadataNonPropertySuggestionNode.builder().name(SuggestionNode.sanitise(originalName))
          .originalName(originalName).parent(parent);
  Set<String> belongsToSet = new THashSet<>();
  belongsToSet.add(belongsTo);
  builder.belongsTo(belongsToSet);
  return builder.build();
}
 
public synchronized Set<String> read(@NotNull DataInput in) throws IOException {
    THashSet set = new THashSet();

    for(int r = in.readInt(); r > 0; --r) {
        set.add(EnumeratorStringDescriptor.INSTANCE.read(in));
    }

    return set;
}
 
@Nonnull
@RequiredReadAction
public static Set<DotNetVirtualImplementOwner> getAllElements(PsiElement element)
{
	Collection<DotNetVirtualImplementOwner> temp1 = OverrideUtil.collectOverridingMembers((DotNetVirtualImplementOwner) element);
	Collection<DotNetVirtualImplementOwner> temp2 = OverrideUtil.collectOverridenMembers((DotNetVirtualImplementOwner) element);
	Set<DotNetVirtualImplementOwner> set = new THashSet<DotNetVirtualImplementOwner>(temp1.size() + temp1.size());
	set.addAll(temp1);
	set.addAll(temp2);
	return set;
}
 
@NotNull
@Override
public Set<Language> getLanguages() {

    if (languages == null) {
        languages = new THashSet<>(Arrays.asList(FluidLanguage.INSTANCE, myTemplateDataLanguage));
    }

    return languages;
}
 
源代码27 项目: consulo   文件: CommandMerger.java
private void reset() {
  myCurrentActions = new ArrayList<>();
  myAllAffectedDocuments = new THashSet<>();
  myAdditionalAffectedDocuments = new THashSet<>();
  myLastGroupId = null;
  myForcedGlobal = false;
  myTransparent = false;
  myCommandName = null;
  myValid = true;
  myStateAfter = null;
  myStateBefore = null;
  myUndoConfirmationPolicy = UndoConfirmationPolicy.DEFAULT;
}
 
源代码28 项目: consulo   文件: InspectionProfileWrapper.java
public static void checkInspectionsDuplicates(@Nonnull InspectionToolWrapper[] toolWrappers) {
  if (alreadyChecked) return;
  alreadyChecked = true;
  Set<InspectionProfileEntry> uniqTools = new THashSet<InspectionProfileEntry>(toolWrappers.length);
  for (InspectionToolWrapper toolWrapper : toolWrappers) {
    ProgressManager.checkCanceled();
    if (!uniqTools.add(toolWrapper.getTool())) {
      LOG.error("Inspection " + toolWrapper.getDisplayName() + " (" + toolWrapper.getTool().getClass() + ") already registered");
    }
  }
}
 
源代码29 项目: consulo   文件: VcsDirtyScopeImpl.java
@Override
public Set<FilePath> getDirtyFilesNoExpand() {
  final THashSet<FilePath> paths = newFilePathsSet();
  for (THashSet<FilePath> filePaths : myDirtyFiles.values()) {
    paths.addAll(filePaths);
  }
  return paths;
}
 
源代码30 项目: consulo   文件: ProjectOrderEnumerator.java
@Override
public void forEach(@Nonnull final Processor<OrderEntry> processor) {
  myRecursively = false;
  myWithoutDepModules = true;
  final THashSet<Module> processed = new THashSet<Module>();
  processRootModules(new Processor<Module>() {
    @Override
    public boolean process(Module module) {
      processEntries(getRootModel(module), processor, processed, true);
      return true;
    }
  });
}