本文整理汇总了Java中com.intellij.openapi.util.Couple.getFirst方法的典型用法代码示例。如果您正苦于以下问题:Java Couple.getFirst方法的具体用法?Java Couple.getFirst怎么用?Java Couple.getFirst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.util.Couple
的用法示例。
在下文中一共展示了Couple.getFirst方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: editMacro
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
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();
}
}
示例2: unparseKeyCodes
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
public static String unparseKeyCodes(Couple<List<Integer>> pairs) {
StringBuilder result = new StringBuilder();
List<Integer> codes = pairs.getFirst();
List<Integer> modifiers = pairs.getSecond();
for (int i = 0; i < codes.size(); i++) {
Integer each = codes.get(i);
result.append(each.toString());
result.append(MODIFIER_DELIMITER);
result.append(modifiers.get(i));
if (i < codes.size() - 1) {
result.append(CODE_DELIMITER);
}
}
return result.toString();
}
示例3: replaceRelativeImportSourceWithQualifiedExpression
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
/**
* Replace import source with leading dots (if any) with reference expression created from given qualified name.
* Basically it does the same thing as {@link #replaceWithQualifiedExpression}, but also removes leading dots.
*
* @param importStatement import statement to update
* @param qualifiedName qualified name of new import source
* @return updated import statement
* @see #replaceWithQualifiedExpression(com.intellij.psi.PsiElement, com.intellij.psi.util.QualifiedName)
*/
@NotNull
private static PsiElement replaceRelativeImportSourceWithQualifiedExpression(@NotNull PyFromImportStatement importStatement,
@Nullable QualifiedName qualifiedName) {
final Couple<PsiElement> range = getRelativeImportSourceRange(importStatement);
if (range != null && qualifiedName != null) {
if (range.getFirst() == range.getSecond()) {
replaceWithQualifiedExpression(range.getFirst(), qualifiedName);
}
else {
importStatement.deleteChildRange(range.getFirst().getNextSibling(), range.getSecond());
replaceWithQualifiedExpression(range.getFirst(), qualifiedName);
}
}
return importStatement;
}
示例4: processDeclarations
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
@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;
}
示例5: getValueAt
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
public Object getValueAt(int rowIndex, int columnIndex) {
final Couple<String> pair = myMacros.get(rowIndex);
switch (columnIndex) {
case NAME_COLUMN: return pair.getFirst();
case VALUE_COLUMN: return pair.getSecond();
}
LOG.error("Wrong indices");
return null;
}
示例6: ensureLastX
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
public void ensureLastX(final int x) {
if (myPoints.isEmpty() || myPoints.get(myPoints.size() - 1).getFirst() < x) {
if (myPoints.isEmpty()) {
myPoints.add(Couple.of(0, 0));
myPoints.addAll(generateLine(0,0,x,0,myYDiff,0));
} else {
final Couple<Integer> lastPoint = myPoints.get(myPoints.size() - 1);
int finalX = (x - lastPoint.getFirst()) < 5 ? x + 10 : x;
myPoints.addAll(generateLine(lastPoint.getFirst(),lastPoint.getSecond(),finalX,0,myYDiff,lastPoint.getSecond()));
}
//myPoints.set(myPoints.size() - 1, new Pair<Integer, Integer>(x, 0));
}
}
示例7: getDescriptor
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
/**
* @return resolved string descriptor. If user chose nothing then the
* method returns <code>null</code>.
*/
@Nullable StringDescriptor getDescriptor() {
final int selectedRow = myTable.getSelectedRow();
if(selectedRow < 0 || selectedRow >= myTable.getRowCount()){
return null;
}
else{
final Couple<String> pair = myPairs.get(selectedRow);
final StringDescriptor descriptor = new StringDescriptor(myBundleName, pair.getFirst());
descriptor.setResolvedValue(pair.getSecond());
return descriptor;
}
}
示例8: makeKey
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
/**
* Makes the password database key for the URL: inserts the login after the scheme: http://[email protected]
*/
@NotNull
private static String makeKey(@NotNull String url, @Nullable String login) {
if (login == null) {
return url;
}
Couple<String> pair = UriUtil.splitScheme(url);
String scheme = pair.getFirst();
if (!StringUtil.isEmpty(scheme)) {
return scheme + URLUtil.SCHEME_SEPARATOR + login + "@" + pair.getSecond();
}
return login + "@" + url;
}
示例9: doDeleteRemote
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
private boolean doDeleteRemote(@NotNull String branchName, @NotNull Collection<GitRepository> repositories) {
Couple<String> pair = splitNameOfRemoteBranch(branchName);
String remoteName = pair.getFirst();
String branch = pair.getSecond();
GitCompoundResult result = new GitCompoundResult(myProject);
for (GitRepository repository : repositories) {
GitCommandResult res;
GitRemote remote = getRemoteByName(repository, remoteName);
if (remote == null) {
String error = "Couldn't find remote by name: " + remoteName;
LOG.error(error);
res = GitCommandResult.error(error);
}
else {
res = pushDeletion(repository, remote, branch);
if (!res.success() && isAlreadyDeletedError(res.getErrorOutputAsJoinedString())) {
res = myGit.remotePrune(repository, remote);
}
}
result.append(repository, res);
repository.update();
}
if (!result.totalSuccess()) {
VcsNotifier.getInstance(myProject).notifyError("Failed to delete remote branch " + branchName,
result.getErrorOutputWithReposIndication());
}
return result.totalSuccess();
}
示例10: HgRevisionNumber
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
public HgRevisionNumber(@NotNull String revision,
@NotNull String changeset,
@NotNull String authorInfo,
@NotNull String commitMessage,
@NotNull List<HgRevisionNumber> parents) {
this.commitMessage = commitMessage;
Couple<String> authorArgs = HgUtil.parseUserNameAndEmail(authorInfo);
this.author = authorArgs.getFirst();
this.email = authorArgs.getSecond();
this.parents = parents;
this.revision = revision.trim();
this.changeset = changeset.trim();
isWorkingVersion = changeset.endsWith("+");
mySubject = HgBaseLogParser.extractSubject(commitMessage);
}
示例11: search
import com.intellij.openapi.util.Couple; //导入方法依赖的package包/类
/**
* search for most used inheritors of superClass in scope
*
* @param aClass - class that excluded from inheritors of superClass
* @param minPercentRatio - head volume
* @return - search results in relevant ordering (frequency descent)
*/
public static List<InheritorsStatisticsSearchResult> search(final @NotNull PsiClass superClass,
final @NotNull PsiClass aClass,
final @NotNull GlobalSearchScope scope,
final int minPercentRatio) {
final String superClassName = superClass.getName();
final String aClassName = aClass.getName();
final Set<String> disabledNames = new HashSet<String>();
disabledNames.add(aClassName);
disabledNames.add(superClassName);
final Set<InheritorsCountData> collector = new TreeSet<InheritorsCountData>();
final Couple<Integer> collectingResult = collectInheritorsInfo(superClass, collector, disabledNames);
final int allAnonymousInheritors = collectingResult.getSecond();
final int allInheritors = collectingResult.getFirst() + allAnonymousInheritors - 1;
final List<InheritorsStatisticsSearchResult> result = new ArrayList<InheritorsStatisticsSearchResult>();
Integer firstPercent = null;
for (final InheritorsCountData data : collector) {
final int inheritorsCount = data.getInheritorsCount();
if (inheritorsCount < allAnonymousInheritors) {
break;
}
final int percent = (inheritorsCount * 100) / allInheritors;
if (percent < 1) {
break;
}
if (firstPercent == null) {
firstPercent = percent;
}
else if (percent * minPercentRatio < firstPercent) {
break;
}
final PsiClass psiClass = data.getPsiClass();
final VirtualFile file = psiClass.getContainingFile().getVirtualFile();
if (file != null && scope.contains(file)) {
result.add(new InheritorsStatisticsSearchResult(psiClass, percent));
}
}
return result;
}