本文整理汇总了Java中com.intellij.openapi.util.NullableComputable类的典型用法代码示例。如果您正苦于以下问题:Java NullableComputable类的具体用法?Java NullableComputable怎么用?Java NullableComputable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NullableComputable类属于com.intellij.openapi.util包,在下文中一共展示了NullableComputable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitParenthesizedExpression
import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
@Override
public void visitParenthesizedExpression(PsiParenthesizedExpression expression) {
PsiElement parent = expression.getParent();
if (parent != null) {
final MyParentVisitor visitor = new MyParentVisitor(expression, myForCompletion, myClassProvider, myVoidable, myUsedAfter);
parent.accept(visitor);
for (final ExpectedTypeInfo info : visitor.myResult) {
myResult.add(createInfoImpl(info.getType(), info.getKind(), info.getDefaultType(), TailTypes.RPARENTH, info.getCalledMethod(),
new NullableComputable<String>() {
@Nullable
@Override
public String compute() {
return ((ExpectedTypeInfoImpl)info).getExpectedName();
}
}));
}
}
}
示例2: visitMethodReturnType
import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
private void visitMethodReturnType(final PsiMethod scopeMethod, PsiType type, boolean tailTypeSemicolon) {
if (type != null) {
NullableComputable<String> expectedName;
if (PropertyUtil.isSimplePropertyAccessor(scopeMethod)) {
expectedName = new NullableComputable<String>() {
@Override
public String compute() {
return PropertyUtil.getPropertyName(scopeMethod);
}
};
}
else {
expectedName = ExpectedTypeInfoImpl.NULL;
}
myResult.add(createInfoImpl(type, ExpectedTypeInfo.TYPE_OR_SUBTYPE, type,
tailTypeSemicolon ? TailType.SEMICOLON : TailType.NONE, null, expectedName));
}
}
示例3: ExpectedTypeInfoImpl
import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
public ExpectedTypeInfoImpl(@NotNull PsiType type,
@Type int kind,
@NotNull PsiType defaultType,
@NotNull TailType myTailType,
PsiMethod calledMethod,
@NotNull NullableComputable<String> expectedName) {
this.type = type;
this.kind = kind;
this.myTailType = myTailType;
this.defaultType = defaultType;
myCalledMethod = calledMethod;
this.expectedNameComputable = expectedName;
expectedNameLazyValue = new VolatileNullableLazyValue<String>() {
@Nullable
@Override
protected String compute() {
return expectedNameComputable.compute();
}
};
PsiUtil.ensureValidType(type);
PsiUtil.ensureValidType(defaultType);
}
示例4: createProject
import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
@Nullable
@Override
public Project createProject(String name, final String path) {
myProjectMode = true;
unzip(name, path, false);
return ApplicationManager.getApplication().runWriteAction(new NullableComputable<Project>() {
@Nullable
@Override
public Project compute() {
try {
return ProjectManagerEx.getInstanceEx().convertAndLoadProject(path);
}
catch (IOException e) {
LOG.error(e);
return null;
}
}
});
}
示例5: getFullName
import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
@Nullable
public String getFullName(final @NotNull PropertiesFile propertiesFile) {
return ApplicationManager.getApplication().runReadAction(new NullableComputable<String>() {
public String compute() {
final PsiDirectory directory = propertiesFile.getParent();
final String packageQualifiedName = PropertiesUtil.getPackageQualifiedName(directory);
if (packageQualifiedName == null) {
return null;
}
final StringBuilder qName = new StringBuilder(packageQualifiedName);
if (qName.length() > 0) {
qName.append(".");
}
qName.append(getBaseName(propertiesFile.getContainingFile()));
return qName.toString();
}
});
}
示例6: getLeastUpperBoundByVar
import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
@Nullable
private static PsiType getLeastUpperBoundByVar(@NotNull final GrVariable var) {
return RecursionManager.doPreventingRecursion(var, false, new NullableComputable<PsiType>() {
@Override
public PsiType compute() {
final Collection<PsiReference> all = ReferencesSearch.search(var, var.getUseScope()).findAll();
final GrExpression initializer = var.getInitializerGroovy();
if (initializer == null && all.isEmpty()) {
return var.getDeclaredType();
}
PsiType result = initializer != null ? initializer.getType() : null;
final PsiManager manager = var.getManager();
for (PsiReference reference : all) {
final PsiElement ref = reference.getElement();
if (ref instanceof GrReferenceExpression && PsiUtil.isLValue(((GrReferenceExpression)ref))) {
result = TypesUtil.getLeastUpperBoundNullable(result, TypeInferenceHelper.getInitializerTypeFor(ref), manager);
}
}
return result;
}
});
}
示例7: fun
import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
@Override
public PsiType fun(GrMethodCall methodCall, PsiMethod method) {
GrExpression[] allArguments = PsiUtil.getAllArguments(methodCall);
GrClosableBlock closure = null;
for (GrExpression argument : allArguments) {
if (argument instanceof GrClosableBlock) {
closure = (GrClosableBlock)argument;
break;
}
}
if (closure == null) return null;
final GrClosableBlock finalClosure = closure;
return ourGuard.doPreventingRecursion(methodCall, true, new NullableComputable<PsiType>() {
@Override
public PsiType compute() {
PsiType returnType = finalClosure.getReturnType();
if (returnType == PsiType.VOID) return null;
return returnType;
}
});
}
示例8: getExternalDocInfoForElement
import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
@Override
@Nullable
public String getExternalDocInfoForElement(final String docURL, final PsiElement element) throws Exception {
String externalDoc = super.getExternalDocInfoForElement(docURL, element);
if (externalDoc != null) {
if (element instanceof PsiMethod) {
final String className = ApplicationManager.getApplication().runReadAction(
new NullableComputable<String>() {
@Override
@Nullable
public String compute() {
PsiClass aClass = ((PsiMethod)element).getContainingClass();
return aClass == null ? null : aClass.getQualifiedName();
}
}
);
Matcher matcher = ourMethodHeading.matcher(externalDoc);
final StringBuilder buffer = new StringBuilder();
DocumentationManager.createHyperlink(buffer, className, className, false);
//noinspection HardCodedStringLiteral
return matcher.replaceFirst("<H3>" + buffer.toString() + "</H3>");
}
}
return externalDoc;
}
示例9: visitMethodReturnType
import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
private void visitMethodReturnType(final PsiMethod scopeMethod, PsiType type, boolean tailTypeSemicolon) {
if (type != null) {
ExpectedTypeInfoImpl info = createInfoImpl(type, ExpectedTypeInfo.TYPE_OR_SUBTYPE, type,
tailTypeSemicolon ? TailType.SEMICOLON : TailType.NONE);
if (PropertyUtil.isSimplePropertyAccessor(scopeMethod)) {
info.expectedName = new NullableComputable<String>() {
@Override
public String compute() {
return PropertyUtil.getPropertyName(scopeMethod);
}
};
}
myResult = new ExpectedTypeInfo[]{info};
}
else {
myResult = ExpectedTypeInfo.EMPTY_ARRAY;
}
}
示例10: diagnoseNull
import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
public String diagnoseNull() {
try {
PsiElement element = ApplicationManager.getApplication().runReadAction(new NullableComputable<PsiElement>() {
@Override
public PsiElement compute() {
return restoreFromStubIndex((PsiFileWithStubSupport)getFile(), myIndex, myElementType, true);
}
});
return "No diagnostics, element=" + element + "@" + (element == null ? 0 : System.identityHashCode(element));
}
catch (AssertionError e) {
return e.getMessage() +
"; current modCount=" + PsiManager.getInstance(getProject()).getModificationTracker().getModificationCount() +
"; creation modCount=" + myCreationModCount;
}
}
示例11: createContentDFA
import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
@Nullable
public static XmlContentDFA createContentDFA(@NotNull XmlTag parentTag) {
final PsiFile file = parentTag.getContainingFile().getOriginalFile();
if (!(file instanceof XmlFile)) return null;
XSModel xsModel = ApplicationManager.getApplication().runReadAction(new NullableComputable<XSModel>() {
@Override
public XSModel compute() {
return getXSModel((XmlFile)file);
}
});
if (xsModel == null) {
return null;
}
XSElementDeclaration decl = getElementDeclaration(parentTag, xsModel);
if (decl == null) {
return null;
}
return new XsContentDFA(decl, parentTag);
}
示例12: diagnoseNull
import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
public String diagnoseNull() {
final PsiFile file = ApplicationManager.getApplication().runReadAction((Computable<PsiFile>)() -> getFile());
try {
PsiElement element = ApplicationManager.getApplication().runReadAction(
(NullableComputable<PsiElement>)() -> restoreFromStubIndex((PsiFileWithStubSupport)file, myIndex, myElementType, true));
return "No diagnostics, element=" + element + "@" + (element == null ? 0 : System.identityHashCode(element));
}
catch (AssertionError e) {
String msg = e.getMessage();
msg += file == null ? "\n no PSI file" : "\n current file stamp=" + (short)file.getModificationStamp();
final Document document = FileDocumentManager.getInstance().getCachedDocument(myVirtualFile);
if (document != null) {
msg += "\n committed=" + PsiDocumentManager.getInstance(myProject).isCommitted(document);
msg += "\n saved=" + !FileDocumentManager.getInstance().isDocumentUnsaved(document);
}
return msg;
}
}
示例13: visitParenthesizedExpression
import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
@Override
public void visitParenthesizedExpression(PsiParenthesizedExpression expression)
{
PsiElement parent = expression.getParent();
if(parent != null)
{
final MyParentVisitor visitor = new MyParentVisitor(expression, myForCompletion, myClassProvider,
myVoidable, myUsedAfter);
parent.accept(visitor);
for(final ExpectedTypeInfo info : visitor.myResult)
{
myResult.add(createInfoImpl(info.getType(), info.getKind(), info.getDefaultType(),
TailTypes.RPARENTH, info.getCalledMethod(), new NullableComputable<String>()
{
@Nullable
@Override
public String compute()
{
return ((ExpectedTypeInfoImpl) info).getExpectedName();
}
}));
}
}
}
示例14: visitMethodReturnType
import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
private void visitMethodReturnType(final PsiMethod scopeMethod, PsiType type, boolean tailTypeSemicolon)
{
if(type != null)
{
NullableComputable<String> expectedName;
if(PropertyUtil.isSimplePropertyAccessor(scopeMethod))
{
expectedName = new NullableComputable<String>()
{
@Override
public String compute()
{
return PropertyUtil.getPropertyName(scopeMethod);
}
};
}
else
{
expectedName = ExpectedTypeInfoImpl.NULL;
}
myResult.add(createInfoImpl(type, ExpectedTypeInfo.TYPE_OR_SUBTYPE, type,
tailTypeSemicolon ? TailType.SEMICOLON : TailType.NONE, null, expectedName));
}
}
示例15: getPropertyName
import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
@Nullable
private static NullableComputable<String> getPropertyName(@NotNull final PsiVariable variable)
{
return new NullableComputable<String>()
{
@Override
public String compute()
{
final String name = variable.getName();
if(name == null)
{
return null;
}
JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(variable.getProject());
VariableKind variableKind = codeStyleManager.getVariableKind(variable);
return codeStyleManager.variableNameToPropertyName(name, variableKind);
}
};
}