com.intellij.util.containers.HashMap Java Examples
The following examples show how to use
com.intellij.util.containers.HashMap.
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 File: AbstractColorsScheme.java From consulo with Apache License 2.0 | 6 votes |
public void copyTo(AbstractColorsScheme newScheme) { myFontPreferences.copyTo(newScheme.myFontPreferences); newScheme.myLineSpacing = myLineSpacing; newScheme.myQuickDocFontSize = myQuickDocFontSize; myConsoleFontPreferences.copyTo(newScheme.myConsoleFontPreferences); newScheme.myConsoleLineSpacing = myConsoleLineSpacing; final Set<EditorFontType> types = myFonts.keySet(); for (EditorFontType type : types) { Font font = myFonts.get(type); newScheme.setFont(type, font); } newScheme.myAttributesMap = new HashMap<TextAttributesKey, TextAttributes>(myAttributesMap); newScheme.myColorsMap = new HashMap<ColorKey, Color>(myColorsMap); newScheme.myVersion = myVersion; }
Example #2
Source File: EntityAdapter.java From CleanArchitecturePlugin with Apache License 2.0 | 6 votes |
/** * Create EntityAdapter.class */ public static void create() { PsiDirectory adapterDirectory = createDirectory(getViewPackage(), ADAPTER.toLowerCase()); String className = getEntityConfig().getEntityName() + ADAPTER; HashMap<String, String> varTemplate = new HashMap<>(); varTemplate.put("PACKAGE_PROJECT", getPackageNameProject(getProjectDirectory())); varTemplate.put("LAYOUT_NAME", getEntityConfig().getEntityName().toLowerCase()); Runnable runnable = () -> { JavaDirectoryService.getInstance().createClass(adapterDirectory, className, ADAPTER_TEMPLATE, false, varTemplate); try { createLayout(getPackageNameProject(adapterDirectory), className, ADAPTER); } catch (Exception e) { e.printStackTrace(); } }; WriteCommandAction.runWriteCommandAction(getProject(), runnable); }
Example #3
Source File: GenericInlineHandler.java From consulo with Apache License 2.0 | 6 votes |
public static Map<Language, InlineHandler.Inliner> initializeInliners(PsiElement element, InlineHandler.Settings settings, Collection<? extends PsiReference> allReferences) { final Map<Language, InlineHandler.Inliner> inliners = new HashMap<Language, InlineHandler.Inliner>(); for (PsiReference ref : allReferences) { if (ref == null) { LOG.error("element: " + element.getClass()+ ", allReferences contains null!"); continue; } PsiElement refElement = ref.getElement(); LOG.assertTrue(refElement != null, ref.getClass().getName()); final Language language = refElement.getLanguage(); if (inliners.containsKey(language)) continue; final List<InlineHandler> handlers = InlineHandlers.getInlineHandlers(language); for (InlineHandler handler : handlers) { InlineHandler.Inliner inliner = handler.createInliner(element, settings); if (inliner != null) { inliners.put(language, inliner); break; } } } return inliners; }
Example #4
Source File: EntityPresenter.java From CleanArchitecturePlugin with Apache License 2.0 | 6 votes |
/** * Create EntityPresenter.class */ public static void create() { // Create presenter directory presenterDirectory = createDirectory(getViewPackage(), PRESENTER.toLowerCase()); // Create presenter class String className = getEntityConfig().getEntityName() + PRESENTER; HashMap<String, String> varTemplate = new HashMap<>(); varTemplate.put("PACKAGE_PRESENTER_IMPL", getPackageNameProject(Presenter.getPresenterDirectory())); varTemplate.put("PRESENTER_IMPL", PRESENTER_IMPL); Runnable runnable = () -> JavaDirectoryService.getInstance().createClass(presenterDirectory, className, PRESENTER_TEMPLATE, false, varTemplate); WriteCommandAction.runWriteCommandAction(getProject(), runnable); }
Example #5
Source File: UsedByMemberDependencyGraph.java From consulo with Apache License 2.0 | 6 votes |
@Override public Set<? extends T> getDependent() { if(myDependencies == null) { myDependencies = new HashSet<T>(); myDependenciesToDependent = new HashMap<T, HashSet<T>>(); for (T member : myMembers) { Set<T> dependent = myMemberDependenciesStorage.getMemberDependencies(member); if (dependent != null) { for (final T aDependent : dependent) { if (mySelectedNormal.contains(aDependent) && !mySelectedAbstract.contains(aDependent)) { myDependencies.add(member); HashSet<T> deps = myDependenciesToDependent.get(member); if (deps == null) { deps = new HashSet<T>(); myDependenciesToDependent.put(member, deps); } deps.add(aDependent); } } } } } return myDependencies; }
Example #6
Source File: PsiPackageBase.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull public PsiPackage[] getSubPackages(@Nonnull PsiPackage psiPackage, @Nonnull GlobalSearchScope scope) { final Map<String, PsiPackage> packagesMap = new HashMap<String, PsiPackage>(); final String qualifiedName = psiPackage.getQualifiedName(); for (PsiDirectory dir : psiPackage.getDirectories(scope)) { PsiDirectory[] subDirs = dir.getSubdirectories(); for (PsiDirectory subDir : subDirs) { final PsiPackage aPackage = myPackageManager.findPackage(subDir, myExtensionClass); if (aPackage != null) { final String subQualifiedName = aPackage.getQualifiedName(); if (subQualifiedName.startsWith(qualifiedName) && !packagesMap.containsKey(subQualifiedName)) { packagesMap.put(aPackage.getQualifiedName(), aPackage); } } } } packagesMap.remove(qualifiedName); // avoid SOE caused by returning a package as a subpackage of itself return ContainerUtil.toArray(packagesMap.values(), getPackageArrayFactory()); }
Example #7
Source File: DFSTBuilderTest.java From consulo with Apache License 2.0 | 6 votes |
public void testTNumberingSimple () { final TestNode nA = new TestNode("A"); final TestNode nB = new TestNode("B"); final TestNode nC = new TestNode("C"); final TestNode nD = new TestNode("D"); final TestNode[] allNodes = new TestNode[]{nA, nB, nC, nD}; final Map<TestNode, TestNode[]> map = new HashMap<TestNode, TestNode[]>(); map.put(nA, new TestNode[]{nC}); map.put(nB, new TestNode[]{nA}); map.put(nC, new TestNode[]{nB}); map.put(nD, new TestNode[]{nB}); GraphGenerator<TestNode> graph = graphByNodes(allNodes, map); final DFSTBuilder<TestNode> dfstBuilder = new DFSTBuilder<TestNode>(graph); assertTrue (!dfstBuilder.isAcyclic()); Comparator<TestNode> comparator = dfstBuilder.comparator(); assertTrue(comparator.compare(nA, nD) < 0); assertTrue(comparator.compare(nB, nD) < 0); assertTrue(comparator.compare(nC, nD) < 0); }
Example #8
Source File: CopyrightProfilesPanel.java From consulo with Apache License 2.0 | 6 votes |
public Map<String, CopyrightProfile> getAllProfiles() { final Map<String, CopyrightProfile> profiles = new HashMap<String, CopyrightProfile>(); if (!myInitialized.get()) { for (CopyrightProfile profile : myManager.getCopyrights()) { profiles.put(profile.getName(), profile); } } else { for (int i = 0; i < myRoot.getChildCount(); i++) { MyNode node = (MyNode)myRoot.getChildAt(i); final CopyrightProfile copyrightProfile = ((CopyrightConfigurable)node.getConfigurable()).getEditableObject(); profiles.put(copyrightProfile.getName(), copyrightProfile); } } return profiles; }
Example #9
Source File: RoutingRemoteFileStorage.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@Override public void build(@NotNull Project project, @NotNull Collection<FileObject> fileObjects) { Map<String, Route> routeMap = new HashMap<>(); for (FileObject file : fileObjects) { String content; try { content = StreamUtil.readText(file.getContent().getInputStream(), "UTF-8"); } catch (IOException e) { continue; } if(StringUtils.isBlank(content)) { continue; } routeMap.putAll(RouteHelper.getRoutesInsideUrlGeneratorFile( PhpPsiElementFactory.createPsiFileFromText(project, content) )); } this.routeMap = routeMap; }
Example #10
Source File: TemplateManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
public void startTemplateWithPrefix(final Editor editor, final TemplateImpl template, final int templateStart, @Nullable final PairProcessor<String, String> processor, @Nullable final String argument) { final int caretOffset = editor.getCaretModel().getOffset(); final TemplateState templateState = initTemplateState(editor); CommandProcessor commandProcessor = CommandProcessor.getInstance(); commandProcessor.executeCommand(myProject, () -> { editor.getDocument().deleteString(templateStart, caretOffset); editor.getCaretModel().moveToOffset(templateStart); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); editor.getSelectionModel().removeSelection(); Map<String, String> predefinedVarValues = null; if (argument != null) { predefinedVarValues = new HashMap<>(); predefinedVarValues.put(TemplateImpl.ARG, argument); } templateState.start(template, processor, predefinedVarValues); }, CodeInsightBundle.message("insert.code.template.command"), null); }
Example #11
Source File: AnnotateCurrentRevisionAction.java From consulo with Apache License 2.0 | 6 votes |
public AnnotateCurrentRevisionAction(@Nonnull FileAnnotation annotation, @Nonnull AbstractVcs vcs) { super("Annotate Revision", "Annotate selected revision in new tab", AllIcons.Actions.Annotate, annotation, vcs); List<VcsFileRevision> revisions = annotation.getRevisions(); if (revisions == null) { myRevisions = null; return; } Map<VcsRevisionNumber, VcsFileRevision> map = new HashMap<VcsRevisionNumber, VcsFileRevision>(); for (VcsFileRevision revision : revisions) { map.put(revision.getRevisionNumber(), revision); } myRevisions = new ArrayList<VcsFileRevision>(annotation.getLineCount()); for (int i = 0; i < annotation.getLineCount(); i++) { myRevisions.add(map.get(annotation.getLineRevisionNumber(i))); } }
Example #12
Source File: AnnotatePreviousRevisionAction.java From consulo with Apache License 2.0 | 6 votes |
public AnnotatePreviousRevisionAction(@Nonnull FileAnnotation annotation, @Nonnull AbstractVcs vcs) { super("Annotate Previous Revision", "Annotate successor of selected revision in new tab", AllIcons.Actions.Annotate, annotation, vcs); List<VcsFileRevision> revisions = annotation.getRevisions(); if (revisions == null) { myRevisions = null; return; } Map<VcsRevisionNumber, VcsFileRevision> map = new HashMap<VcsRevisionNumber, VcsFileRevision>(); for (int i = 0; i < revisions.size(); i++) { VcsFileRevision revision = revisions.get(i); VcsFileRevision previousRevision = i + 1 < revisions.size() ? revisions.get(i + 1) : null; map.put(revision.getRevisionNumber(), previousRevision); } myRevisions = new ArrayList<VcsFileRevision>(annotation.getLineCount()); for (int i = 0; i < annotation.getLineCount(); i++) { myRevisions.add(map.get(annotation.getLineRevisionNumber(i))); } }
Example #13
Source File: ExportToHTMLManager.java From consulo with Apache License 2.0 | 5 votes |
private static boolean exportPsiFile(final PsiFile psiFile, final String outputDirectoryName, final Project project, final HashMap<PsiFile, PsiFile> filesMap) { try { return ApplicationManager.getApplication().runReadAction(new ThrowableComputable<Boolean, FileNotFoundException>() { @Override public Boolean compute() throws FileNotFoundException { ExportToHTMLSettings exportToHTMLSettings = ExportToHTMLSettings.getInstance(project); if (psiFile instanceof PsiBinaryFile) { return true; } TreeMap<Integer, PsiReference> refMap = null; for (PrintOption printOption : Extensions.getExtensions(PrintOption.EP_NAME)) { final TreeMap<Integer, PsiReference> map = printOption.collectReferences(psiFile, filesMap); if (map != null) { refMap = new TreeMap<Integer, PsiReference>(); refMap.putAll(map); } } String dirName = constructOutputDirectory(psiFile, outputDirectoryName); HTMLTextPainter textPainter = new HTMLTextPainter(psiFile, project, dirName, exportToHTMLSettings.PRINT_LINE_NUMBERS); textPainter.paint(refMap, psiFile.getFileType()); return true; } }); } catch (FileNotFoundException throwable) { myLastException = throwable; return true; } }
Example #14
Source File: SafeDeleteProcessor.java From consulo with Apache License 2.0 | 5 votes |
/** * @param usages * @return Map from elements to UsageHolders */ private static HashMap<PsiElement, UsageHolder> sortUsages(@Nonnull UsageInfo[] usages) { HashMap<PsiElement, UsageHolder> result = new HashMap<PsiElement, UsageHolder>(); for (final UsageInfo usage : usages) { if (usage instanceof SafeDeleteUsageInfo) { final PsiElement referencedElement = ((SafeDeleteUsageInfo)usage).getReferencedElement(); if (!result.containsKey(referencedElement)) { result.put(referencedElement, new UsageHolder(referencedElement, usages)); } } } return result; }
Example #15
Source File: AbstractExtractMethodDialog.java From consulo with Apache License 2.0 | 5 votes |
public static Map<String, AbstractVariableData> createVariableMap(final AbstractVariableData[] data) { final HashMap<String, AbstractVariableData> map = new HashMap<>(); for (AbstractVariableData variableData : data) { map.put(variableData.getOriginalName(), variableData); } return map; }
Example #16
Source File: UsesMemberDependencyGraph.java From consulo with Apache License 2.0 | 5 votes |
@Override public Set<? extends T> getDependent() { if (myDependencies == null) { myDependencies = new HashSet<T>(); myDependenciesToDependentMap = new HashMap<T, HashSet<T>>(); buildDeps(null, mySelectedNormal); } return myDependencies; }
Example #17
Source File: FileColorConfigurationEditDialog.java From consulo with Apache License 2.0 | 5 votes |
private JComponent createColorButtonsPanel(final FileColorConfiguration configuration) { final JPanel result = new JPanel(new BorderLayout()); result.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); final JPanel inner = new JPanel(); inner.setLayout(new BoxLayout(inner, BoxLayout.X_AXIS)); inner.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1), BorderFactory.createEmptyBorder(5, 5, 5, 5))); if (!UIUtil.isUnderDarcula()) { inner.setBackground(Color.WHITE); } result.add(inner, BorderLayout.CENTER); final ButtonGroup group = new ButtonGroup(); myColorToButtonMap = new HashMap<String, AbstractButton>(); final Collection<String> names = myManager.getColorNames(); for (final String name : names) { final ColorButton colorButton = new ColorButton(name, myManager.getColor(name)); group.add(colorButton); inner.add(colorButton); myColorToButtonMap.put(name, colorButton); inner.add(Box.createHorizontalStrut(5)); } final CustomColorButton customButton = new CustomColorButton(); group.add(customButton); inner.add(customButton); myColorToButtonMap.put(customButton.getText(), customButton); inner.add(Box.createHorizontalStrut(5)); if (configuration != null) { final AbstractButton button = myColorToButtonMap.get(configuration.getColorName()); if (button != null) { button.setSelected(true); } } return result; }
Example #18
Source File: TemplateManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
public Map<TemplateImpl, String> findMatchingTemplates(final PsiFile file, Editor editor, @Nullable Character shortcutChar, TemplateSettings templateSettings) { final Document document = editor.getDocument(); CharSequence text = document.getCharsSequence(); final int caretOffset = editor.getCaretModel().getOffset(); List<TemplateImpl> candidatesWithoutArgument = findMatchingTemplates(text, caretOffset, shortcutChar, templateSettings, false); int argumentOffset = passArgumentBack(text, caretOffset); String argument = null; if (argumentOffset >= 0) { argument = text.subSequence(argumentOffset, caretOffset).toString(); if (argumentOffset > 0 && text.charAt(argumentOffset - 1) == ' ') { if (argumentOffset - 2 >= 0 && Character.isJavaIdentifierPart(text.charAt(argumentOffset - 2))) { argumentOffset--; } } } List<TemplateImpl> candidatesWithArgument = findMatchingTemplates(text, argumentOffset, shortcutChar, templateSettings, true); if (candidatesWithArgument.isEmpty() && candidatesWithoutArgument.isEmpty()) { return null; } candidatesWithoutArgument = filterApplicableCandidates(file, caretOffset, candidatesWithoutArgument); candidatesWithArgument = filterApplicableCandidates(file, argumentOffset, candidatesWithArgument); Map<TemplateImpl, String> candidate2Argument = new HashMap<>(); addToMap(candidate2Argument, candidatesWithoutArgument, null); addToMap(candidate2Argument, candidatesWithArgument, argument); return candidate2Argument; }
Example #19
Source File: LookupItem.java From consulo with Apache License 2.0 | 5 votes |
public <T> void setAttribute(Key<T> key, T value){ if (value == null && myAttributes != null) { myAttributes.remove(key); return; } if (myAttributes == null){ myAttributes = new HashMap<Object, Object>(5); } myAttributes.put(key, value); }
Example #20
Source File: ExternalToolPass.java From consulo with Apache License 2.0 | 5 votes |
public ExternalToolPass(@Nonnull ExternalToolPassFactory externalToolPassFactory, @Nonnull PsiFile file, @Nonnull Editor editor, int startOffset, int endOffset) { super(file.getProject(), editor.getDocument(), false); myEditor = editor; myFile = file; myStartOffset = startOffset; myEndOffset = endOffset; myAnnotationHolder = new AnnotationHolderImpl(new AnnotationSession(file)); myAnnotator2DataMap = new HashMap<ExternalAnnotator, MyData>(); myExternalToolPassFactory = externalToolPassFactory; }
Example #21
Source File: HistoryEntry.java From consulo with Apache License 2.0 | 5 votes |
private HistoryEntry(@Nonnull VirtualFilePointer filePointer, @Nullable FileEditorProvider selectedProvider, @Nullable Disposable disposable) { myFilePointer = filePointer; mySelectedProvider = selectedProvider; myDisposable = disposable; myProvider2State = new HashMap<>(); }
Example #22
Source File: ModulesConfigurator.java From consulo with Apache License 2.0 | 5 votes |
public GraphGenerator<ModuleRootModel> createGraphGenerator() { final Map<Module, ModuleRootModel> models = new HashMap<>(); for (ModuleEditor moduleEditor : myModuleEditors) { models.put(moduleEditor.getModule(), moduleEditor.getRootModel()); } return ModuleCompilerUtil.createGraphGenerator(models); }
Example #23
Source File: HTMLExporter.java From consulo with Apache License 2.0 | 5 votes |
public HTMLExporter(String rootFolder, HTMLComposerImpl composer) { myRootFolder = rootFolder; myElementToFilenameMap = new HashMap<RefEntity, String>(); myFileCounter = 0; myComposer = composer; myGeneratedPages = new HashSet<RefEntity>(); myGeneratedReferences = new HashSet<RefEntity>(); }
Example #24
Source File: GlobalInspectionContextImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static Map<String, InspectionToolWrapper> getInspectionWrappersMap(@Nonnull List<Tools> tools) { Map<String, InspectionToolWrapper> name2Inspection = new HashMap<String, InspectionToolWrapper>(tools.size()); for (Tools tool : tools) { InspectionToolWrapper toolWrapper = tool.getTool(); name2Inspection.put(toolWrapper.getShortName(), toolWrapper); } return name2Inspection; }
Example #25
Source File: FileAnnotation.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private static PreviousFileRevisionProvider createDefaultPreviousFileRevisionProvider(@Nonnull FileAnnotation annotation) { List<VcsFileRevision> revisions = annotation.getRevisions(); if (revisions == null) return null; Map<VcsRevisionNumber, VcsFileRevision> map = new HashMap<>(); for (int i = 0; i < revisions.size(); i++) { VcsFileRevision revision = revisions.get(i); VcsFileRevision previousRevision = i + 1 < revisions.size() ? revisions.get(i + 1) : null; map.put(revision.getRevisionNumber(), previousRevision); } List<VcsFileRevision> lineToRevision = new ArrayList<>(annotation.getLineCount()); for (int i = 0; i < annotation.getLineCount(); i++) { lineToRevision.add(map.get(annotation.getLineRevisionNumber(i))); } VcsFileRevision lastRevision = ContainerUtil.getFirstItem(revisions); return new PreviousFileRevisionProvider() { @javax.annotation.Nullable @Override public VcsFileRevision getPreviousRevision(int lineNumber) { LOG.assertTrue(lineNumber >= 0 && lineNumber < lineToRevision.size()); return lineToRevision.get(lineNumber); } @javax.annotation.Nullable @Override public VcsFileRevision getLastRevision() { return lastRevision; } }; }
Example #26
Source File: ChangeUtil.java From consulo with Apache License 2.0 | 5 votes |
public static TreeElement decodeInformation(TreeElement element) { DebugUtil.startPsiModification(null); try { return decodeInformation(element, new HashMap<>()); } finally { DebugUtil.finishPsiModification(); } }
Example #27
Source File: ChangeUtil.java From consulo with Apache License 2.0 | 5 votes |
private static void encodeInformation(TreeElement element, ASTNode original) { DebugUtil.startPsiModification(null); try { encodeInformation(element, original, new HashMap<>()); } finally { DebugUtil.finishPsiModification(); } }
Example #28
Source File: Registry.java From consulo with Apache License 2.0 | 5 votes |
public void restoreDefaults() { Map<String, String> old = new HashMap<String, String>(); old.putAll(myUserProperties); for (String each : old.keySet()) { get(each).resetToDefault(); } }
Example #29
Source File: ApplicationStatisticsPersistence.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public Map<String, Set<UsageDescriptor>> getApplicationData(@Nonnull String groupDescriptor) { if (!myApplicationData.containsKey(groupDescriptor)) { myApplicationData.put(groupDescriptor, new HashMap<>()); } return myApplicationData.get(groupDescriptor); }
Example #30
Source File: ChoseProjectTypeStep.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@NotNull @Override public Collection<? extends ModelWizardStep> createDependentSteps() { List<ModelWizardStep> allSteps = Lists.newArrayList(); myModuleDescriptionToStepMap = new HashMap<>(); for (ModuleGalleryEntry moduleGalleryEntry : myModuleGalleryEntryList) { FlutterProjectStep step = ((FlutterGalleryEntry)moduleGalleryEntry).createFlutterStep(getModel()); allSteps.add(step); myModuleDescriptionToStepMap.put(moduleGalleryEntry, step); } return allSteps; }