本文整理匯總了Java中com.intellij.openapi.util.Pair.getSecond方法的典型用法代碼示例。如果您正苦於以下問題:Java Pair.getSecond方法的具體用法?Java Pair.getSecond怎麽用?Java Pair.getSecond使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.util.Pair
的用法示例。
在下文中一共展示了Pair.getSecond方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateCourseProgress
import com.intellij.openapi.util.Pair; //導入方法依賴的package包/類
public void updateCourseProgress(@NotNull final Project project) {
final Course course = StudyTaskManager.getInstance(project).getCourse();
if (course != null) {
List<Lesson> lessons = course.getLessons();
Pair<Integer, Integer> progress = countProgressAsOneTaskWithSubtasks(lessons);
if (progress == null) {
progress = countProgressWithoutSubtasks(lessons);
}
int taskSolved = progress.getFirst();
int taskNum = progress.getSecond();
String completedTasks = String.format("%d of %d tasks completed", taskSolved, taskNum);
double percent = (taskSolved * 100.0) / taskNum;
myStatisticLabel.setText(completedTasks);
myStudyProgressBar.setFraction(percent / 100);
}
}
示例2: doTest
import com.intellij.openapi.util.Pair; //導入方法依賴的package包/類
private void doTest(String name) {
VirtualFile file = configureByTaskFile(name + CCTestsUtil.BEFORE_POSTFIX);
CCShowPreview action = new CCShowPreview();
TestActionEvent e = getActionEvent(action,PsiManager.getInstance(getProject()).findFile(file));
action.beforeActionPerformedUpdate(e);
assertTrue(e.getPresentation().isEnabled() && e.getPresentation().isVisible());
action.actionPerformed(e);
Editor editor = EditorFactory.getInstance().getAllEditors()[1];
try {
Pair<Document, List<AnswerPlaceholder>> pair = getPlaceholders(name + CCTestsUtil.AFTER_POSTFIX);
assertEquals("Files don't match", pair.getFirst().getText(), editor.getDocument().getText());
for (AnswerPlaceholder placeholder : pair.getSecond()) {
assertNotNull("No highlighter for placeholder:" + CCTestsUtil.getPlaceholderPresentation(placeholder),
getHighlighter(editor.getMarkupModel(), placeholder));
}
}
finally {
EditorFactory.getInstance().releaseEditor(editor);
}
}
示例3: checkByFile
import com.intellij.openapi.util.Pair; //導入方法依賴的package包/類
public void checkByFile(TaskFile taskFile, String fileName, boolean useLength) {
Pair<Document, List<AnswerPlaceholder>> placeholders = getPlaceholders(fileName, useLength, true);
String message = "Placeholders don't match";
if (taskFile.getActivePlaceholders().size() != placeholders.second.size()) {
throw new ComparisonFailure(message,
CCTestsUtil.getPlaceholdersPresentation(taskFile.getActivePlaceholders()),
CCTestsUtil.getPlaceholdersPresentation(placeholders.second));
}
for (AnswerPlaceholder answerPlaceholder : placeholders.getSecond()) {
AnswerPlaceholder placeholder = taskFile.getAnswerPlaceholder(answerPlaceholder.getOffset());
if (!CCTestsUtil.comparePlaceholders(placeholder, answerPlaceholder)) {
throw new ComparisonFailure(message,
CCTestsUtil.getPlaceholdersPresentation(taskFile.getActivePlaceholders()),
CCTestsUtil.getPlaceholdersPresentation(placeholders.second));
}
}
}
示例4: addPendingEdge
import com.intellij.openapi.util.Pair; //導入方法依賴的package包/類
private void addPendingEdge(LuaPsiElement scopeWhenAdded, InstructionImpl instruction) {
if (instruction == null) {
return;
}
int i = 0;
if (scopeWhenAdded != null) {
for (; i < myPending.size(); i++) {
Pair<InstructionImpl, LuaPsiElement> pair = myPending.get(i);
final LuaPsiElement currScope = pair.getSecond();
if (currScope == null) {
continue;
}
if (!PsiTreeUtil.isAncestor(currScope, scopeWhenAdded, true)) {
break;
}
}
}
myPending.add(i, new Pair<InstructionImpl, LuaPsiElement>(instruction, scopeWhenAdded));
}
示例5: showConflicts
import com.intellij.openapi.util.Pair; //導入方法依賴的package包/類
/**
* Shows a panel with name redefinition conflicts, if needed.
* @param project
* @param conflicts what {@link #findDefinitions} would return
* @param obscured name or its topmost qualifier that is obscured, used at top of pane.
* @param name full name (maybe qualified) to show as obscured and display as qualifier in "would be" chunks.
* @return true iff conflicts is not empty and the panel is shown.
*/
public static boolean showConflicts(Project project, List<Pair<PsiElement, PsiElement>> conflicts, String obscured, @Nullable String name) {
if (conflicts.size() > 0) {
Usage[] usages = new Usage[conflicts.size()];
int i = 0;
for (Pair<PsiElement, PsiElement> pair : conflicts) {
usages[i] = new NameUsage(pair.getFirst(), pair.getSecond(), name != null? name : obscured, name != null);
i += 1;
}
UsageViewPresentation prsnt = new UsageViewPresentation();
prsnt.setTabText(PyBundle.message("CONFLICT.name.$0.obscured", obscured));
prsnt.setCodeUsagesString(PyBundle.message("CONFLICT.name.$0.obscured.cannot.convert", obscured));
prsnt.setUsagesWord(PyBundle.message("CONFLICT.occurrence.sing"));
prsnt.setUsagesString(PyBundle.message("CONFLICT.occurrence.pl"));
UsageViewManager.getInstance(project).showUsages(UsageTarget.EMPTY_ARRAY, usages, prsnt);
return true;
}
return false;
}
示例6: createUserFriendlyError
import com.intellij.openapi.util.Pair; //導入方法依賴的package包/類
@NotNull
public ExternalSystemException createUserFriendlyError(@NotNull String msg, @Nullable String location, @NotNull String... quickFixes) {
String newMsg = msg;
if (!newMsg.isEmpty() && Character.isLowerCase(newMsg.charAt(0))) {
// Message starts with lower case letter. Sentences should start with uppercase.
newMsg = "Cause: " + newMsg;
}
if (!StringUtil.isEmpty(location)) {
Pair<String, Integer> pair = getErrorLocation(location);
if (pair != null) {
return new LocationAwareExternalSystemException(newMsg, pair.first, pair.getSecond(), quickFixes);
}
}
return new ExternalSystemException(newMsg, null, quickFixes);
}
示例7: compare
import com.intellij.openapi.util.Pair; //導入方法依賴的package包/類
@Override
public int compare(Pair<?, Integer> o1, Pair<?, Integer> o2) {
int i = o2.getSecond() - o1.getSecond();
if (i != 0) {
return i;
}
int h1 = o1.hashCode();
int h2 = o2.hashCode();
if (h1 > h2) {
return 1;
}
if (h1 < h2) {
return -1;
}
return 0;
}
示例8: runSmartTestProcess
import com.intellij.openapi.util.Pair; //導入方法依賴的package包/類
static void runSmartTestProcess(@NotNull final VirtualFile taskDir,
@NotNull final PyStudyTestRunner testRunner,
@NotNull final String taskFileName,
@NotNull final TaskFile taskFile,
@NotNull final Project project) {
final VirtualFile virtualFile = taskDir.findFileByRelativePath(taskFileName);
if (virtualFile == null) {
return;
}
Pair<VirtualFile, TaskFile> pair = getCopyWithAnswers(taskDir, virtualFile, taskFile);
if (pair == null) {
return;
}
VirtualFile answerFile = pair.getFirst();
TaskFile answerTaskFile = pair.getSecond();
try {
for (final AnswerPlaceholder answerPlaceholder : answerTaskFile.getActivePlaceholders()) {
final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
if (document == null) {
continue;
}
smartCheck(answerPlaceholder, project, answerFile, answerTaskFile, taskFile, testRunner,
virtualFile, document);
}
}
finally {
StudyUtils.deleteFile(answerFile);
}
}
示例9: getOptimizedNodeOldOffset
import com.intellij.openapi.util.Pair; //導入方法依賴的package包/類
private int getOptimizedNodeOldOffset(ASTNode child, ChangeInfo changeInfo) {
// we usually add / remove ranges so old offset can be tried to calculate from change with previous sibling
ASTNode prevSibling = child.getTreePrev();
if (prevSibling != null) {
if (mySortedChanges.size() > 0) {
Pair<ASTNode, Integer> pair = mySortedChanges.get(mySortedChanges.size() - 1);
if (pair.getFirst() == prevSibling) {
ChangeInfo prevSiblingChange = myChanges.get(prevSibling);
if ((prevSiblingChange.getChangeType() == ChangeInfo.REMOVED &&
changeInfo.getChangeType() == ChangeInfo.REMOVED
) ||
(prevSiblingChange.getChangeType() == ChangeInfo.ADD &&
changeInfo.getChangeType() == ChangeInfo.ADD
)
) {
int optimizedResult = pair.getSecond() + prevSiblingChange.getOldLength();
if (ourDoChecks && !ourReportedDifferentOptimizedNodeOldOffset) {
int oldOffset = calculateOldOffsetLinearly(child);
if (optimizedResult != oldOffset) {
LOG.error("Failed optimized node old offset check:"+changeInfo + ", previous:" + prevSibling + "," + prevSiblingChange);
ourReportedDifferentOptimizedNodeOldOffset = true;
optimizedResult = oldOffset;
}
}
return optimizedResult;
}
}
}
}
return haveNotCalculated;
}
示例10: setupControl
import com.intellij.openapi.util.Pair; //導入方法依賴的package包/類
private void setupControl(JTable table, Object value, boolean isSelected, boolean hasFocus) {
myPanel.setBorder(getCellBorder(table, isSelected && hasFocus));
Color foreground;
Color background;
if (isSelected) {
background = table.getSelectionBackground();
foreground = table.getSelectionForeground();
}
else {
background = table.getBackground();
foreground = table.getForeground();
}
myPanel.setBackground(background);
myCheckBox.setForeground(foreground);
myPanel.remove(myCheckBox);
//noinspection unchecked
Pair<ComponentTreeNode, Integer> pair = (Pair<ComponentTreeNode, Integer>)value;
int indent = 0;
if (pair != null) {
ComponentTreeNode node = pair.getFirst();
myCheckBox.setEnabled(isOptional(node));
myCheckBox.setText(node.getLabel());
myCheckBox.setSelected(node.isChecked());
indent = pair.getSecond();
}
myPanel.add(myCheckBox,
new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, indent * 2));
}
示例11: getThisClassesToMembers
import com.intellij.openapi.util.Pair; //導入方法依賴的package包/類
private static void getThisClassesToMembers(final PsiElement scope, final Map<PsiClass, Set<PsiMember>> map, final PsiMember refMember) {
if (scope instanceof PsiExpression) {
final PsiExpression expression = (PsiExpression)scope;
if (!(scope instanceof PsiReferenceExpression) || !((PsiReferenceExpression)scope).isReferenceTo(refMember)) {
final Pair<PsiMember, PsiClass> pair = getMemberAndClassReferencedByThis(expression);
if (pair != null) {
PsiClass refClass = pair.getSecond();
PsiMember member = pair.getFirst();
if (refClass != null) {
boolean inherited = false;
PsiClass parentClass = PsiTreeUtil.getParentOfType(scope, PsiClass.class, true);
while (parentClass != null && PsiTreeUtil.isAncestor(refMember, parentClass, false)) {
if (parentClass == refClass || parentClass.isInheritor(refClass, true)) {
inherited = true;
break;
}
parentClass = PsiTreeUtil.getParentOfType(parentClass, PsiClass.class, true);
}
if (!inherited && !PsiTreeUtil.isAncestor(refMember, member, false)) {
addReferencedMember(map, refClass, member);
}
}
}
if (expression instanceof PsiThisExpression) {
final PsiJavaCodeReferenceElement thisQualifier = ((PsiThisExpression)expression).getQualifier();
PsiClass thisClass = thisQualifier == null ? PsiTreeUtil.getParentOfType(expression, PsiClass.class, true) : ((PsiClass)thisQualifier.resolve());
if (thisClass != null && !PsiTreeUtil.isAncestor( refMember,thisClass, false)) {
addReferencedMember(map, thisClass, null);
}
}
}
}
final PsiElement[] children = scope.getChildren();
for (PsiElement child : children) {
getThisClassesToMembers(child, map, refMember);
}
}
示例12: minus
import com.intellij.openapi.util.Pair; //導入方法依賴的package包/類
public void minus(Pair<String, AbstractVcs> pair) {
final VirtualFile root = getRootForPath(pair.getFirst());
if (root == null) return;
synchronized (myLock) {
final VcsRoot key = new VcsRoot(pair.getSecond(), root);
if (myQueries.containsKey(key)) {
myQueries.remove(key, pair.getFirst());
}
myChanged.remove(pair.getFirst());
}
}
示例13: resolveToDocStringOwner
import com.intellij.openapi.util.Pair; //導入方法依賴的package包/類
@Nullable
private PsiElement resolveToDocStringOwner() {
// here the ^Q target is already resolved; the resolved element may point to intermediate assignments
if (myElement instanceof PyTargetExpression) {
final String targetName = myElement.getText();
myReassignmentChain.addWith(TagSmall, $(PyBundle.message("QDOC.assigned.to.$0", targetName)).addItem(BR));
final PyExpression assignedValue = ((PyTargetExpression)myElement).findAssignedValue();
if (assignedValue instanceof PyReferenceExpression) {
final PsiElement resolved = resolveWithoutImplicits((PyReferenceExpression)assignedValue);
if (resolved != null) {
return resolved;
}
}
return assignedValue;
}
if (myElement instanceof PyReferenceExpression) {
myReassignmentChain.addWith(TagSmall, $(PyBundle.message("QDOC.assigned.to.$0", myElement.getText())).addItem(BR));
return resolveWithoutImplicits((PyReferenceExpression)myElement);
}
// it may be a call to a standard wrapper
if (myElement instanceof PyCallExpression) {
final PyCallExpression call = (PyCallExpression)myElement;
final Pair<String, PyFunction> wrapInfo = PyCallExpressionHelper.interpretAsModifierWrappingCall(call, myOriginalElement);
if (wrapInfo != null) {
final String wrapperName = wrapInfo.getFirst();
final PyFunction wrappedFunction = wrapInfo.getSecond();
myReassignmentChain.addWith(TagSmall, $(PyBundle.message("QDOC.wrapped.in.$0", wrapperName)).addItem(BR));
return wrappedFunction;
}
}
return myElement;
}
示例14: runTasksQueue
import com.intellij.openapi.util.Pair; //導入方法依賴的package包/類
private boolean runTasksQueue(final Queue<Pair<ProjectSystemId, ExternalSystemTaskExecutionSettings>> tasksQueue) {
final Pair<ProjectSystemId, ExternalSystemTaskExecutionSettings> pair = tasksQueue.poll();
if (pair == null) return true;
final ProjectSystemId systemId = pair.first;
final ExternalSystemTaskExecutionSettings executionSettings = pair.getSecond();
final Semaphore targetDone = new Semaphore();
targetDone.down();
final Ref<Boolean> result = new Ref<Boolean>(false);
ExternalSystemUtil.runTask(executionSettings, DefaultRunExecutor.EXECUTOR_ID, myProject, systemId,
new TaskCallback() {
@Override
public void onSuccess() {
result.set(runTasksQueue(tasksQueue));
targetDone.up();
}
@Override
public void onFailure() {
targetDone.up();
}
},
ProgressExecutionMode.IN_BACKGROUND_ASYNC);
targetDone.waitFor();
return result.get();
}
示例15: read
import com.intellij.openapi.util.Pair; //導入方法依賴的package包/類
/**
* Creates an instance of GitConfig by reading information from the specified {@code .git/config} file.
* <p/>
* If some section is invalid, it is skipped, and a warning is reported.
*/
@NotNull
static GitConfig read(@NotNull GitPlatformFacade platformFacade, @NotNull File configFile) {
GitConfig emptyConfig = new GitConfig(Collections.<Remote>emptyList(), Collections.<Url>emptyList(),
Collections.<BranchConfig>emptyList());
if (!configFile.exists()) {
LOG.info("No .git/config file at " + configFile.getPath());
return emptyConfig;
}
Ini ini = new Ini();
ini.getConfig().setMultiOption(true); // duplicate keys (e.g. url in [remote])
ini.getConfig().setTree(false); // don't need tree structure: it corrupts url in section name (e.g. [url "http://github.com/"]
try {
ini.load(configFile);
}
catch (IOException e) {
LOG.warn("Couldn't load .git/config file at " + configFile.getPath(), e);
return emptyConfig;
}
IdeaPluginDescriptor plugin = platformFacade.getPluginByClassName(GitConfig.class.getName());
ClassLoader classLoader = plugin == null ?
GitConfig.class.getClassLoader() : // null e.g. if IDEA is started from IDEA
plugin.getPluginClassLoader();
Pair<Collection<Remote>, Collection<Url>> remotesAndUrls = parseRemotes(ini, classLoader);
Collection<BranchConfig> trackedInfos = parseTrackedInfos(ini, classLoader);
return new GitConfig(remotesAndUrls.getFirst(), remotesAndUrls.getSecond(), trackedInfos);
}