本文整理汇总了Java中com.intellij.openapi.util.Couple.of方法的典型用法代码示例。如果您正苦于以下问题:Java Couple.of方法的具体用法?Java Couple.of怎么用?Java Couple.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.util.Couple
的用法示例。
在下文中一共展示了Couple.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collectInheritorsInfo
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
private static Couple<Integer> collectInheritorsInfo(final PsiClass aClass,
final Set<InheritorsCountData> collector,
final Set<String> disabledNames,
final Set<String> processedElements,
final Set<String> allNotAnonymousInheritors) {
final String className = aClass.getName();
if (!processedElements.add(className)) return Couple.of(0, 0);
final MyInheritorsInfoProcessor processor = new MyInheritorsInfoProcessor(collector, disabledNames, processedElements);
DirectClassInheritorsSearch.search(aClass).forEach(processor);
allNotAnonymousInheritors.addAll(processor.getAllNotAnonymousInheritors());
final int allInheritorsCount = processor.getAllNotAnonymousInheritors().size() + processor.getAnonymousInheritorsCount();
if (!aClass.isInterface() && allInheritorsCount != 0 && !disabledNames.contains(className)) {
collector.add(new InheritorsCountData(aClass, allInheritorsCount));
}
return Couple.of(allNotAnonymousInheritors.size(), processor.getAnonymousInheritorsCount());
}
示例2: splitIterable2Side
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
@NotNull
private static Couple<List<Range>> splitIterable2Side(@NotNull FairDiffIterable changes, int offset) {
final List<Range> ranges1 = new ArrayList<Range>();
final List<Range> ranges2 = new ArrayList<Range>();
for (Range ch : changes.iterateUnchanged()) {
if (ch.end2 <= offset) {
ranges1.add(new Range(ch.start1, ch.end1, ch.start2, ch.end2));
}
else if (ch.start2 >= offset) {
ranges2.add(new Range(ch.start1, ch.end1, ch.start2 - offset, ch.end2 - offset));
}
else {
int len2 = offset - ch.start2;
ranges1.add(new Range(ch.start1, ch.start1 + len2, ch.start2, offset));
ranges2.add(new Range(ch.start1 + len2, ch.end1, 0, ch.end2 - offset));
}
}
return Couple.of(ranges1, ranges2);
}
示例3: getStatementsRange
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
@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;
}
示例4: add
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
/**
* For the given VirtualFile constructs a FilePathImpl object without referring to the initial VirtualFile object
* and adds this FilePathImpl to the set of files for proper VcsDirtyScopeManager - to mark these files dirty
* when the set will be populated.
* @param file file which path is to be added.
* @param addToFiles If true, then add to dirty files even if it is a directory. Otherwise add to the proper set.
*/
private void add(VirtualFile file, boolean addToFiles) {
if (file == null) { return; }
final boolean isDirectory = file.isDirectory();
FilePath path = VcsUtil.getFilePath(file.getPath(), isDirectory);
final Collection<VcsDirtyScopeManager> managers = getManagers(file);
for (VcsDirtyScopeManager manager : managers) {
Couple<HashSet<FilePath>> filesAndDirs = map.get(manager);
if (filesAndDirs == null) {
filesAndDirs = Couple.of(new HashSet<FilePath>(), new HashSet<FilePath>());
map.put(manager, filesAndDirs);
}
if (addToFiles || !isDirectory) {
filesAndDirs.first.add(path);
} else {
filesAndDirs.second.add(path);
}
}
}
示例5: createKeysDescriptions
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
private static Pair[] createKeysDescriptions(String artifactName) {
return new Pair[]{
Couple.of("alias", BuildProperties.propertyRef(artifactBasedProperty(ARTIFACT_ALIAS_SIGN_PROPERTY, artifactName))),
Couple.of("keystore", BuildProperties.propertyRef(artifactBasedProperty(ARTIFACT_KEYSTORE_SIGN_PROPERTY, artifactName))),
Couple.of("storepass", BuildProperties.propertyRef(artifactBasedProperty(ARTIFACT_STOREPASS_SIGN_PROPERTY, artifactName))),
Couple.of("keypass", BuildProperties.propertyRef(artifactBasedProperty(ARTIFACTKEYPASS_SIGN_PROPERTY, artifactName)))};
}
示例6: duplicateLinesRange
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
@SuppressWarnings("WeakerAccess")
@Nullable
public static Couple<Integer> duplicateLinesRange(
Editor editor,
Document document,
@Nullable Caret caret,
int offset,
VisualPosition rangeStart,
VisualPosition rangeEnd,
boolean moveCaret
) {
Pair<LogicalPosition, LogicalPosition> lines = EditorUtil.calcSurroundingRange(editor, rangeStart, rangeEnd);
LogicalPosition lineStart = lines.first;
LogicalPosition nextLineStart = lines.second;
int start = editor.logicalPositionToOffset(lineStart);
int end = editor.logicalPositionToOffset(nextLineStart);
if (end <= start) {
return null;
}
String s = document.getCharsSequence().subSequence(start, end).toString();
final int lineToCheck = nextLineStart.line - 1;
int newOffset = end + offset - start;
if (lineToCheck == document.getLineCount() /* empty document */
|| lineStart.line == document.getLineCount() - 1 /* last line*/
|| document.getLineSeparatorLength(lineToCheck) == 0) {
s = "\n" + s;
newOffset++;
}
document.insertString(end, s);
if (moveCaret && caret != null) {
caret.moveToOffset(newOffset);
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
}
return Couple.of(end, end + s.length());
}
示例7: keyForChange
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
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);
}
示例8: getArtifactXmlNs
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
@Nullable
@Override
public Couple<String> getArtifactXmlNs(ArtifactType artifactType) {
if (artifactType instanceof JavaFxApplicationArtifactType) {
return Couple.of("xmlns:fx", "javafx:com.sun.javafx.tools.ant");
}
return null;
}
示例9: getBlockPrefixSuffixPair
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
@Nullable
public static Couple<String> getBlockPrefixSuffixPair(@NotNull PsiElement comment) {
final Commenter commenter = LanguageCommenters.INSTANCE.forLanguage(comment.getLanguage());
if (commenter != null) {
final String prefix = commenter.getBlockCommentPrefix();
final String suffix = commenter.getBlockCommentSuffix();
if (prefix != null || suffix != null) {
return Couple.of(StringUtil.notNullize(prefix), StringUtil.notNullize(suffix));
}
}
return null;
}
示例10: parseComparisonMessage
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
private static Couple<String> parseComparisonMessage(String message, final String regex) {
final Matcher matcher = Pattern.compile(regex, Pattern.DOTALL | Pattern.CASE_INSENSITIVE).matcher(message);
if (matcher.matches()) {
return Couple.of(matcher.group(1).replaceAll("\\\\n", "\n"), matcher.group(2).replaceAll("\\\\n", "\n"));
}
return null;
}
示例11: splitPath
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
@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);
}
示例12: layoutInGrid
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
/**
* @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))
);
}
示例13: parseUserNameAndEmail
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
@NotNull
public static Couple<String> parseUserNameAndEmail(@NotNull String authorString) {
//special characters should be retained for properly filtering by username. For Mercurial "a.b" username is not equal to "a b"
// Vasya Pupkin <[email protected]> -> Vasya Pupkin , [email protected]
int startEmailIndex = authorString.indexOf('<');
int startDomainIndex = authorString.indexOf('@');
int endEmailIndex = authorString.indexOf('>');
String userName;
String email;
if (0 < startEmailIndex && startEmailIndex < startDomainIndex && startDomainIndex < endEmailIndex) {
email = authorString.substring(startEmailIndex + 1, endEmailIndex);
userName = authorString.substring(0, startEmailIndex).trim();
}
// [email protected] || <[email protected]>
else if (!authorString.contains(" ") && startDomainIndex > 0) { //simple e-mail check. [email protected]
if (startEmailIndex >= 0 && startDomainIndex > startEmailIndex && startDomainIndex < endEmailIndex) {
// <[email protected]> --> vasya.pupkin, [email protected]
userName = authorString.substring(startEmailIndex + 1, startDomainIndex).trim();
email = authorString.substring(startEmailIndex + 1, endEmailIndex).trim();
} else {
// [email protected] --> vasya.pupkin, [email protected]
userName = authorString.substring(0, startDomainIndex).trim();
email = authorString;
}
}
else {
userName = authorString.trim();
email = "";
}
return Couple.of(userName, email);
}
示例14: getUsages
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
@NotNull
private static Couple<List<TextRange>> getUsages(@NotNull PsiElement target,
@NotNull PsiElement psiElement) {
List<TextRange> readRanges = new ArrayList<>();
List<TextRange> writeRanges = new ArrayList<>();
final ReadWriteAccessDetector detector = ReadWriteAccessDetector.findDetector(target);
final FindUsagesManager findUsagesManager = ((FindManagerImpl) FindManager.getInstance(
target.getProject())).getFindUsagesManager();
final FindUsagesHandler findUsagesHandler =
findUsagesManager.getFindUsagesHandler(target, true);
final LocalSearchScope scope = new LocalSearchScope(psiElement);
Collection<PsiReference> refs =
findUsagesHandler != null ? findUsagesHandler.findReferencesToHighlight(target,
scope) : ReferencesSearch.search(target, scope).findAll();
for (PsiReference psiReference : refs) {
if (psiReference == null) {
Log.error("Null reference returned, findUsagesHandler=" + findUsagesHandler
+ "; target=" + target + " of " + target.getClass());
continue;
}
List<TextRange> destination;
if (detector == null || detector.getReferenceAccess(target, psiReference)
== ReadWriteAccessDetector.Access.Read) {
destination = readRanges;
} else {
destination = writeRanges;
}
HighlightUsagesHandler.collectRangesToHighlight(psiReference, destination);
}
final TextRange declareRange =
HighlightUsagesHandler.getNameIdentifierRange(psiElement.getContainingFile(),
target);
if (declareRange != null) {
if (detector != null && detector.isDeclarationWriteAccess(target)) {
writeRanges.add(declareRange);
} else {
readRanges.add(declareRange);
}
}
return Couple.of(readRanges, writeRanges);
}
示例15: expandLineCommentsRange
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
@NotNull
private static Couple<PsiElement> expandLineCommentsRange(@NotNull PsiElement anchor) {
return Couple.of(findFurthestSiblingOfSameType(anchor, false), findFurthestSiblingOfSameType(anchor, true));
}