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


Java Computable.compute方法代碼示例

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


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

示例1: getMethodResult

import com.intellij.openapi.util.Computable; //導入方法依賴的package包/類
private static JavaResolveResult getMethodResult(final PsiCall callExpression) {
  final PsiExpressionList argumentList = callExpression.getArgumentList();

  final PsiLambdaExpression expression = PsiTreeUtil.getParentOfType(argumentList, PsiLambdaExpression.class);
  final Computable<JavaResolveResult> computableResolve = new Computable<JavaResolveResult>() {
    @Override
    public JavaResolveResult compute() {
      return getResolveResult(callExpression, argumentList);
    }
  };
  MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
  return properties != null ? null :
         expression == null || !PsiResolveHelper.ourGraphGuard.currentStack().contains(expression)
         ? computableResolve.compute()
         : PsiResolveHelper.ourGraphGuard.doPreventingRecursion(expression, false, computableResolve);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:InferenceSession.java

示例2: computeForOverloadedCandidate

import com.intellij.openapi.util.Computable; //導入方法依賴的package包/類
private <T> T computeForOverloadedCandidate(final Computable<T> computable, final PsiSubstitutor substitutor) {
  Map<PsiElement, CurrentCandidateProperties> map = CURRENT_CANDIDATE.get();
  if (map == null) {
    map = ContainerUtil.createConcurrentWeakMap();
    CURRENT_CANDIDATE.set(map);
  }
  final PsiElement argumentList = getMarkerList();
  final CurrentCandidateProperties alreadyThere = map.put(argumentList,
                                                          new CurrentCandidateProperties(this, substitutor, isVarargs(), true));
  try {
    return computable.compute();
  }
  finally {
    if (alreadyThere == null) {
      map.remove(argumentList);
    } else {
      map.put(argumentList, alreadyThere);
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:MethodCandidateInfo.java

示例3: doHierarchyTest

import com.intellij.openapi.util.Computable; //導入方法依賴的package包/類
protected void doHierarchyTest(final Computable<HierarchyTreeStructure> treeStructureComputable, final String... fileNames)
  throws Exception {
  final String[] relFilePaths = new String[fileNames.length];
  for (int i = 0; i < fileNames.length; i++) {
    relFilePaths[i] = "/" + getBasePath() + "/" + fileNames[i];
  }
  configureByFiles(null, relFilePaths);

  final String verificationFilePath = getTestDataPath() + "/" + getBasePath() + "/" + getTestName(false) + "_verification.xml";
  HierarchyTreeStructure structure = treeStructureComputable.compute();
  try {
    checkHierarchyTreeStructure(structure, JDOMUtil.loadDocument(new File(verificationFilePath)));
  } catch (Throwable e)  {
    assertEquals("XML structure comparison for your convenience, actual failure details BELOW",
                 FileUtil.loadFile(new File(verificationFilePath)), dump(structure, null, 0));
    //noinspection CallToPrintStackTrace
    e.printStackTrace();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:HierarchyViewTestBase.java

示例4: tryRunReadActionInSmartMode

import com.intellij.openapi.util.Computable; //導入方法依賴的package包/類
@Nullable
public <T> T tryRunReadActionInSmartMode(@NotNull Computable<T> task, @Nullable String notification) {
  if (ApplicationManager.getApplication().isReadAccessAllowed()) {
    try {
      return task.compute();
    }
    catch (IndexNotReadyException e) {
      if (notification != null) {
        showDumbModeNotification(notification);
      }
      return null;
    }
  }
  else {
    return runReadActionInSmartMode(task);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:DumbService.java

示例5: removeData

import com.intellij.openapi.util.Computable; //導入方法依賴的package包/類
@Override
public void removeData(@NotNull final Computable<Collection<Library>> toRemoveComputable,
                       @NotNull Collection<DataNode<LibraryData>> toIgnore,
                       @NotNull ProjectData projectData,
                       @NotNull final Project project,
                       @NotNull final IdeModifiableModelsProvider modelsProvider) {
  final Collection<Library> toRemove = toRemoveComputable.compute();
  if (toRemove.isEmpty()) {
    return;
  }

  final LibraryTable.ModifiableModel librariesModel = modelsProvider.getModifiableProjectLibrariesModel();
  for (Library library : toRemove) {
    String libraryName = library.getName();
    if (libraryName != null) {
      Library libraryToRemove = librariesModel.getLibraryByName(libraryName);
      if (libraryToRemove != null) {
        librariesModel.removeLibrary(libraryToRemove);
      }
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:LibraryDataService.java

示例6: findValidParentUnderReadAction

import com.intellij.openapi.util.Computable; //導入方法依賴的package包/類
@Nullable
public static VirtualFile findValidParentUnderReadAction(final FilePath file) {
  if (file.getVirtualFile() != null) return file.getVirtualFile();
  final Computable<VirtualFile> computable = new Computable<VirtualFile>() {
    @Override
    public VirtualFile compute() {
      return findValidParent(file);
    }
  };
  final Application application = ApplicationManager.getApplication();
  if (application.isReadAccessAllowed()) {
    return computable.compute();
  } else {
    return application.runReadAction(computable);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:ChangesUtil.java

示例7: createFromLineComputable

import com.intellij.openapi.util.Computable; //導入方法依賴的package包/類
public static SourcePosition createFromLineComputable(@NotNull final PsiFile file, final Computable<Integer> line) {
  return new SourcePositionCache(file) {
    @Override
    protected int calcLine() {
      return line.compute();
    }
  };
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:9,代碼來源:SourcePosition.java

示例8: execute

import com.intellij.openapi.util.Computable; //導入方法依賴的package包/類
public <T> void execute(Computable<T> task, CallbackWrapper<T> callback) {
  clear();
  T result = task.compute();
  if (myErrorMessage == null) {
    callback.onSuccess(result);
  }
  else {
    callback.onError(myErrorMessage);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:11,代碼來源:AgentTaskExecutor.java

示例9: doInference

import com.intellij.openapi.util.Computable; //導入方法依賴的package包/類
private static <T> T doInference(@NotNull Map<String, PsiType> bindings, @NotNull Computable<T> computation) {
  InferenceContext old = ourInferenceContext.get();
  ourInferenceContext.set(new InferenceContext.PartialContext(bindings));
  try {
    return computation.compute();
  }
  finally {
    ourInferenceContext.set(old);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:11,代碼來源:TypeInferenceHelper.java

示例10: queryImpl

import com.intellij.openapi.util.Computable; //導入方法依賴的package包/類
public Component queryImpl(Computable<Component> runnable) {
  try {
    myQueryImpl = true;
    return runnable.compute();
  }
  finally {
    myQueryImpl = false;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:LayoutFocusTraversalPolicyExt.java

示例11: insertChangeNode

import com.intellij.openapi.util.Computable; //導入方法依賴的package包/類
private void insertChangeNode(final Object change, final ChangesGroupingPolicy policy,
                              final ChangesBrowserNode listNode, final Computable<ChangesBrowserNode> nodeCreator) {
  final StaticFilePath pathKey = getKey(change);
  final ChangesBrowserNode node = nodeCreator.compute();
  ChangesBrowserNode parentNode = getParentNodeFor(pathKey, policy, listNode);
  model.insertNodeInto(node, parentNode, model.getChildCount(parentNode));

  if (pathKey != null && pathKey.isDirectory()) {
    myFoldersCache.put(pathKey.getKey(), node);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:12,代碼來源:TreeModelBuilder.java

示例12: runWithFormattingDisabled

import com.intellij.openapi.util.Computable; //導入方法依賴的package包/類
@Nullable
public <T> T runWithFormattingDisabled(@NotNull Computable<T> runnable) {
  disableFormatting();
  try {
    return runnable.compute();
  }
  finally {
    enableFormatting();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:11,代碼來源:FormatterImpl.java

示例13: _getCachedValue

import com.intellij.openapi.util.Computable; //導入方法依賴的package包/類
private <T> T _getCachedValue(@Nullable PsiElement element, @NotNull Computable<T> computable, @NotNull Object key) {
  Map<Object, Object> map = myCache.get(element);
  if (map == null) {
    myCache.put(element, map = ContainerUtil.newHashMap());
  }
  if (map.containsKey(key)) {
    //noinspection unchecked
    return (T)map.get(key);
  }

  T result = computable.compute();
  map.put(key, result);
  return result;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:15,代碼來源:InferenceContext.java

示例14: fromString

import com.intellij.openapi.util.Computable; //導入方法依賴的package包/類
public List<File> fromString(@Nullable @NonNls String s, ConvertContext context) {
  final GenericAttributeValue attribValue = context.getInvocationElement().getParentOfType(GenericAttributeValue.class, false);
  if (attribValue == null) {
    return null;
  }
  final String path = attribValue.getStringValue();
  if (path == null) {
    return null;
  }
  final List<File> result = new ArrayList<File>();
  Computable<String> basedirComputable = null;
  final PathTokenizer pathTokenizer = new PathTokenizer(path);
  while (pathTokenizer.hasMoreTokens()) {
    File file = new File(pathTokenizer.nextToken());
    if (!file.isAbsolute()) {
      if (basedirComputable == null) {
        basedirComputable = new Computable<String>() {
          final String myBaseDir;
          {
            final AntDomProject antProject = getEffectiveAntProject(attribValue);
            myBaseDir = antProject != null? antProject.getProjectBasedirPath() : null;
          }

          public String compute() {
            return myBaseDir;
          }
        };
      }
      final String baseDir = basedirComputable.compute();
      if (baseDir == null) {
        continue;
      }
      file = new File(baseDir, path);
    }
    result.add(file);
  }
  return result;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:39,代碼來源:AntMultiPathStringConverter.java

示例15: resolveInReadAction

import com.intellij.openapi.util.Computable; //導入方法依賴的package包/類
static <T> T resolveInReadAction( Project p, Computable<T> computable )
{
  return ApplicationManager.getApplication().isReadAccessAllowed() ? computable.compute() : DumbService.getInstance( p ).runReadActionInSmartMode( computable );
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:5,代碼來源:ExtensionMethodUsageSearcher.java


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