當前位置: 首頁>>代碼示例>>Java>>正文


Java Pair類代碼示例

本文整理匯總了Java中com.intellij.openapi.util.Pair的典型用法代碼示例。如果您正苦於以下問題:Java Pair類的具體用法?Java Pair怎麽用?Java Pair使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Pair類屬於com.intellij.openapi.util包,在下文中一共展示了Pair類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getLocalInspectionsAtCaret

import com.intellij.openapi.util.Pair; //導入依賴的package包/類
private Pair<List<ProblemDescriptor>, Integer> getLocalInspectionsAtCaret(String filename, String content) {

        PsiElement psiFile = myFixture.configureByText(filename, content);

        int caretOffset = myFixture.getCaretOffset();
        if(caretOffset <= 0) {
            fail("Please provide <caret> tag");
        }

        ProblemsHolder problemsHolder = new ProblemsHolder(InspectionManager.getInstance(getProject()), psiFile.getContainingFile(), false);

        for (LocalInspectionEP localInspectionEP : LocalInspectionEP.LOCAL_INSPECTION.getExtensions()) {
            Object object = localInspectionEP.getInstance();
            if(!(object instanceof LocalInspectionTool)) {
                continue;
            }

            ((LocalInspectionTool) object).buildVisitor(problemsHolder, false);
        }

        return new Pair<List<ProblemDescriptor>, Integer>(problemsHolder.getResults(), caretOffset);
    }
 
開發者ID:adelf,項目名稱:idea-php-dotenv-plugin,代碼行數:23,代碼來源:DotEnvLightCodeInsightFixtureTestCase.java

示例2: getDejagnuParameters

import com.intellij.openapi.util.Pair; //導入依賴的package包/類
/**
 * Returns need runner parameters dependence current version runtest.
 * @param version current version runtest
 * @return list of need parameters
 */
@NotNull
@VisibleForTesting
static List<Pair<String, String>> getDejagnuParameters(@NotNull final String version){
  final List<Pair<String, String>> params = new ArrayList<Pair<String, String>>();
  params.add(new Pair<String, String>(HAS_RUNTEST_VAR, "1"));
  if (VersionComparatorUtil.compare(version, "1.4.4") <= 0){
    params.add(new Pair<String, String>(MY_RUNTESTFLAGS, "RUNTESTFLAGS=--all"));
    return params;
  }
  if (VersionComparatorUtil.compare(version, "1.5.3") < 0){
      params.add(new Pair<String, String>(MY_RUNTESTFLAGS, "RUNTESTFLAGS=--all --xml"));
    return params;
  }
  params.add(new Pair<String, String>(MY_RUNTESTFLAGS, "RUNTESTFLAGS=--all --xml=\"testresults.xml\""));
  return params;
}
 
開發者ID:unix-junkie,項目名稱:teamcity-autotools-plugin,代碼行數:22,代碼來源:RuntestToolProvider.java

示例3: getDejagnuParametersTest

import com.intellij.openapi.util.Pair; //導入依賴的package包/類
@Test
public void getDejagnuParametersTest(){
  final Collection<Pair<String, String>> answer = new ArrayList<Pair<String, String>>();
  answer.add(new Pair<String, String>(HAS_RUNTEST_VAR, "1"));
  answer.add(new Pair<String, String>(MY_RUNTESTFLAGS, "RUNTESTFLAGS=--all"));
  Assert.assertEquals(RuntestToolProvider.getDejagnuParameters("1.4.4"), answer,"for version 1.4.4");
  answer.clear();

  answer.add(new Pair<String, String>(HAS_RUNTEST_VAR, "1"));
  answer.add(new Pair<String, String>(MY_RUNTESTFLAGS, "RUNTESTFLAGS=--all --xml"));
  Assert.assertEquals(RuntestToolProvider.getDejagnuParameters("1.5.1"), answer, "for version 1.5.1");
  answer.clear();

  answer.add(new Pair<String, String>(HAS_RUNTEST_VAR, "1"));
  //answer.add(new Pair<String, String>(MY_RUNTESTFLAGS, "'--all --xml'"));
  answer.add(new Pair<String, String>(MY_RUNTESTFLAGS, "RUNTESTFLAGS=--all --xml=\"testresults.xml\""));
  Assert.assertEquals(RuntestToolProvider.getDejagnuParameters("1.5.3"), answer, "for version 1.5.3");
  Assert.assertEquals(RuntestToolProvider.getDejagnuParameters("1.6"), answer, "for version 1.6");
}
 
開發者ID:unix-junkie,項目名稱:teamcity-autotools-plugin,代碼行數:20,代碼來源:AutotoolsAgentTest.java

示例4: onDownload

import com.intellij.openapi.util.Pair; //導入依賴的package包/類
@Override
public Pair<Boolean, List<File>> onDownload(@NotNull ClassEntity[] classEntities, @NotNull File outputFolder) {
    String newUrl = null;
    try {
        newUrl = androidOnlineSearch(classEntities[0]);
    } catch (ConnectException | UnknownHostException e1) {
        if (timeoutListener != null) {
            timeoutListener.run();
        }
    } catch (Exception e) {
        Log.e(e);
    }
    if (!Utils.isEmpty(newUrl)) {
        for (ClassEntity entity : classEntities) {
            entity.setDownloadUrl(newUrl);
        }
        Log.debug("SearchDownload => " + newUrl);
        return new XrefDownload().onDownload(classEntities, outputFolder);
    }
    return Pair.create(false, Collections.<File>emptyList());
}
 
開發者ID:pengwei1024,項目名稱:AndroidSourceViewer,代碼行數:22,代碼來源:SearchDownload.java

示例5: addShortcut

import com.intellij.openapi.util.Pair; //導入依賴的package包/類
private void addShortcut(@NotNull final String actionIdString, @NotNull final String[] shortcuts) {
  KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
  for (Keymap keymap : keymapManager.getAllKeymaps()) {
    List<Pair<String, String>> pairs = myDeletedShortcuts.get(keymap);
    if (pairs == null) {
      pairs = new ArrayList<>();
      myDeletedShortcuts.put(keymap, pairs);
    }
    for (String shortcutString : shortcuts) {
      Shortcut studyActionShortcut = new KeyboardShortcut(KeyStroke.getKeyStroke(shortcutString), null);
      String[] actionsIds = keymap.getActionIds(studyActionShortcut);
      for (String actionId : actionsIds) {
        pairs.add(Pair.create(actionId, shortcutString));
        keymap.removeShortcut(actionId, studyActionShortcut);
      }
      keymap.addShortcut(actionIdString, studyActionShortcut);
    }
  }
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:20,代碼來源:StudyProjectComponent.java

示例6: projectClosed

import com.intellij.openapi.util.Pair; //導入依賴的package包/類
@Override
public void projectClosed() {
  final Course course = StudyTaskManager.getInstance(myProject).getCourse();
  if (course != null) {
    final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
    if (toolWindow != null) {
      toolWindow.getContentManager().removeAllContents(false);
    }
    KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
    for (Keymap keymap : keymapManager.getAllKeymaps()) {
      List<Pair<String, String>> pairs = myDeletedShortcuts.get(keymap);
      if (pairs != null && !pairs.isEmpty()) {
        for (Pair<String, String> actionShortcut : pairs) {
          keymap.addShortcut(actionShortcut.first, new KeyboardShortcut(KeyStroke.getKeyStroke(actionShortcut.second), null));
        }
      }
    }
  }
  myListener = null;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:21,代碼來源:StudyProjectComponent.java

示例7: 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);
  }
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:20,代碼來源:StudyToolWindow.java

示例8: countProgressAsOneTaskWithSubtasks

import com.intellij.openapi.util.Pair; //導入依賴的package包/類
/**
 * Counts current progress for course which consists of only on task with subtasks
 * In this case we count each subtasks as task
 * @return Pair (number of solved tasks, number of tasks) or null if lessons can't be interpreted as one task with subtasks
 */
@Nullable
private static Pair<Integer, Integer> countProgressAsOneTaskWithSubtasks(List<Lesson> lessons) {
  if (lessons.size() == 1 && lessons.get(0).getTaskList().size() == 1) {
    final Lesson lesson = lessons.get(0);
    final Task task = lesson.getTaskList().get(0);
    if (task instanceof TaskWithSubtasks) {
      final int lastSubtaskIndex = ((TaskWithSubtasks)task).getLastSubtaskIndex();
      final int activeSubtaskIndex = ((TaskWithSubtasks)task).getActiveSubtaskIndex();
      int taskNum = lastSubtaskIndex + 1;
      boolean isLastSubtaskSolved = activeSubtaskIndex == lastSubtaskIndex && task.getStatus() == StudyStatus.Solved;
      return Pair.create(isLastSubtaskSolved ? taskNum : activeSubtaskIndex, taskNum);
    }
  }
  return null;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:21,代碼來源:StudyToolWindow.java

示例9: drawAnswerPlaceholder

import com.intellij.openapi.util.Pair; //導入依賴的package包/類
public static void drawAnswerPlaceholder(@NotNull final Editor editor, @NotNull final AnswerPlaceholder placeholder,
                                         @NotNull final JBColor color) {
  EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
  final TextAttributes textAttributes = new TextAttributes(scheme.getDefaultForeground(), scheme.getDefaultBackground(), null,
                                                           EffectType.BOXED, Font.PLAIN);
  textAttributes.setEffectColor(color);
  int startOffset = placeholder.getOffset();
  if (startOffset == -1) {
    return;
  }
  final int length =
    placeholder.isActive() ? placeholder.getRealLength() : placeholder.getVisibleLength(placeholder.getActiveSubtaskIndex());
  Pair<Integer, Integer> offsets = StudyUtils.getPlaceholderOffsets(placeholder, editor.getDocument());
  startOffset = offsets.first;
  int endOffset = offsets.second;
  if (placeholder.isActive()) {
    drawAnswerPlaceholder(editor, startOffset, endOffset, textAttributes, PLACEHOLDERS_LAYER);
  }
  else if (!placeholder.getUseLength() && length != 0) {
    drawAnswerPlaceholderFromPrevStep(editor, startOffset, endOffset);
  }
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:23,代碼來源:EduAnswerPlaceholderPainter.java

示例10: createGuardedBlocks

import com.intellij.openapi.util.Pair; //導入依賴的package包/類
public static void createGuardedBlocks(@NotNull final Editor editor, AnswerPlaceholder placeholder) {
  Document document = editor.getDocument();
  if (document instanceof DocumentImpl) {
    DocumentImpl documentImpl = (DocumentImpl)document;
    List<RangeMarker> blocks = documentImpl.getGuardedBlocks();
    Pair<Integer, Integer> offsets = StudyUtils.getPlaceholderOffsets(placeholder, editor.getDocument());
    Integer start = offsets.first;
    Integer end = offsets.second;
    if (start != 0) {
      createGuardedBlock(editor, blocks, start - 1, start);
    }
    if (end != document.getTextLength()) {
      createGuardedBlock(editor, blocks, end, end + 1);
    }
  }
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:17,代碼來源:EduAnswerPlaceholderPainter.java

示例11: 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);
  }
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:21,代碼來源:CCShowPreviewTest.java

示例12: 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));
    }
  }
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:18,代碼來源:CCTestCase.java

示例13: findSelectedBreakpoint

import com.intellij.openapi.util.Pair; //導入依賴的package包/類
@NotNull
public static Pair<GutterIconRenderer, Object> findSelectedBreakpoint(@NotNull final Project project, @NotNull final Editor editor) {
  int offset = editor.getCaretModel().getOffset();
  Document editorDocument = editor.getDocument();

  DebuggerSupport[] debuggerSupports = DebuggerSupport.getDebuggerSupports();
  for (DebuggerSupport debuggerSupport : debuggerSupports) {
    final BreakpointPanelProvider<?> provider = debuggerSupport.getBreakpointPanelProvider();

    final int textLength = editor.getDocument().getTextLength();
    if (offset > textLength) {
      offset = textLength;
    }

    Object breakpoint = provider.findBreakpoint(project, editorDocument, offset);
    if (breakpoint != null) {
      final GutterIconRenderer iconRenderer = provider.getBreakpointGutterIconRenderer(breakpoint);
      return Pair.create(iconRenderer, breakpoint);
    }
  }
  return Pair.create(null, null);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:XBreakpointUtil.java

示例14: isProperAssignmentStatementFound

import com.intellij.openapi.util.Pair; //導入依賴的package包/類
private static Pair<Boolean, PsiNewExpression> isProperAssignmentStatementFound(PsiLocalVariable localVariable, PsiMethodCallExpression addAllExpression) {
  PsiStatement currentStatement = PsiTreeUtil.getParentOfType(addAllExpression, PsiStatement.class);
  final PsiStatement localVariableDefinitionStatement = PsiTreeUtil.getParentOfType(localVariable, PsiStatement.class);
  while (currentStatement != null) {
    currentStatement = PsiTreeUtil.getPrevSiblingOfType(currentStatement, PsiStatement.class);
    if (currentStatement == localVariableDefinitionStatement) {
      return Pair.create(true, null);
    }
    for (PsiAssignmentExpression expression : PsiTreeUtil.findChildrenOfType(currentStatement, PsiAssignmentExpression.class)) {
      final PsiExpression lExpression = expression.getLExpression();
      if (lExpression instanceof PsiReferenceExpression && ((PsiReferenceExpression)lExpression).isReferenceTo(localVariable)) {
        final PsiExpression rExpression = expression.getRExpression();
        final boolean isValid = checkLocalVariableAssignmentOrInitializer(rExpression);
        return Pair.create(isValid, isValid ? (PsiNewExpression)rExpression : null);
      }
    }
  }
  return Pair.create(true, null);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:CollectionAddAllCanBeReplacedWithConstructorInspection.java

示例15: initComboBox

import com.intellij.openapi.util.Pair; //導入依賴的package包/類
static JComboBox initComboBox(final JComboBox comboBox, final Condition<String> validity) {
  comboBox.setEditable(false);
  comboBox.setPrototypeDisplayValue(new ComboBoxItem("A", null));
  comboBox.setRenderer(new DefaultListCellRenderer() {
    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
      final Pair<String, Icon> pair = (Pair<String, Icon>)value;
      final String text = pair == null ? null : pair.first;
      setText(text);
      final Dimension dimension = getPreferredSize();
      if (!validity.value(text)) {
        setFont(getFont().deriveFont(Font.ITALIC));
        setForeground(JBColor.RED);
      }
      setIcon(pair == null ? null : pair.second);
      setPreferredSize(new Dimension(-1, dimension.height));
      return this;
    }
  });
  return comboBox;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:ComboControl.java


注:本文中的com.intellij.openapi.util.Pair類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。