com.intellij.util.containers.hash.HashMap Java Examples
The following examples show how to use
com.intellij.util.containers.hash.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: ImageUtils.java From markdown-image-kit with MIT License | 6 votes |
/** * Gets data from clipboard. * * @return the data from clipboard map 中只有一对 kev-value */ @Nullable public static Map<DataFlavor, Object> getDataFromClipboard() { Map<DataFlavor, Object> data = new HashMap<>(1); Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); if (transferable != null) { // 如果剪切板的内容是文件 try { DataFlavor dataFlavor; if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { // List<File> dataFlavor = DataFlavor.javaFileListFlavor; } else if (transferable.isDataFlavorSupported(DataFlavor.imageFlavor)) { // Image dataFlavor = DataFlavor.imageFlavor; } else { return null; } Object object = transferable.getTransferData(dataFlavor); data.put(dataFlavor, object); } catch (IOException | UnsupportedFlavorException ignored) { // 如果 clipboard 没有文件, 不处理 } } return data; }
Example #2
Source File: PhpHighlightPackParametersUsagesHandler.java From idea-php-advanced-autocomplete with MIT License | 6 votes |
@NotNull private static HashMap<Integer, RelativeRange> getRelativeSpecificationRanges(HashMap<Integer, PhpPackFormatSpecificationParser.PackSpecification> specifications, List<StringLiteralExpression> targets) { Map<TextRange, StringLiteralExpression> rangesInsideResultingFormatString = getRangesWithExpressionInsideResultingFormatString(targets); HashMap<Integer, RelativeRange> result = new HashMap<>(); for (Map.Entry<Integer, PhpPackFormatSpecificationParser.PackSpecification> entry : specifications.entrySet()) { PhpPackFormatSpecificationParser.PackSpecification specification = entry.getValue(); for (Map.Entry<TextRange, StringLiteralExpression> e : rangesInsideResultingFormatString.entrySet()) { TextRange expressionRangeInsideFormatString = e.getKey(); TextRange specificationRangeInsideFormatString = expressionRangeInsideFormatString.intersection(specification.getRangeInElement()); if (specificationRangeInsideFormatString != null && !specificationRangeInsideFormatString.isEmpty()) { result.put(entry.getKey(), new RelativeRange(e.getValue(), specificationRangeInsideFormatString.shiftLeft(expressionRangeInsideFormatString.getStartOffset()))); } } } return result; }
Example #3
Source File: PhpHighlightPackParametersUsagesHandler.java From idea-php-advanced-autocomplete with MIT License | 6 votes |
private int resolveSpecificationIndexFromParameter(HashMap<Integer, PhpPackFormatSpecificationParser.PackSpecification> specifications) { int offset = 1; for (Map.Entry<Integer, PhpPackFormatSpecificationParser.PackSpecification> entry : specifications.entrySet()) { PhpPackFormatSpecificationParser.PackSpecification specification = entry.getValue(); for (int r = 0; r < specification.getRepeater(); r++) { int parameterIndex = offset + r >= 0 ? this.myFormatExpressionIndex + offset + r : offset + r; if (parameterIndex == this.mySelectedParameterIndex) { return entry.getKey(); } } offset += specification.getRepeater(); } return -1; }
Example #4
Source File: ChangeSignatureProcessorBase.java From consulo with Apache License 2.0 | 6 votes |
protected List<UsageInfo> filterUsages(List<UsageInfo> infos) { Map<PsiElement, MoveRenameUsageInfo> moveRenameInfos = new HashMap<PsiElement, MoveRenameUsageInfo>(); Set<PsiElement> usedElements = new HashSet<PsiElement>(); List<UsageInfo> result = new ArrayList<UsageInfo>(infos.size() / 2); for (UsageInfo info : infos) { LOG.assertTrue(info != null, getClass()); PsiElement element = info.getElement(); if (info instanceof MoveRenameUsageInfo) { if (usedElements.contains(element)) continue; moveRenameInfos.put(element, (MoveRenameUsageInfo)info); } else { moveRenameInfos.remove(element); usedElements.add(element); if (!(info instanceof PossiblyIncorrectUsage) || ((PossiblyIncorrectUsage)info).isCorrect()) { result.add(info); } } } result.addAll(moveRenameInfos.values()); return result; }
Example #5
Source File: PasteImageAction.java From markdown-image-kit with MIT License | 5 votes |
@Contract(pure = true) private Map<Document, List<MarkdownImage>> buildWaitingProcessMap(@NotNull Map.Entry<DataFlavor, Object> entry, Editor editor) { Map<Document, List<MarkdownImage>> waitingProcessMap = new HashMap<>(10); List<MarkdownImage> markdownImages = new ArrayList<>(10); for (Map.Entry<String, InputStream> inputStreamMap : resolveClipboardData(entry).entrySet()) { MarkdownImage markdownImage = new MarkdownImage(); markdownImage.setFileName(""); markdownImage.setImageName(inputStreamMap.getKey()); markdownImage.setExtension(""); markdownImage.setOriginalLineText(""); markdownImage.setLineNumber(0); markdownImage.setLineStartOffset(0); markdownImage.setLineEndOffset(0); markdownImage.setTitle(""); markdownImage.setPath(""); markdownImage.setLocation(ImageLocationEnum.LOCAL); markdownImage.setImageMarkType(ImageMarkEnum.ORIGINAL); markdownImage.setInputStream(inputStreamMap.getValue()); markdownImage.setFinalMark(""); markdownImages.add(markdownImage); } if(markdownImages.size() > 0){ waitingProcessMap.put(editor.getDocument(), markdownImages); } return waitingProcessMap; }
Example #6
Source File: PasteImageAction.java From markdown-image-kit with MIT License | 5 votes |
/** * 处理 clipboard 数据 * * @param entry the entry List<File> 或者 Image 类型 * @return the map 文件名-->File, File 有本地文件(resolveFromFile)和临时文件(resolveFromImage) */ private Map<String, InputStream> resolveClipboardData(@NotNull Map.Entry<DataFlavor, Object> entry) { Map<String, InputStream> imageMap = new HashMap<>(10); if (entry.getKey().equals(DataFlavor.javaFileListFlavor)) { resolveFromFile(entry, imageMap); } else { resolveFromImage(entry, imageMap); } return imageMap; }
Example #7
Source File: PhpHighlightPackParametersUsagesHandler.java From idea-php-advanced-autocomplete with MIT License | 5 votes |
@Override public void computeUsages(List<StringLiteralExpression> targets) { StringLiteralExpression formatExpression = ContainerUtil.getFirstItem(targets); if (formatExpression == null) { return; } String contents = PhpInterpolationStringRepresentationConverter.createExpressionContent(targets); HashMap<Integer, PhpPackFormatSpecificationParser.PackSpecification> specificationsWithIndices = PhpPackFormatSpecificationParser.parseFormat(contents, formatExpression.isSingleQuote() || PhpHeredocToStringIntention.isNowdoc(formatExpression), this.myParameters.length); HashMap<Integer, RelativeRange> relativeSpecificationRanges = getRelativeSpecificationRanges(specificationsWithIndices, targets); int specificationIndex = this.mySelectedParameterIndex == this.myFormatExpressionIndex ? resolveSpecificationIndexFromCaret(relativeSpecificationRanges) : resolveSpecificationIndexFromParameter(specificationsWithIndices); RelativeRange pair = relativeSpecificationRanges.get(specificationIndex); if (pair == null) { return; } this.myReadUsages.add(getRangeInsideDocument(pair.getContainingExpression(), pair.getRangeInsideExpression())); int offset = 1; for (Map.Entry<Integer, PhpPackFormatSpecificationParser.PackSpecification> entry : specificationsWithIndices.entrySet()) { PhpPackFormatSpecificationParser.PackSpecification specification = entry.getValue(); if (entry.getKey() == specificationIndex) { for (int r = 0; r < specification.getRepeater(); r++) { int parameterIndex = offset + r >= 0 ? this.myFormatExpressionIndex + offset + r : offset + r; if (parameterIndex >= 0 && parameterIndex < this.myParameters.length) { this.addOccurrence(this.myParameters[parameterIndex]); } } break; } offset += specification.getRepeater(); } }
Example #8
Source File: PhpHighlightPackParametersUsagesHandler.java From idea-php-advanced-autocomplete with MIT License | 5 votes |
private int resolveSpecificationIndexFromCaret(@NotNull HashMap<Integer, RelativeRange> specificationRelativeRanges) { int caretOffset = this.myEditor.getCaretModel().getOffset(); StringLiteralExpression selectedLiteralExpression = PhpPsiUtil.getParentByCondition(this.myFile.findElementAt(caretOffset), false, StringLiteralExpression.INSTANCEOF); return StreamEx.of(specificationRelativeRanges.entrySet()) .findFirst((e) -> specificationAtCaretOffsetExists(caretOffset, selectedLiteralExpression, e.getValue())) .map(Map.Entry::getKey).orElse(-1); }
Example #9
Source File: AbstractApplicationUsagesCollector.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public Set<UsageDescriptor> getApplicationUsages(@Nonnull final ApplicationStatisticsPersistence persistence) { final Map<String, Integer> result = new HashMap<String, Integer>(); for (Set<UsageDescriptor> usageDescriptors : persistence.getApplicationData(getGroupId()).values()) { for (UsageDescriptor usageDescriptor : usageDescriptors) { final String key = usageDescriptor.getKey(); final Integer count = result.get(key); result.put(key, count == null ? 1 : count.intValue() + 1); } } return ContainerUtil.map2Set(result.entrySet(), entry -> new UsageDescriptor(entry.getKey(), entry.getValue())); }
Example #10
Source File: VcsDiffUtil.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess public static void showDiffFor(@Nonnull Project project, @Nonnull final Collection<Change> changes, @Nonnull final String revNumTitle1, @Nonnull final String revNumTitle2, @Nonnull final FilePath filePath) { if (filePath.isDirectory()) { showChangesDialog(project, getDialogTitle(filePath, revNumTitle1, revNumTitle2), ContainerUtil.newArrayList(changes)); } else { if (changes.isEmpty()) { DiffManager.getInstance().showDiff(project, new MessageDiffRequest("No Changes Found")); } else { final HashMap<Key, Object> revTitlesMap = new HashMap<>(2); revTitlesMap.put(VCS_DIFF_LEFT_CONTENT_TITLE, revNumTitle1); revTitlesMap.put(VCS_DIFF_RIGHT_CONTENT_TITLE, revNumTitle2); ShowDiffContext showDiffContext = new ShowDiffContext() { @Nonnull @Override public Map<Key, Object> getChangeContext(@Nonnull Change change) { return revTitlesMap; } }; ShowDiffAction.showDiffForChange(project, changes, 0, showDiffContext); } } }
Example #11
Source File: OrganizationListWindow.java From tmc-intellij with MIT License | 4 votes |
public OrganizationCellRenderer(JBList parent) { this.parent = parent; this.cachedOrgs = new HashMap<>(); }
Example #12
Source File: PhpPackFormatSpecificationParser.java From idea-php-advanced-autocomplete with MIT License | 4 votes |
static HashMap<Integer, PackSpecification> parseFormat(@NotNull String expression, boolean singleQuote, int parametersCount) { int index = 0; int num = 0; HashMap<Integer, PackSpecification> result = new HashMap<>(); List<String> codesList = Arrays.asList(PhpCompletionTokens.packCodes); while (index < expression.length()) { char c = expression.charAt(index); // Cancel when we hit variables inside string if (!singleQuote && charAtEqualsToAny(expression, index, '$')) { return result; } if (!codesList.contains(Character.toString(c)) || charAtEqualsToAny(expression, index, 'x', 'X')) { ++index; continue; } int endIndex = index; int repeater = 1; TextRange width = parseUnsignedInt(expression, index+1); if (width != null && !charAtEqualsToAny(expression, index, 'a', 'A', 'h', 'H')) { endIndex = width.getEndOffset() - 1; repeater = Integer.parseUnsignedInt(width.substring(expression)); } boolean repeatToEnd = charAtEqualsToAny(expression, index + 1, '*'); if (repeatToEnd) { ++endIndex; repeater = parametersCount - num; } TextRange range = TextRange.create(index, endIndex + 1); result.put(num, new PackSpecification(range, repeater)); if (repeatToEnd) { return result; } ++num; ++index; } return result; }