本文整理匯總了Java中com.intellij.openapi.util.Computable類的典型用法代碼示例。如果您正苦於以下問題:Java Computable類的具體用法?Java Computable怎麽用?Java Computable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Computable類屬於com.intellij.openapi.util包,在下文中一共展示了Computable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTypeSystemMeta
import com.intellij.openapi.util.Computable; //導入依賴的package包/類
@Override
public synchronized TSMetaModel getTypeSystemMeta(@Nullable final PsiFile contextFile) {
if (contextFile == null || !TSMetaModelBuilder.isTsFile(contextFile)) {
return myCachedValue.getValue();
}
final TSMetaModelImpl externalModel = doGetExternalModel(contextFile);
final Project project = contextFile.getProject();
CachedValue<TSMetaModelImpl> fileModelCache = contextFile.getUserData(FILE_MODEL_CACHE_KEY);
if (fileModelCache == null) {
fileModelCache = CachedValuesManager.getManager(project).createCachedValue(
() -> ApplicationManager.getApplication().runReadAction(
(Computable<CachedValueProvider.Result<TSMetaModelImpl>>) () -> {
final TSMetaModelBuilder builder = new TSMetaModelBuilder(project);
final TSMetaModelImpl modelForFile = builder.buildModelForFile(contextFile);
return CachedValueProvider.Result.create(modelForFile, contextFile);
}), false);
contextFile.putUserData(FILE_MODEL_CACHE_KEY, fileModelCache);
}
final TSMetaModelImpl fileModel = fileModelCache.getValue();
return new TSMetaModelImpl(Arrays.asList(externalModel, fileModel));
}
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:25,代碼來源:TSMetaModelAccessImpl.java
示例2: doGetExternalModel
import com.intellij.openapi.util.Computable; //導入依賴的package包/類
@NotNull
private TSMetaModelImpl doGetExternalModel(final @NotNull PsiFile contextFile) {
final PsiFile originalFile = contextFile.getOriginalFile();
final VirtualFile vFile = originalFile.getVirtualFile();
final Project project = originalFile.getProject();
CachedValue<TSMetaModelImpl> externalModelCache = originalFile.getUserData(EXTERNAL_MODEL_CACHE_KEY);
if (externalModelCache == null) {
externalModelCache = CachedValuesManager.getManager(project).createCachedValue(
() -> ApplicationManager.getApplication().runReadAction(
(Computable<CachedValueProvider.Result<TSMetaModelImpl>>) () -> {
final List<VirtualFile> excludes = vFile == null
? Collections.emptyList()
: Collections.singletonList(vFile);
final TSMetaModelBuilder builder = new TSMetaModelBuilder(project, excludes);
final TSMetaModelImpl model = builder.buildModel();
return CachedValueProvider.Result.create(model, builder.getFiles());
}), false);
originalFile.putUserData(EXTERNAL_MODEL_CACHE_KEY, externalModelCache);
}
return externalModelCache.getValue();
}
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:27,代碼來源:TSMetaModelAccessImpl.java
示例3: isAccepted
import com.intellij.openapi.util.Computable; //導入依賴的package包/類
@Override
public boolean isAccepted(PsiClass klass) {
return ApplicationManager.getApplication().runReadAction((Computable<Boolean>) () -> {
if (isSketchClass(klass)) {
final CompilerConfiguration compilerConfiguration = CompilerConfiguration.getInstance(project);
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(klass);
if (virtualFile == null) {
return false;
}
return ! compilerConfiguration.isExcludedFromCompilation(virtualFile) &&
! ProjectRootManager.getInstance(project)
.getFileIndex()
.isUnderSourceRootOfType(virtualFile, JavaModuleSourceRootTypes.RESOURCES);
}
return false;
});
}
示例4: getApplicationComponents
import com.intellij.openapi.util.Computable; //導入依賴的package包/類
private <T> List<T> getApplicationComponents(final Function<Application, List<T>> accessor) {
final List<Manifest> manifests = getManifests();
if (manifests.isEmpty()) {
Logger.getInstance(ManifestInfo.class).warn("List of manifests is empty, possibly needs a gradle sync.");
}
return ApplicationManager.getApplication().runReadAction(new Computable<List<T>>() {
@Override
public List<T> compute() {
List<T> components = Lists.newArrayList();
for (Manifest m : manifests) {
Application application = m.getApplication();
if (application != null) {
components.addAll(accessor.fun(application));
}
}
return components;
}
});
}
示例5: getElementToolSuppressedIn
import com.intellij.openapi.util.Computable; //導入依賴的package包/類
@Nullable
public PsiElement getElementToolSuppressedIn(
@NotNull
final PsiElement place, final String toolId) {
return ApplicationManager.getApplication().runReadAction(new Computable<PsiElement>() {
@Nullable
public PsiElement compute() {
final PsiElement statement = getStatementToolSuppressedIn(place,
toolId, LuaStatementElement.class);
if (statement != null) {
return statement;
}
return null;
}
});
}
示例6: getProximity
import com.intellij.openapi.util.Computable; //導入依賴的package包/類
@Nullable
public static WeighingComparable<PsiElement, ProximityLocation> getProximity(final Computable<PsiElement> elementComputable, final PsiElement context, ProcessingContext processingContext) {
PsiElement element = elementComputable.compute();
if (element == null) return null;
if (element instanceof MetadataPsiElementBase) return null;
if (context == null) return null;
Module contextModule = processingContext.get(MODULE_BY_LOCATION);
if (contextModule == null) {
contextModule = ModuleUtilCore.findModuleForPsiElement(context);
processingContext.put(MODULE_BY_LOCATION, contextModule);
}
if (contextModule == null) return null;
return new WeighingComparable<PsiElement,ProximityLocation>(elementComputable,
new ProximityLocation(context, contextModule, processingContext),
PROXIMITY_WEIGHERS);
}
示例7: accept
import com.intellij.openapi.util.Computable; //導入依賴的package包/類
@Override
public boolean accept(@NotNull final VirtualFile file) {
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
DirectoryInfo info = getInfoForFileOrDirectory(file);
if (!info.isInProject() || info.getModule() == null) return false;
if (file.isDirectory()) {
return true;
}
else {
return !myFileTypeRegistry.isFileIgnored(file);
}
}
});
}
示例8: processClassesByNames
import com.intellij.openapi.util.Computable; //導入依賴的package包/類
public static boolean processClassesByNames(Project project,
final GlobalSearchScope scope,
Collection<String> names,
Processor<PsiClass> processor) {
final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project);
for (final String name : names) {
ProgressIndicatorProvider.checkCanceled();
final PsiClass[] classes = MethodUsagesSearcher.resolveInReadAction(project, new Computable<PsiClass[]>() {
@Override
public PsiClass[] compute() {
return cache.getClassesByName(name, scope);
}
});
for (PsiClass psiClass : classes) {
ProgressIndicatorProvider.checkCanceled();
if (!processor.process(psiClass)) {
return false;
}
}
}
return true;
}
示例9: clone
import com.intellij.openapi.util.Computable; //導入依賴的package包/類
@Override
@NotNull
public GitCommandResult clone(@NotNull final Project project, @NotNull final File parentDirectory, @NotNull final String url,
@NotNull final String clonedDirectoryName, @NotNull final GitLineHandlerListener... listeners) {
return run(new Computable<GitLineHandler>() {
@Override
public GitLineHandler compute() {
GitLineHandler handler = new GitLineHandler(project, parentDirectory, GitCommand.CLONE);
handler.setStdoutSuppressed(false);
handler.setUrl(url);
handler.addParameters("--progress");
handler.addParameters(url);
handler.endOptions();
handler.addParameters(clonedDirectoryName);
addListeners(handler, listeners);
return handler;
}
});
}
示例10: findMethodRange
import com.intellij.openapi.util.Computable; //導入依賴的package包/類
private static List<TextRange> findMethodRange(final ExceptionWorker worker,
final Document document,
final Trinity<PsiClass, PsiFile, String> previousLineResult) {
return ApplicationManager.getApplication().runReadAction(new Computable<List<TextRange>>() {
@Override
public List<TextRange> compute() {
List<TextRange> ranges = getTextRangeForMethod(worker, previousLineResult);
if (ranges == null) return null;
final List<TextRange> result = new ArrayList<TextRange>();
for (TextRange range : ranges) {
result.add(new TextRange(document.getLineNumber(range.getStartOffset()),
document.getLineNumber(range.getEndOffset())));
}
return result;
}
});
}
示例11: isAccepted
import com.intellij.openapi.util.Computable; //導入依賴的package包/類
public boolean isAccepted(final PsiClass aClass) {
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
if (aClass.getQualifiedName() != null && ConfigurationUtil.PUBLIC_INSTANTIATABLE_CLASS.value(aClass) &&
(aClass.isInheritor(myBase, true) || JUnitUtil.isTestClass(aClass))) {
final CompilerConfiguration compilerConfiguration = CompilerConfiguration.getInstance(getProject());
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(aClass);
if (virtualFile == null) return false;
return !compilerConfiguration.isExcludedFromCompilation(virtualFile) &&
!ProjectRootManager.getInstance(myProject).getFileIndex().isUnderSourceRootOfType(virtualFile, JavaModuleSourceRootTypes.RESOURCES);
}
return false;
}
});
}
示例12: loadDomElement
import com.intellij.openapi.util.Computable; //導入依賴的package包/類
@Nullable
public static <T extends DomElement> T loadDomElement(@NotNull final Project project,
@NotNull final VirtualFile file,
@NotNull final Class<T> aClass) {
return ApplicationManager.getApplication().runReadAction(new Computable<T>() {
@Override
@Nullable
public T compute() {
if (project.isDisposed()) return null;
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile instanceof XmlFile) {
return loadDomElementWithReadPermission(project, (XmlFile)psiFile, aClass);
}
else {
return null;
}
}
});
}
示例13: getIncludingLayout
import com.intellij.openapi.util.Computable; //導入依賴的package包/類
@Nullable
public static String getIncludingLayout(@NotNull final XmlFile file) {
if (!ApplicationManager.getApplication().isReadAccessAllowed()) {
return ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Nullable
@Override
public String compute() {
return getIncludingLayout(file);
}
});
}
XmlTag rootTag = file.getRootTag();
if (rootTag != null && rootTag.isValid()) {
return rootTag.getAttributeValue(ATTR_RENDER_IN, TOOLS_URI);
}
return null;
}
示例14: addFileToProject
import com.intellij.openapi.util.Computable; //導入依賴的package包/類
@Override
public PsiFile addFileToProject(@NotNull @NonNls String rootPath, @NotNull @NonNls final String relativePath, @NotNull @NonNls final String fileText) throws IOException {
final VirtualFile dir = VfsUtil.createDirectories(rootPath + "/" + PathUtil.getParentPath(relativePath));
final VirtualFile[] virtualFile = new VirtualFile[1];
new WriteCommandAction.Simple(getProject()) {
@Override
protected void run() throws Throwable {
virtualFile[0] = dir.createChildData(this, StringUtil.getShortName(relativePath, '/'));
VfsUtil.saveText(virtualFile[0], fileText);
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
}
}.execute();
return ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() {
@Override
public PsiFile compute() {
return PsiManager.getInstance(getProject()).findFile(virtualFile[0]);
}
});
}
示例15: isAccepted
import com.intellij.openapi.util.Computable; //導入依賴的package包/類
@Override
public boolean isAccepted(@NotNull final PyClass pyClass) {
final VirtualFile virtualFile = pyClass.getContainingFile().getVirtualFile();
if (virtualFile == null) {
return false;
}
final int key = pyClass.hashCode();
final Pair<WeakReference<PyClass>, Boolean> pair = processedElements.get(key);
boolean isException;
if (pair == null || pair.first.get() != pyClass) {
isException = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
return PyUtil.isExceptionClass(pyClass);
}
});
processedElements.put(key, Pair.create(new WeakReference<PyClass>(pyClass), isException));
}
else {
isException = pair.second;
}
return isException;
}