当前位置: 首页>>代码示例>>Java>>正文


Java Pair.getFirst方法代码示例

本文整理汇总了Java中com.intellij.openapi.util.Pair.getFirst方法的典型用法代码示例。如果您正苦于以下问题:Java Pair.getFirst方法的具体用法?Java Pair.getFirst怎么用?Java Pair.getFirst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.util.Pair的用法示例。


在下文中一共展示了Pair.getFirst方法的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);
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:20,代码来源:StudyToolWindow.java

示例2: getIcon

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
@Nullable
public Icon getIcon(@NotNull VirtualFile file) {
  final String path = file.getPath();
  final long stamp = file.getModificationStamp();
  Pair<Long, Icon> iconInfo = iconsCache.get(path);
  if (iconInfo == null || iconInfo.getFirst() < stamp) {
    try {
      final Icon icon = createOrFindBetterIcon(file, isIdeaProject(myProject));
      iconInfo = new Pair<Long, Icon>(stamp, hasProperSize(icon) ? icon : null);
      iconsCache.put(file.getPath(), iconInfo);
    }
    catch (Exception e) {//
      iconInfo = null;
      iconsCache.remove(path);
    }
  }
  return iconInfo == null ? null : iconInfo.getSecond();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ProjectIconsAccessor.java

示例3: addPendingEdge

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
/**
 * Adds pending edge in pendingScope
 *
 * @param pendingScope Scope for instruction
 * @param instruction  "Last" pending instruction
 */
public void addPendingEdge(@Nullable final PsiElement pendingScope, final Instruction instruction) {
  if (instruction == null) {
    return;
  }

  int i = 0;
  // another optimization! Place pending before first scope, not contained in pendingScope
  // the same logic is used in checkPending
  if (pendingScope != null) {
    for (; i < pending.size(); i++) {
      final Pair<PsiElement, Instruction> pair = pending.get(i);
      final PsiElement scope = pair.getFirst();
      if (scope == null) {
        continue;
      }
      if (!PsiTreeUtil.isAncestor(scope, pendingScope, true)) {
        break;
      }
    }
  }
  pending.add(i, Pair.create(pendingScope, instruction));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:ControlFlowBuilder.java

示例4: updateMappingsOnRoundCompletion

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
public static boolean updateMappingsOnRoundCompletion(
  CompileContext context, DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder, ModuleChunk chunk) throws IOException {

  Mappings delta = null;
  
  final Pair<Mappings, Callbacks.Backend> pair = MAPPINGS_DELTA_KEY.get(context);
  if (pair != null) {
    MAPPINGS_DELTA_KEY.set(context, null);
    delta = pair.getFirst();
  }
  
  if (delta == null) {
    return false;
  }
  final Set<File> compiledFiles = getFilesContainer(context, FILES_TO_COMPILE_KEY);
  FILES_TO_COMPILE_KEY.set(context, null);
  final Set<File> successfullyCompiled = getFilesContainer(context, SUCCESSFULLY_COMPILED_FILES_KEY);
  SUCCESSFULLY_COMPILED_FILES_KEY.set(context, null);
  return updateMappings(context, delta, dirtyFilesHolder, chunk, compiledFiles, successfullyCompiled);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:JavaBuilderUtil.java

示例5: getValueResources

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
protected List<ResourceElement> getValueResources(@NotNull final String resourceType, @Nullable Set<VirtualFile> files) {
  final List<ResourceElement> result = new ArrayList<ResourceElement>();
  List<Pair<Resources, VirtualFile>> resourceFiles = getResourceElements(files);
  for (final Pair<Resources, VirtualFile> pair : resourceFiles) {
    final Resources resources = pair.getFirst();
    ApplicationManager.getApplication().runReadAction(new Runnable() {
      @Override
      public void run() {
        if (!resources.isValid() || myProject.isDisposed()) {
          return;
        }
        final List<ResourceElement> valueResources = AndroidResourceUtil.getValueResourcesFromElement(resourceType, resources);
        for (ResourceElement valueResource : valueResources) {
          final String resName = valueResource.getName().getValue();

          if (resName != null && isResourcePublic(resourceType, resName)) {
            result.add(valueResource);
          }
        }
      }
    });
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ResourceManager.java

示例6: getAndroidPlatform

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
@Nullable
public static AndroidPlatform getAndroidPlatform(@NotNull JpsModule module,
                                                 @Nullable CompileContext context,
                                                 String builderName) {
  final JpsSdk<JpsSimpleElement<JpsAndroidSdkProperties>> sdk = module.getSdk(JpsAndroidSdkType.INSTANCE);
  if (sdk == null) {
    if (context != null) {
      context.processMessage(new CompilerMessage(builderName, BuildMessage.Kind.ERROR,
                                                 AndroidJpsBundle.message("android.jps.errors.sdk.not.specified", module.getName())));
    }
    return null;
  }

  final Pair<IAndroidTarget, LocalSdk> pair = getAndroidTarget(sdk, context, builderName);
  if (pair == null) {
    if (context != null) {
      context.processMessage(new CompilerMessage(builderName, BuildMessage.Kind.ERROR,
                                                 AndroidJpsBundle.message("android.jps.errors.sdk.invalid", module.getName())));
    }
    return null;
  }
  return new AndroidPlatform(sdk, pair.getFirst(), pair.getSecond());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AndroidJpsUtil.java

示例7: stepTwoEnds

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
private static boolean stepTwoEnds(final MarkedNode currNode, final LinkedList worklist, final TwoEndsFunctor functor) {
  boolean result = false;

  for (Iterator i = currNode.outIterator(); i.hasNext();) {
    final MarkedEdge currEdge = (MarkedEdge)i.next();
    final MarkedNode nextNode = (MarkedNode)currEdge.end();
    final Pair<Mark,Mark> markPair = functor.compute(currNode.getMark(), currEdge.getMark(), nextNode.getMark());

    final Mark leftMark = markPair.getFirst();
    final Mark rightMark = markPair.getSecond();

    if (!leftMark.coincidesWith(currNode.getMark())) {
      result = true;
      currNode.setMark(leftMark);
      worklist.addFirst(currNode);
    }

    if (!rightMark.coincidesWith(nextNode.getMark())) {
      result = true;
      nextNode.setMark(rightMark);
      worklist.addFirst(nextNode);
    }
  }

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:GlobalAnalyzer.java

示例8: assertLocalInspectionContains

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
public void assertLocalInspectionContains(String filename, String content, String contains) {
    Set<String> matches = new HashSet<String>();

    Pair<List<ProblemDescriptor>, Integer> localInspectionsAtCaret = getLocalInspectionsAtCaret(filename, content);
    for (ProblemDescriptor result : localInspectionsAtCaret.getFirst()) {
        TextRange textRange = result.getPsiElement().getTextRange();
        if (textRange.contains(localInspectionsAtCaret.getSecond()) && result.toString().equals(contains)) {
            return;
        }

        matches.add(result.toString());
    }

    fail(String.format("Fail matches '%s' with one of %s", contains, matches));
}
 
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:16,代码来源:DotEnvLightCodeInsightFixtureTestCase.java

示例9: assertLocalInspectionContainsNotContains

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
public void assertLocalInspectionContainsNotContains(String filename, String content, String contains) {
    Pair<List<ProblemDescriptor>, Integer> localInspectionsAtCaret = getLocalInspectionsAtCaret(filename, content);

    for (ProblemDescriptor result : localInspectionsAtCaret.getFirst()) {
        TextRange textRange = result.getPsiElement().getTextRange();
        if (textRange.contains(localInspectionsAtCaret.getSecond())) {
            fail(String.format("Fail inspection not contains '%s'", contains));
        }
    }
}
 
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:11,代码来源:DotEnvLightCodeInsightFixtureTestCase.java

示例10: assertLocalInspectionIsEmpty

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
protected void assertLocalInspectionIsEmpty(String filename, String content) {
    Pair<List<ProblemDescriptor>, Integer> localInspectionsAtCaret = getLocalInspectionsAtCaret(filename, content);

    for (ProblemDescriptor result : localInspectionsAtCaret.getFirst()) {
        TextRange textRange = result.getPsiElement().getTextRange();
        if (textRange.contains(localInspectionsAtCaret.getSecond())) {
            fail("Fail that matches is empty");
        }
    }
}
 
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:11,代码来源:DotEnvLightCodeInsightFixtureTestCase.java

示例11: 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);
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:30,代码来源:PyStudySmartChecker.java

示例12: isStructurallyAssignable_Laxed

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
public static boolean isStructurallyAssignable_Laxed( PsiClass toType, PsiClass fromType, TypeVarToTypeMap inferenceMap, boolean structural )
{
  if( fromType == PsiType.NULL )
  {
    return true;
  }

  List<Pair<PsiMethod, PsiSubstitutor>> toMethods = toType.getAllMethodsAndTheirSubstitutors();

  inferenceMap.setStructural( true );

  for( Pair<PsiMethod, PsiSubstitutor> pair : toMethods )
  {
    PsiMethod toMi = pair.getFirst();
    if( isObjectMethod( toMi ) )
    {
      continue;
    }
    if( toMi.getContainingClass().getModifierList().findAnnotation( "manifold.ext.ExtensionMethod" ) != null )
    {
      continue;
    }
    if( toMi.hasModifierProperty( PsiModifier.DEFAULT ) || toMi.hasModifierProperty( PsiModifier.STATIC ) )
    {
      continue;
    }
    PsiMethod fromMi = findAssignableMethod( structural, fromType, toMi, inferenceMap );
    if( fromMi == null )
    {
      return false;
    }
  }
  return true;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:35,代码来源:TypeUtil.java

示例13: checkForMultipleCopiesNotMove

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
private void checkForMultipleCopiesNotMove(boolean somethingChanged) {
  final MultiMap<FilePath, Pair<Change, String>> moves = new MultiMap<FilePath, Pair<Change, String>>() {
    @NotNull
    protected Collection<Pair<Change, String>> createCollection() {
      return new LinkedList<Pair<Change, String>>();
    }
  };

  for (LocalChangeList changeList : myMap.values()) {
    final Collection<Change> changes = changeList.getChanges();
    for (Change change : changes) {
      if (change.isMoved() || change.isRenamed()) {
        moves.putValue(change.getBeforeRevision().getFile(), Pair.create(change, changeList.getName()));
      }
    }
  }
  for (FilePath filePath : moves.keySet()) {
    final List<Pair<Change, String>> copies = (List<Pair<Change, String>>) moves.get(filePath);
    if (copies.size() == 1) continue;
    Collections.sort(copies, MyChangesAfterRevisionComparator.getInstance());
    for (int i = 0; i < (copies.size() - 1); i++) {
      somethingChanged = true;
      final Pair<Change, String> item = copies.get(i);
      final Change oldChange = item.getFirst();
      final Change newChange = new Change(null, oldChange.getAfterRevision());

      final LocalChangeListImpl list = (LocalChangeListImpl) myMap.get(item.getSecond());
      list.removeChange(oldChange);
      list.addChange(newChange);
      
      final VcsKey key = myIdx.getVcsFor(oldChange);
      myIdx.changeRemoved(oldChange);
      myIdx.changeAdded(newChange, key);
    }
  }
  if (somethingChanged) {
    FileStatusManager.getInstance(myProject).fileStatusesChanged();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:ChangeListWorker.java

示例14: handleInsert

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
@Override
public void handleInsert(InsertionContext context) {
  context.commitDocument();
  if (myFile.isValid()) {
    final PsiReference psiReference = context.getFile().findReferenceAt(context.getStartOffset());
    final Pair<FileReference, Boolean> fileReferencePair = getReference(psiReference);
    if (fileReferencePair != null) {
      FileReference ref = fileReferencePair.getFirst();
      context.setTailOffset(ref.getRangeInElement().getEndOffset() + ref.getElement().getTextRange().getStartOffset());
      ref.bindToElement(myFile);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:FilePathCompletionContributor.java

示例15: createDiffNavigationContext

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
private DiffNavigationContext createDiffNavigationContext(final int actualLine) {
  final ContentsLines contentsLines = new ContentsLines(myFileAnnotation.getAnnotatedContent());

  final Pair<Integer, String> pair = correctActualLineIfTextEmpty(contentsLines, actualLine);
  return new DiffNavigationContext(new Iterable<String>() {
    @Override
    public Iterator<String> iterator() {
      return new CacheOneStepIterator<String>(new ContextLineIterator(contentsLines, myFileAnnotation, pair.getFirst()));
    }
  }, pair.getSecond());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ShowDiffFromAnnotation.java


注:本文中的com.intellij.openapi.util.Pair.getFirst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。