public static Couple<Integer> duplicateLineOrSelectedBlockAtCaret(Editor editor, final Document document, @NotNull Caret caret, final boolean moveCaret) { if (caret.hasSelection()) { int start = caret.getSelectionStart(); int end = caret.getSelectionEnd(); String s = document.getCharsSequence().subSequence(start, end).toString(); document.insertString(end, s); if (moveCaret) { // select newly copied lines and move there caret.moveToOffset(end + s.length()); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); caret.removeSelection(); caret.setSelection(end, end + s.length()); } return Couple.of(end, end + s.length()); } else { return duplicateLinesRange(editor, document, caret, caret.getOffset(), caret.getVisualPosition(), caret.getVisualPosition(), moveCaret); } }
private static void collectDescriptorsRecursively(@NotNull ASTNode node, @NotNull Document document, @NotNull List<FoldingDescriptor> descriptors) { final IElementType type = node.getElementType(); if (type == token(COMMENT) && spanMultipleLines(node, document)) { descriptors.add(new FoldingDescriptor(node, node.getTextRange())); } if (type == token(LINE_COMMENT)) { final Couple<PsiElement> commentRange = expandLineCommentsRange(node.getPsi()); final int startOffset = commentRange.getFirst().getTextRange().getStartOffset(); final int endOffset = commentRange.getSecond().getTextRange().getEndOffset(); if (document.getLineNumber(startOffset) != document.getLineNumber(endOffset)) { descriptors.add(new FoldingDescriptor(node, new TextRange(startOffset, endOffset))); } } if (PROVIDERS.keySet().contains(type) && spanMultipleLines(node, document)) { descriptors.add(new FoldingDescriptor(node, node.getTextRange())); } for (ASTNode child : node.getChildren(null)) { collectDescriptorsRecursively(child, document, descriptors); } }
public Couple<List<String>> collectExtensions(GlobalSearchScope resolveScope) { PsiPackage aPackage = JavaPsiFacade.getInstance(myProject).findPackage("META-INF.services"); if (aPackage == null) { return Couple.of(Collections.<String>emptyList(), Collections.<String>emptyList()); } List<String> instanceClasses = new ArrayList<String>(); List<String> staticClasses = new ArrayList<String>(); for (PsiDirectory directory : aPackage.getDirectories(resolveScope)) { PsiFile file = directory.findFile(ORG_CODEHAUS_GROOVY_RUNTIME_EXTENSION_MODULE); if (file instanceof PropertiesFile) { IProperty inst = ((PropertiesFile)file).findPropertyByKey("extensionClasses"); IProperty stat = ((PropertiesFile)file).findPropertyByKey("staticExtensionClasses"); if (inst != null) collectClasses(inst, instanceClasses); if (stat != null) collectClasses(stat, staticClasses); } } return Couple.of(instanceClasses, staticClasses); }
@Override public boolean process(final PsiClass psiClass) { final String inheritorName = psiClass.getName(); if (inheritorName == null) { myAnonymousInheritorsCount++; } else { final Couple<Integer> res = collectInheritorsInfo(psiClass, myCollector, myDisabledNames, myProcessedElements, myAllNotAnonymousInheritors); myAnonymousInheritorsCount += res.getSecond(); if (!psiClass.isInterface()) { myAllNotAnonymousInheritors.add(inheritorName); } } return true; }
@Nullable protected Couple<String> invokeAction(@NotNull final Project project, @NotNull PsiFile file, @NotNull PsiElement psiElement, @Nullable final String suggestedKey, @Nullable String suggestedValue, @Nullable final List<PropertiesFile> propertiesFiles) { final PsiLiteralExpression literalExpression = psiElement instanceof PsiLiteralExpression ? (PsiLiteralExpression)psiElement : null; final String propertyValue = suggestedValue == null ? "" : suggestedValue; final I18nizeQuickFixDialog dialog = new JavaI18nizeQuickFixDialog( project, file, literalExpression, propertyValue, createDefaultCustomization(suggestedKey, propertiesFiles), false, false ); return doAction(project, psiElement, dialog); }
public Collection<Couple<TemplateResource>> getTemplateCouples() { final LinkedHashMap<String, Couple<TemplateResource>> resources = new LinkedHashMap<String, Couple<TemplateResource>>(); for (TemplateResource resource : getAllTemplates()) { final String baseName = getTemplateBaseName(resource); TemplateResource eq = toEqualsName(baseName).equals(resource.getFileName()) ? resource : null; TemplateResource hc = toHashCodeName(baseName).equals(resource.getFileName()) ? resource : null; final Couple<TemplateResource> couple = resources.get(baseName); if (couple != null) { resources.put(baseName, Couple.of(couple.first != null ? couple.first : eq, couple.second != null ? couple.second : hc)); } else { resources.put(baseName, Couple.of(eq, hc)); } } return resources.values(); }
@Override @NotNull public String getInternalCanonicalText() { Set<String> stringKeys = getStringKeys(); List<Couple<PsiType>> otherEntries = getOtherEntries(); if (stringKeys.isEmpty()) { if (otherEntries.isEmpty()) return "[:]"; String name = getJavaClassName(); final PsiType[] params = getParameters(); return name + "<" + getInternalText(params[0]) + ", " + getInternalText(params[1]) + ">"; } List<String> components = new ArrayList<String>(); for (String s : stringKeys) { components.add("'" + s + "':" + getInternalCanonicalText(getTypeByStringKey(s))); } for (Couple<PsiType> entry : otherEntries) { components.add(getInternalCanonicalText(entry.first) + ":" + getInternalCanonicalText(entry.second)); } boolean tooMany = components.size() > 2; final List<String> theFirst = components.subList(0, Math.min(2, components.size())); return "[" + StringUtil.join(theFirst, ", ") + (tooMany ? ",..." : "") + "]"; }
private static void walk(File root, MultiMap<Couple<Integer>, String> dimToPath, File file) throws IOException { if (file.isDirectory()) { for (File child : file.listFiles()) { walk(root, dimToPath, child); } } else { if (IMAGE_EXTENSIONS.contains(FileUtilRt.getExtension(file.getName()))) { String relativePath = file.getAbsolutePath().substring(root.getAbsolutePath().length() + 1); Image image = loadImage(file); File target; int width = image.getWidth(null); int height = image.getHeight(null); if (height != width && (height > 100 || width > 100)) { target = new File("/Users/max/images/other", relativePath); } else { target = new File("/Users/max/images/icons", relativePath); dimToPath.putValue(new Couple<Integer>(width, height), relativePath); } FileUtil.copy(file, target); } } }
@NotNull private Map<String, String> parseSelectors() { final Map<String, String> result = ContainerUtil.newLinkedHashMap(); List<Couple<String>> attrList = parseSelector(); while (attrList != null) { for (Couple<String> attr : attrList) { if (getClassAttributeName().equals(attr.first)) { result.put(getClassAttributeName(), (StringUtil.notNullize(result.get(getClassAttributeName())) + " " + attr.second).trim()); } else if (HtmlUtil.ID_ATTRIBUTE_NAME.equals(attr.first)) { result.put(HtmlUtil.ID_ATTRIBUTE_NAME, (StringUtil.notNullize(result.get(HtmlUtil.ID_ATTRIBUTE_NAME)) + " " + attr.second).trim()); } else { result.put(attr.first, attr.second); } } attrList = parseSelector(); } return result; }
public TextRange process(PsiElement element, TextRange range) { if (!myPyCodeStyleSettings.SPACE_AFTER_NUMBER_SIGN) { return range; } myRange = range; final PsiDocumentManager manager = PsiDocumentManager.getInstance(myProject); final Document document = manager.getDocument(element.getContainingFile()); if (document != null) { manager.doPostponedOperationsAndUnblockDocument(document); try { // collect all comments element.accept(this); for (Couple<PsiComment> pair : myCommentReplacements) { pair.getFirst().replace(pair.getSecond()); } } finally { manager.commitDocument(document); } } return TextRange.create(range.getStartOffset(), range.getEndOffset() + myDelta); }
/** * Returns comments preceding given elements as pair of the first and the last such comments. Comments should not be * separated by any empty line. * @param element element comments should be adjacent to * @return described range or {@code null} if there are no such comments */ @Nullable public static Couple<PsiComment> getPrecedingComments(@NotNull PsiElement element) { PsiComment firstComment = null, lastComment = null; overComments: while (true) { int newLinesCount = 0; for (element = element.getPrevSibling(); element instanceof PsiWhiteSpace; element = element.getPrevSibling()) { newLinesCount += StringUtil.getLineBreakCount(element.getText()); if (newLinesCount > 1) { break overComments; } } if (element instanceof PsiComment) { if (lastComment == null) { lastComment = (PsiComment)element; } firstComment = (PsiComment)element; } else { break; } } return lastComment == null ? null : Couple.of(firstComment, lastComment); }
@NotNull private Couple<Integer> computeHash(SingleChildDescriptor childDescriptor, PsiFragment parentFragment, NodeSpecificHasher nodeSpecificHasher) { final PsiElement element = childDescriptor.getElement(); if (element == null) { return Couple.of(0, 0); } final Couple<Integer> result = doComputeHash(childDescriptor, parentFragment, nodeSpecificHasher); final DuplicatesProfileBase duplicatesProfile = ((NodeSpecificHasherBase)nodeSpecificHasher).getDuplicatesProfile(); final PsiElementRole role = duplicatesProfile.getRole(element); if (role != null && !duplicatesProfile.getDuplocatorState(duplicatesProfile.getLanguage(element)).distinguishRole(role)) { return Couple.of(0, result.second); } return result; }
@Override protected Couple<String> doAction(Project project, PsiElement psiElement, I18nizeQuickFixModel model) { final Couple<String> result = super.doAction(project, psiElement, model); if (result != null && psiElement instanceof PsiLiteralExpression) { final String key = result.first; final StringBuilder buffer = new StringBuilder(); buffer.append('"'); StringUtil.escapeStringCharacters(key.length(), key, buffer); buffer.append('"'); final AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(JavaCreatePropertyFix.class); try { final PsiExpression newKeyLiteral = JavaPsiFacade.getElementFactory(project).createExpressionFromText(buffer.toString(), null); psiElement.replace(newKeyLiteral); } catch (IncorrectOperationException e) { LOG.error(e); } finally { token.finish(); } } return result; }
public void readExternal(Element macro) { setName(macro.getAttributeValue(ATTRIBUTE_NAME)); List actions = macro.getChildren(); for (final Object o : actions) { Element action = (Element)o; if (ELEMENT_TYPING.equals(action.getName())) { Couple<List<Integer>> codes = parseKeyCodes(action.getAttributeValue(ATTRIBUTE_KEY_CODES)); String text = action.getText(); if (text == null || text.length() == 0) { text = action.getAttributeValue(ATTRIBUTE_TEXT); } text = text.replaceAll(" ", " "); if (!StringUtil.isEmpty(text)) { myActions.add(new TypedDescriptor(text, codes.getFirst(), codes.getSecond())); } } else if (ELEMENT_ACTION.equals(action.getName())) { myActions.add(new IdActionDescriptor(action.getAttributeValue(ATTRIBUTE_ID))); } else if (ELEMENT_SHORTCUT.equals(action.getName())) { myActions.add(new ShortcutActionDesciption(action.getAttributeValue(ATTRIBUTE_TEXT))); } } }
public void editMacro() { if (getSelectedRowCount() != 1) { return; } final int selectedRow = getSelectedRow(); final Couple<String> pair = myMacros.get(selectedRow); final String title = ApplicationBundle.message("title.edit.variable"); final String macroName = pair.getFirst(); final PathMacroEditor macroEditor = new PathMacroEditor(title, macroName, pair.getSecond(), new EditValidator()); if (macroEditor.showAndGet()) { myMacros.remove(selectedRow); myMacros.add(Couple.of(macroEditor.getName(), macroEditor.getValue())); Collections.sort(myMacros, MACRO_COMPARATOR); myTableModel.fireTableDataChanged(); } }
@Nullable private static Couple<PsiElement> getStatementsRange(final PsiElement element1, final PsiElement element2) { final PsiElement parent = PsiTreeUtil.findCommonParent(element1, element2); if (parent == null) { return null; } final PyElement statementList = PyPsiUtils.getStatementList(parent); if (statementList == null) { return null; } final PsiElement statement1 = PyPsiUtils.getParentRightBefore(element1, statementList); final PsiElement statement2 = PyPsiUtils.getParentRightBefore(element2, statementList); if (statement1 == null || statement2 == null){ return null; } // return elements if they are really first and last elements of statements if (element1 == PsiTreeUtil.getDeepestFirst(statement1) && element2 == PyPsiUtils.getPrevSignificantLeaf(PsiTreeUtil.getDeepestLast(statement2), !(element2 instanceof PsiComment))) { return Couple.of(statement1, statement2); } return null; }
public static Couple<ASTNode> findTopmostSiblingParents(ASTNode one, ASTNode two) { if (one == two) return Couple.of(null, null); LinkedList<ASTNode> oneParents = new LinkedList<ASTNode>(); LinkedList<ASTNode> twoParents = new LinkedList<ASTNode>(); while (one != null) { oneParents.add(one); one = one.getTreeParent(); } while (two != null) { twoParents.add(two); two = two.getTreeParent(); } do { one = oneParents.pollLast(); two = twoParents.pollLast(); } while (one == two && one != null); return Couple.of(one, two); }
@Override public int getSpacingForBlockAtOffset(FormattingModel model, int offset) { Couple<Block> blockWithParent = getBlockAtOffset(null, model.getRootBlock(), offset); if (blockWithParent != null) { Block parentBlock = blockWithParent.first; Block targetBlock = blockWithParent.second; if (parentBlock != null && targetBlock != null) { Block prevBlock = findPreviousSibling(parentBlock, targetBlock); if (prevBlock != null) { SpacingImpl spacing = (SpacingImpl)parentBlock.getSpacing(prevBlock, targetBlock); if (spacing != null) { int minSpaces = spacing.getMinSpaces(); if (minSpaces > 0) { return minSpaces; } } } } } return 0; }
public GrMapTypeFromNamedArgs(@NotNull JavaPsiFacade facade, @NotNull GlobalSearchScope scope, @NotNull GrNamedArgument[] namedArgs) { super(facade, scope); myStringEntries = ContainerUtil.newLinkedHashMap(); myOtherEntries = ContainerUtil.newArrayList(); for (GrNamedArgument namedArg : namedArgs) { final GrArgumentLabel label = namedArg.getLabel(); final GrExpression expression = namedArg.getExpression(); if (label == null || expression == null) { continue; } final String name = label.getName(); if (name != null) { myStringEntries.put(name, expression); } else if (label.getExpression() != null) { myOtherEntries.add(Couple.of(label.getExpression(), expression)); } } }
@NotNull @Override public Collection<? extends Couple<TextRange>> getCommentRangesToDelete(@NotNull CharSequence charSequence) { Matcher start = BLOCK_COMMENT_START.matcher(charSequence); Matcher end = BLOCK_COMMENT_END.matcher(charSequence); TextRange startRange = start.find() ? new TextRange(start.start(), start.end()) : null; TextRange endRange = end.find() ? new TextRange(end.start(), end.end()) : null; return Collections.singleton(new Couple<>(startRange, endRange)); }
private Couple<String> keyForChange(final Change change) { final FilePath beforePath = ChangesUtil.getBeforePath(change); final String beforeKey = beforePath == null ? null : beforePath.getIOFile().getAbsolutePath(); final FilePath afterPath = ChangesUtil.getAfterPath(change); final String afterKey = afterPath == null ? null : afterPath.getIOFile().getAbsolutePath(); return Couple.of(beforeKey, afterKey); }
@Override public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) { processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, this); if (lastParent == null) { // Parent element should not see our vars return true; } Couple<Set<String>> pair = buildMaps(); boolean conflict = pair == null; final Set<String> classesSet = conflict ? null : pair.getFirst(); final Set<String> variablesSet = conflict ? null : pair.getSecond(); final NameHint hint = processor.getHint(NameHint.KEY); if (hint != null && !conflict) { final ElementClassHint elementClassHint = processor.getHint(ElementClassHint.KEY); final String name = hint.getName(state); if ((elementClassHint == null || elementClassHint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) && classesSet.contains(name)) { return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place); } if ((elementClassHint == null || elementClassHint.shouldProcess(ElementClassHint.DeclarationKind.VARIABLE)) && variablesSet.contains(name)) { return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place); } } else { return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place); } return true; }
@NotNull protected Couple<String> splitPath(@NotNull String path) { int separator = path.indexOf("!/"); if (separator < 0) { throw new IllegalArgumentException("Path in JarFileSystem must contain a separator: " + path); } String localPath = path.substring(0, separator); String pathInJar = path.substring(separator + 2); return Couple.of(localPath, pathInJar); }
public static Object unbox(@Nullable Object value, EvaluationContextImpl context) throws EvaluateException { if (value == null) { throw new EvaluateException("java.lang.NullPointerException: cannot unbox null value"); } if (value instanceof ObjectReference) { final String valueTypeName = ((ObjectReference)value).type().name(); final Couple<String> pair = TYPES_TO_CONVERSION_METHOD_MAP.get(valueTypeName); if (pair != null) { return convertToPrimitive(context, (ObjectReference)value, pair.getFirst(), pair.getSecond()); } } return value; }
public GitFileRevision(@NotNull Project project, @Nullable VirtualFile root, @NotNull FilePath path, @NotNull GitRevisionNumber revision, @Nullable Couple<Couple<String>> authorAndCommitter, @Nullable String message, @Nullable String branch, @Nullable final Date authorTime, @NotNull Collection<String> parents) { myProject = project; myRoot = root; myPath = path; myRevision = revision; myAuthorAndCommitter = authorAndCommitter; myMessage = message; myBranch = branch; myAuthorTime = authorTime; myParents = parents; }
public static void iterateAffectedFiles(final UpdatedFiles updatedFiles, final Consumer<Couple<String>> callback) { final List<FileGroup> groups = updatedFiles.getTopLevelGroups(); for (FileGroup group : groups) { iterateGroup(group, callback); // for changed on server for (FileGroup childGroup : group.getChildren()) { iterateGroup(childGroup, callback); } } }
@Override protected DocumentationComponent initComponent(Couple<PsiElement> content, boolean requestFocus) { if (!content.getFirst().getManager().areElementsEquivalent(myDocumentationComponent.getElement(), content.getFirst())) { myDocumentationManager.fetchDocInfo(content.getFirst(), myDocumentationComponent); } return myDocumentationComponent; }
public void beforeCommandFinished() { if (myMarkers.isEmpty()) return; myState = State.APPLYING; final Document document = myEditor.getDocument(); final Runnable apply = new Runnable() { @Override public void run() { for (Couple<RangeMarker> couple : myMarkers) { final RangeMarker leader = couple.first; final RangeMarker support = couple.second; final String name = document.getText(new TextRange(leader.getStartOffset(), leader.getEndOffset())); document.replaceString(support.getStartOffset(), support.getEndOffset(), name); } } }; ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myEditor); if (lookup != null) { lookup.performGuardedChange(apply); } else { apply.run(); } } }); myState = State.TRACKING; }
@Nullable private static Couple<String> calcProposedValues(Map<VirtualFile, Couple<String>> rootsWithDefinedProps) { if (rootsWithDefinedProps.isEmpty()) { return null; } Iterator<Map.Entry<VirtualFile,Couple<String>>> iterator = rootsWithDefinedProps.entrySet().iterator(); Couple<String> firstValue = iterator.next().getValue(); while (iterator.hasNext()) { // nothing to propose if there are different values set in different repositories if (!firstValue.equals(iterator.next().getValue())) { return null; } } return firstValue; }
public KnownRepositoryLocations() { myMap = MultiMap.createSet(); myLocations = new HashMap<Couple<String>, Long>(); myLastRevision = new HashMap<Long, RevisionId>(); myFirstRevision = new HashMap<Long, RevisionId>(); myJustVcs = new HashMap<String, Long>(); myAuthors = new HashMap<String, Long>(); }
public static void main(String[] args) throws Exception { File root = new File("/Users/max/IDEA/out/classes/production/"); final MultiMap<Couple<Integer>, String> dimToPath = new MultiMap<Couple<Integer>, String>(); walk(root, dimToPath, root); ArrayList<Couple<Integer>> keys = new ArrayList<Couple<Integer>>(dimToPath.keySet()); Collections.sort(keys, new Comparator<Couple<Integer>>() { @Override public int compare(Couple<Integer> o1, Couple<Integer> o2) { int d0 = dimToPath.get(o2).size() - dimToPath.get(o1).size(); if (d0 != 0) return d0; int d1 = o1.first - o2.first; if (d1 != 0) { return d1; } return o1.second - o2.second; } }); int total = 0; for (Couple<Integer> key : keys) { Collection<String> paths = dimToPath.get(key); System.out.println("------------------------ " + key.first + "x" + key.second + " (total " +paths.size() + " icons) --------------------------------"); for (String path : paths) { System.out.println(path); total ++; } System.out.println(""); } System.out.println("Total icons: " + total); }
public static Comparator<FrameworkSupportInModuleProvider> getFrameworkSupportProvidersComparator(final List<FrameworkSupportInModuleProvider> types) { DFSTBuilder<FrameworkSupportInModuleProvider> builder = new DFSTBuilder<FrameworkSupportInModuleProvider>(GraphGenerator.create(CachingSemiGraph.create(new ProvidersGraph(types)))); if (!builder.isAcyclic()) { Couple<FrameworkSupportInModuleProvider> pair = builder.getCircularDependency(); LOG.error("Circular dependency between types '" + pair.getFirst().getFrameworkType().getId() + "' and '" + pair.getSecond().getFrameworkType().getId() + "' was found."); } return builder.comparator(); }
@SuppressWarnings({"HardCodedStringLiteral"}) private static Pair[] getOptions(@NonNls String... names) { final List<Pair> options = new ArrayList<Pair>(); options.add(Couple.of("name", names[0])); appendIfNonEmpty(options, "depends", names[1]); appendIfNonEmpty(options, "description", names[2]); appendIfNonEmpty(options, "unless", names[3]); if (names.length > 5) { appendIfNonEmpty(options, names[4], names[5]); } return options.toArray(new Pair[options.size()]); }
@NotNull @Override protected PsiType[] getAllValueTypes() { Set<PsiType> result = ContainerUtil.newHashSet(); for (GrExpression expression : myStringEntries.values()) { result.add(inferTypePreventingRecursion(expression)); } for (Couple<GrExpression> entry : myOtherEntries) { result.add(inferTypePreventingRecursion(entry.second)); } result.remove(null); return result.toArray(createArray(result.size())); }
private static GridLayoutManager createTwoDimensionGrid(final RadComponent[] selection){ final int[] x = new int[selection.length]; final int[] y = new int[selection.length]; final int[] colSpans = new int[selection.length]; final int[] rowSpans = new int[selection.length]; for (int i = selection.length - 1; i >= 0; i--) { x[i] = selection[i].getX(); y[i] = selection[i].getY(); rowSpans[i] = selection[i].getHeight(); colSpans[i] = selection[i].getWidth(); } final Couple<Integer> pair = layoutInGrid(x, y, rowSpans, colSpans); for (int i = 0; i < selection.length; i++) { final RadComponent component = selection[i]; final GridConstraints constraints = component.getConstraints(); constraints.setRow(y[i]); constraints.setRowSpan(rowSpans[i]); constraints.setColumn(x[i]); constraints.setColSpan(colSpans[i]); } return new GridLayoutManager(pair.first.intValue(), pair.second.intValue()); }
/** * Splits the url into 2 parts: the scheme ("http", for instance) and the rest of the URL. <br/> * Scheme separator is not included neither to the scheme part, nor to the url part. <br/> * The scheme can be absent, in which case empty string is written to the first item of the Pair. */ @NotNull public static Couple<String> splitScheme(@NotNull String url) { ArrayList<String> list = Lists.newArrayList(Splitter.on(URLUtil.SCHEME_SEPARATOR).limit(2).split(url)); if (list.size() == 1) { return Couple.of("", list.get(0)); } return Couple.of(list.get(0), list.get(1)); }
/** * @param x array of <code>X</code> coordinates of components that should be layed out in a grid. * This is input/output parameter. * * @param y array of <code>Y</code> coordinates of components that should be layed out in a grid. * This is input/output parameter. * * @param rowSpans output parameter. * * @param colSpans output parameter. * * @return pair that says how many (rows, columns) are in the composed grid. */ public static Couple<Integer> layoutInGrid( final int[] x, final int[] y, final int[] rowSpans, final int[] colSpans ){ LOG.assertTrue(x.length == y.length); LOG.assertTrue(y.length == colSpans.length); LOG.assertTrue(colSpans.length == rowSpans.length); for (int i = 0; i < x.length; i++) { colSpans[i] = Math.max(colSpans[i], 1); rowSpans[i] = Math.max(rowSpans[i], 1); if (colSpans[i] > GRID_TREMOR * 4) { colSpans[i] -= GRID_TREMOR * 2; x[i] += GRID_TREMOR; } if (rowSpans[i] > GRID_TREMOR * 4) { rowSpans[i] -= GRID_TREMOR * 2; y[i] += GRID_TREMOR; } } return Couple.of( new Integer(Util.eliminate(y, rowSpans, null)), new Integer(Util.eliminate(x, colSpans, null)) ); }
@Override public void generate(PrintWriter out) throws IOException { boolean isFirst = true; for (final Couple<String> pair : myProperties) { if (!isFirst) { crlf(out); } else { isFirst = false; } out.print(StringUtil.escapeProperty(pair.getFirst(), true)); out.print("="); out.print(StringUtil.escapeProperty(pair.getSecond(), false)); } }
public void run() { preparation(); for (Change change : myInChanges) { final Couple<String> key = keyForChange(change); processInChange(key, change); } }
@Deprecated AnnotationFieldGutter(FileAnnotation annotation, Editor editor, LineAnnotationAspect aspect, final TextAnnotationPresentation presentation, Couple<Map<VcsRevisionNumber, Color>> colorScheme) { this(annotation, aspect, presentation, colorScheme); }