• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java NullableComputable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.openapi.util.NullableComputable的典型用法代码示例。如果您正苦于以下问题:Java NullableComputable类的具体用法?Java NullableComputable怎么用?Java NullableComputable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NullableComputable类属于com.intellij.openapi.util包,在下文中一共展示了NullableComputable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
                                    }
                                  }));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ExpectedTypesProvider.java


示例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));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ExpectedTypesProvider.java


示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ExpectedTypeInfoImpl.java


示例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;
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TemplateModuleBuilder.java


示例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();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ResourceBundleManager.java


示例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;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:GrReassignedLocalVarsChecker.java


示例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;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:GroovyStdTypeCalculators.java


示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:JavaDocExternalFilter.java


示例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;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:ExpectedTypesProvider.java


示例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;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:PsiAnchor.java


示例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);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:XsContentDFA.java


示例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;
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:PsiAnchor.java


示例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();
				}
			}));
		}
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:25,代码来源:ExpectedTypesProvider.java


示例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));
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:26,代码来源:ExpectedTypesProvider.java


示例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);
		}
	};
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:20,代码来源:ExpectedTypesProvider.java


示例16: createInfoImpl

import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
@NotNull
private static ExpectedTypeInfoImpl createInfoImpl(@NotNull PsiType type,
                                                   int kind,
                                                   PsiType defaultType,
                                                   @NotNull TailType tailType,
                                                   PsiMethod calledMethod,
                                                   NullableComputable<String> expectedName) {
  return new ExpectedTypeInfoImpl(type, kind, defaultType, tailType, calledMethod, expectedName);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ExpectedTypesProvider.java


示例17: getEqualsType

import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
@Nullable
private static ExpectedTypeInfo getEqualsType(@Nullable PsiExpression anotherExpr) {
  PsiType anotherType = anotherExpr != null ? anotherExpr.getType() : null;
  if (anotherType == null) {
    return null;
  }

  NullableComputable<String> expectedName = ExpectedTypeInfoImpl.NULL;
  if (anotherExpr instanceof PsiReferenceExpression) {
    PsiElement refElement = ((PsiReferenceExpression)anotherExpr).resolve();
    if (refElement instanceof PsiVariable) {
      expectedName = getPropertyName((PsiVariable)refElement);
    }
  }
  ExpectedTypeInfoImpl info;
  if (anotherType instanceof PsiPrimitiveType) {
    if (PsiType.BOOLEAN.equals(anotherType)) {
      info = createInfoImpl(anotherType, ExpectedTypeInfo.TYPE_STRICTLY, anotherType, TailType.NONE, null, expectedName);
    }
    else if (PsiType.NULL.equals(anotherType)) {
      PsiType objectType = PsiType.getJavaLangObject(anotherExpr.getManager(), anotherExpr.getResolveScope());
      info = createInfoImpl(objectType, ExpectedTypeInfo.TYPE_OR_SUBTYPE, objectType, TailType.NONE, null, expectedName);
    }
    else {
      info = createInfoImpl(PsiType.DOUBLE, ExpectedTypeInfo.TYPE_OR_SUBTYPE, anotherType, TailType.NONE, null, expectedName);
    }
  }
  else {
    info = createInfoImpl(anotherType, ExpectedTypeInfo.TYPE_STRICTLY, anotherType, TailType.NONE, null, expectedName);
  }

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


示例18: visitConditionalExpression

import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
@Override public void visitConditionalExpression(@NotNull PsiConditionalExpression expr) {
  if (myExpr.equals(expr.getCondition())) {
    if (myForCompletion) {
      myExpr = expr;
      myExpr.getParent().accept(this);
      return;
    }

    myResult.add(createInfoImpl(PsiType.BOOLEAN, ExpectedTypeInfo.TYPE_STRICTLY, PsiType.BOOLEAN, TailType.NONE));
  }
  else if (myExpr.equals(expr.getThenExpression())) {
    ExpectedTypeInfo[] types = getExpectedTypes(expr, myForCompletion);
    for (int i = 0; i < types.length; i++) {
      final ExpectedTypeInfo info = types[i];
      types[i] = createInfoImpl(info.getType(), info.getKind(), info.getDefaultType(), TailType.COND_EXPR_COLON, info.getCalledMethod(),
                                new NullableComputable<String>() {
                                  @Nullable
                                  @Override
                                  public String compute() {
                                    return ((ExpectedTypeInfoImpl)info).getExpectedName();
                                  }
                                });
    }
    Collections.addAll(myResult, types);
  }
  else {
    if (!myExpr.equals(expr.getElseExpression())) {
      LOG.error(Arrays.asList(expr.getChildren()) + "; " + myExpr);
    }
    Collections.addAll(myResult, getExpectedTypes(expr, myForCompletion));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:ExpectedTypesProvider.java


示例19: inferMethodCallArgumentTypes

import com.intellij.openapi.util.NullableComputable; //导入依赖的package包/类
private static void inferMethodCallArgumentTypes(@NotNull final PsiExpression argument,
                                                 final boolean forCompletion,
                                                 @NotNull final PsiExpression[] args,
                                                 final int index,
                                                 @NotNull final PsiMethod method,
                                                 @NotNull final PsiSubstitutor substitutor,
                                                 @NotNull final Set<ExpectedTypeInfo> array) {
  LOG.assertTrue(substitutor.isValid());
  PsiParameter[] parameters = method.getParameterList().getParameters();
  if (!forCompletion && parameters.length != args.length) return;
  if (parameters.length <= index && !method.isVarArgs()) return;

  for (int j = 0; j < index; j++) {
    PsiType paramType = getParameterType(parameters[Math.min(parameters.length - 1, j)],
                                         substitutor);
    PsiType argType = args[j].getType();
    if (argType != null && !paramType.isAssignableFrom(argType)) return;
  }
  PsiParameter parameter = parameters[Math.min(parameters.length - 1, index)];
  PsiType parameterType = getParameterType(parameter, substitutor);

  TailType tailType = getMethodArgumentTailType(argument, index, method, substitutor, parameters);
  PsiType defaultType = getDefaultType(method, substitutor, parameterType, argument, args, index);

  NullableComputable<String> propertyName = getPropertyName(parameter);
  ExpectedTypeInfoImpl info = createInfoImpl(parameterType, ExpectedTypeInfo.TYPE_OR_SUBTYPE, defaultType, tailType, method,
                                             propertyName);
  array.add(info);

  if (index == parameters.length - 1 && parameter.isVarArgs()) {
    //Then we may still want to call with array argument
    final PsiArrayType arrayType = parameterType.createArrayType();
    ExpectedTypeInfoImpl info1 = createInfoImpl(arrayType, ExpectedTypeInfo.TYPE_OR_SUBTYPE, arrayType, tailType, method, propertyName);
    array.add(info1);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:ExpectedTypesProvider.java


示例20: 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);
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ExpectedTypesProvider.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Counters类代码示例发布时间:2022-05-22
下一篇:
Java LogOutCallback类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap