本文整理匯總了Java中consulo.dotnet.psi.DotNetExpression.toTypeRef方法的典型用法代碼示例。如果您正苦於以下問題:Java DotNetExpression.toTypeRef方法的具體用法?Java DotNetExpression.toTypeRef怎麽用?Java DotNetExpression.toTypeRef使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類consulo.dotnet.psi.DotNetExpression
的用法示例。
在下文中一共展示了DotNetExpression.toTypeRef方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: toTypeRefImpl
import consulo.dotnet.psi.DotNetExpression; //導入方法依賴的package包/類
@RequiredReadAction
@NotNull
@Override
public DotNetTypeRef toTypeRefImpl(boolean resolveFromParent)
{
DotNetExpression innerExpression = getInnerExpression();
if(innerExpression == null)
{
return DotNetTypeRef.ERROR_TYPE;
}
DotNetTypeRef typeRef = innerExpression.toTypeRef(resolveFromParent);
PsiElement startElement = getStartElement();
CSharpRefTypeRef.Type type = CSharpRefTypeRef.Type.ref;
if(startElement.getNode().getElementType() == CSharpTokens.OUT_KEYWORD)
{
type = CSharpRefTypeRef.Type.out;
}
return new CSharpRefTypeRef(getProject(), type, typeRef);
}
示例2: canUseVar
import consulo.dotnet.psi.DotNetExpression; //導入方法依賴的package包/類
@RequiredReadAction
public static boolean canUseVar(@NotNull DotNetExpression initializer)
{
if(!CSharpModuleUtil.findLanguageVersion(initializer).isAtLeast(CSharpLanguageVersion._3_0))
{
return false;
}
if(CS0023.isNullConstant(initializer))
{
return false;
}
DotNetTypeRef initializerType = initializer.toTypeRef(false);
DotNetTypeResolveResult typeResolveResult = initializerType.resolve();
if(typeResolveResult instanceof CSharpLambdaResolveResult && ((CSharpLambdaResolveResult) typeResolveResult).getTarget() == null)
{
return false;
}
return true;
}
示例3: isAvailable
import consulo.dotnet.psi.DotNetExpression; //導入方法依賴的package包/類
@Override
@RequiredDispatchThread
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement psi)
{
CSharpExpressionStatementImpl exprStmt = PsiTreeUtil.getParentOfType(psi, CSharpExpressionStatementImpl.class);
if(psi instanceof SyntheticElement || exprStmt == null)
{
return false;
}
DotNetExpression expression = exprStmt.getExpression();
if(expression instanceof CSharpAssignmentExpressionImpl)
{
return false;
}
DotNetTypeRef ref = expression.toTypeRef(true);
return !(ref == DotNetTypeRef.ERROR_TYPE || DotNetTypeRefUtil.isVmQNameEqual(ref, expression, DotNetTypes.System.Void));
}
示例4: check
import consulo.dotnet.psi.DotNetExpression; //導入方法依賴的package包/類
@RequiredReadAction
@NotNull
@Override
public List<HighlightInfoFactory> check(@NotNull CSharpLanguageVersion languageVersion, @NotNull CSharpHighlightContext highlightContext, @NotNull CSharpIndexAccessExpressionImpl expression)
{
DotNetExpression qualifier = expression.getQualifier();
if(qualifier.toTypeRef(false) instanceof CSharpDynamicTypeRef)
{
return Collections.emptyList();
}
List<PsiElement> ranges = new ArrayList<>(2);
CSharpCallArgumentList parameterList = expression.getParameterList();
if(parameterList != null)
{
ContainerUtil.addIfNotNull(ranges, parameterList.getOpenElement());
ContainerUtil.addIfNotNull(ranges, parameterList.getCloseElement());
}
if(ranges.isEmpty())
{
return Collections.emptyList();
}
return CC0001.checkReference(expression, ranges);
}
示例5: checkImpl
import consulo.dotnet.psi.DotNetExpression; //導入方法依賴的package包/類
@RequiredReadAction
@Nullable
@Override
public HighlightInfoFactory checkImpl(@NotNull CSharpLanguageVersion languageVersion, @NotNull CSharpHighlightContext highlightContext, @NotNull CSharpLocalVariable localVariable)
{
DotNetTypeRef dotNetTypeRef = localVariable.toTypeRef(false);
if(dotNetTypeRef == DotNetTypeRef.AUTO_TYPE)
{
DotNetExpression initializer = localVariable.getInitializer();
if(initializer == null)
{
return null;
}
if(CS0023.isNullConstant(initializer))
{
return newBuilder(localVariable.getInitializer(), "null");
}
DotNetTypeRef initializerType = initializer.toTypeRef(false);
DotNetTypeResolveResult typeResolveResult = initializerType.resolve();
if(typeResolveResult instanceof CSharpLambdaResolveResult && ((CSharpLambdaResolveResult) typeResolveResult).getTarget() == null)
{
return newBuilder(localVariable.getInitializer(), "anonymous method");
}
}
return null;
}
示例6: checkImpl
import consulo.dotnet.psi.DotNetExpression; //導入方法依賴的package包/類
@RequiredReadAction
@Nullable
@Override
public HighlightInfoFactory checkImpl(@NotNull CSharpLanguageVersion languageVersion, @NotNull CSharpHighlightContext highlightContext, @NotNull DotNetExpression element)
{
if(element.getParent() instanceof CSharpSwitchStatementImpl)
{
DotNetTypeRef typeRef = element.toTypeRef(true);
if(isValidTypeRef(typeRef))
{
return null;
}
return newBuilder(element, formatTypeRef(typeRef, element));
}
return null;
}
示例7: checkImpl
import consulo.dotnet.psi.DotNetExpression; //導入方法依賴的package包/類
@RequiredReadAction
@Nullable
@Override
public HighlightInfoFactory checkImpl(@NotNull CSharpLanguageVersion languageVersion, @NotNull CSharpHighlightContext highlightContext, @NotNull CSharpOutRefWrapExpressionImpl element)
{
DotNetExpression innerExpression = element.getInnerExpression();
if(innerExpression instanceof CSharpIndexAccessExpressionImpl)
{
DotNetExpression qualifier = ((CSharpIndexAccessExpressionImpl) innerExpression).getQualifier();
DotNetTypeRef typeRef = qualifier.toTypeRef(true);
if(!(typeRef instanceof CSharpArrayTypeRef))
{
return newBuilder(innerExpression);
}
}
return null;
}
示例8: toTypeRefImpl
import consulo.dotnet.psi.DotNetExpression; //導入方法依賴的package包/類
@RequiredReadAction
@NotNull
@Override
public DotNetTypeRef toTypeRefImpl(boolean resolveFromParent)
{
CSharpTupleElementImpl[] elements = getElements();
DotNetTypeRef[] typeRefs = new DotNetTypeRef[elements.length];
for(int i = 0; i < elements.length; i++)
{
CSharpTupleElementImpl element = elements[i];
DotNetExpression expression = element.getExpression();
typeRefs[i] = expression == null ? DotNetTypeRef.ERROR_TYPE : expression.toTypeRef(resolveFromParent);
}
return new CSharpTupleTypeRef(this, typeRefs, elements);
}
示例9: toTypeRefImpl
import consulo.dotnet.psi.DotNetExpression; //導入方法依賴的package包/類
@RequiredReadAction
@NotNull
public DotNetTypeRef toTypeRefImpl(boolean resolveFromInitializer)
{
DotNetType type = getType();
if(type == null)
{
return DotNetTypeRef.ERROR_TYPE;
}
DotNetTypeRef runtimeType = type.toTypeRef();
if(resolveFromInitializer && runtimeType == DotNetTypeRef.AUTO_TYPE)
{
final DotNetExpression initializer = getInitializer();
if(initializer == null)
{
return DotNetTypeRef.ERROR_TYPE;
}
if(myTypeRefProcessing.get())
{
return DotNetTypeRef.AUTO_TYPE;
}
try
{
myTypeRefProcessing.set(Boolean.TRUE);
return initializer.toTypeRef(true);
}
finally
{
myTypeRefProcessing.set(Boolean.FALSE);
}
}
else
{
return runtimeType;
}
}
示例10: multiResolve
import consulo.dotnet.psi.DotNetExpression; //導入方法依賴的package包/類
@NotNull
@Override
@RequiredReadAction
public ResolveResult[] multiResolve(boolean incompleteCode)
{
DotNetExpression callExpression = getCallExpression();
if(callExpression instanceof CSharpReferenceExpression)
{
return ((CSharpReferenceExpression) callExpression).multiResolve(incompleteCode);
}
else
{
DotNetTypeRef typeRef = callExpression.toTypeRef(true);
DotNetTypeResolveResult typeResolveResult = typeRef.resolve();
PsiElement element = typeResolveResult.getElement();
CSharpMethodDeclaration declaration = CSharpLambdaResolveResultUtil.getDelegateMethodTypeWrapper(element);
if(declaration != null)
{
declaration = GenericUnwrapTool.extract(declaration, typeResolveResult.getGenericExtractor());
MethodCalcResult calcResult = MethodResolver.calc(this, declaration, this);
return new ResolveResult[]{MethodResolveResult.createResult(calcResult, declaration, null)};
}
return ResolveResult.EMPTY_ARRAY;
}
}
示例11: buildVariableTypeString
import consulo.dotnet.psi.DotNetExpression; //導入方法依賴的package包/類
@RequiredReadAction
private static void buildVariableTypeString(@NotNull Project project, @NotNull DotNetExpression initializer, @NotNull StringBuilder builder, boolean value)
{
if(value && canUseVar(initializer))
{
builder.append("var");
}
else
{
DotNetTypeRef initalizerTypeRef = initializer.toTypeRef(true);
if(initalizerTypeRef == DotNetTypeRef.AUTO_TYPE || initalizerTypeRef == DotNetTypeRef.ERROR_TYPE || initalizerTypeRef == DotNetTypeRef.UNKNOWN_TYPE)
{
builder.append(StringUtil.getShortName(DotNetTypes.System.Object));
}
else
{
DotNetTypeResolveResult typeResolveResult = initalizerTypeRef.resolve();
if(typeResolveResult instanceof CSharpLambdaResolveResult)
{
List<ExpectedTypeInfo> expectedTypeRefs = ExpectedTypeVisitor.findExpectedTypeRefs(initializer);
if(!expectedTypeRefs.isEmpty())
{
CSharpTypeRefPresentationUtil.appendTypeRef(initializer, builder, expectedTypeRefs.get(0).getTypeRef(), CSharpTypeRefPresentationUtil.TYPE_KEYWORD);
return;
}
}
CSharpTypeRefPresentationUtil.appendTypeRef(initializer, builder, initalizerTypeRef, CSharpTypeRefPresentationUtil.TYPE_KEYWORD);
}
}
}
示例12: toTypeRefImpl
import consulo.dotnet.psi.DotNetExpression; //導入方法依賴的package包/類
@RequiredReadAction
@NotNull
@Override
public DotNetTypeRef toTypeRefImpl(boolean resolveFromParent)
{
DotNetExpression innerExpression = getInnerExpression();
return innerExpression == null ? DotNetTypeRef.ERROR_TYPE : innerExpression.toTypeRef(true);
}
示例13: toTypeRefImpl
import consulo.dotnet.psi.DotNetExpression; //導入方法依賴的package包/類
@NotNull
@Override
@RequiredReadAction
public DotNetTypeRef toTypeRefImpl(boolean resolveFromParent)
{
DotNetExpression condition = getCondition();
DotNetTypeRef typeRef = condition.toTypeRef(resolveFromParent);
return CSharpNullableTypeUtil.unbox(typeRef);
}
示例14: toTypeRefImpl
import consulo.dotnet.psi.DotNetExpression; //導入方法依賴的package包/類
@RequiredReadAction
@NotNull
@Override
public DotNetTypeRef toTypeRefImpl(boolean resolveFromParent)
{
DotNetExpression innerExpression = getInnerExpression();
if(innerExpression == null)
{
return DotNetTypeRef.ERROR_TYPE;
}
return innerExpression.toTypeRef(resolveFromParent);
}
示例15: castTo
import consulo.dotnet.psi.DotNetExpression; //導入方法依賴的package包/類
private static Object castTo(Object value, DotNetExpression element)
{
if(value == null)
{
return null;
}
DotNetTypeRef typeRef = element.toTypeRef(false);
PsiElement psiElement = typeRef.resolve().getElement();
if(!(psiElement instanceof DotNetTypeDeclaration))
{
return value;
}
String vmQName = ((DotNetTypeDeclaration) psiElement).getVmQName();
if(DotNetTypes.System.Int32.equals(vmQName))
{
if(value instanceof Number)
{
return ((Number) value).intValue();
}
}
else if(DotNetTypes.System.Int16.equals(vmQName))
{
if(value instanceof Number)
{
return ((Number) value).shortValue();
}
}
else if(DotNetTypes.System.Int64.equals(vmQName))
{
if(value instanceof Number)
{
return ((Number) value).longValue();
}
}
else if(DotNetTypes.System.SByte.equals(vmQName))
{
if(value instanceof Number)
{
return ((Number) value).byteValue();
}
}
else if(DotNetTypes.System.Single.equals(vmQName))
{
if(value instanceof Number)
{
return ((Number) value).floatValue();
}
}
else if(DotNetTypes.System.Double.equals(vmQName))
{
if(value instanceof Number)
{
return ((Number) value).doubleValue();
}
}
else if(DotNetTypes.System.String.equals(vmQName))
{
return value.toString();
}
return value;
}