本文整理匯總了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);
}
示例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);
}
}
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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();
}
};
}
示例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);
}
}
示例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);
}
}
示例10: queryImpl
import com.intellij.openapi.util.Computable; //導入方法依賴的package包/類
public Component queryImpl(Computable<Component> runnable) {
try {
myQueryImpl = true;
return runnable.compute();
}
finally {
myQueryImpl = false;
}
}
示例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);
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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 );
}