本文整理汇总了C#中ICSharpCode.NRefactory.Ast.TypeReferenceExpression类的典型用法代码示例。如果您正苦于以下问题:C# TypeReferenceExpression类的具体用法?C# TypeReferenceExpression怎么用?C# TypeReferenceExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeReferenceExpression类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了TypeReferenceExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TrackedVisitIdentifierExpression
public override object TrackedVisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
{
if (identifierExpression.Parent is InvocationExpression)
return null;
IList staticTypes = new ArrayList();
staticTypes.Add("java.lang.String");
staticTypes.Add("java.lang.Object");
string type = GetStaticFullName(identifierExpression.Identifier, identifierExpression);
if (type != null)
{
if (!staticTypes.Contains(type) && CodeBase.Mappings.Contains(type))
{
string mappedType = CodeBase.Mappings[type].Target;
TypeReferenceExpression rpe = new TypeReferenceExpression(mappedType);
rpe.Parent = identifierExpression.Parent;
ReplaceCurrentNode(rpe);
}
else if (CodeBase.Types.Contains(type))
{
if (!UsedTypes.Contains(type))
UsedTypes.Add(type);
}
}
return null;
}
示例2: TrackedVisitFieldReferenceExpression
public override object TrackedVisitFieldReferenceExpression(FieldReferenceExpression fieldReferenceExpression, object data)
{
string targetString;
if (projectTypes)
{
targetString = GetTargetString(fieldReferenceExpression);
if (CodeBase.Mappings.Contains(targetString))
{
TypeReferenceExpression typeExpression = new TypeReferenceExpression(targetString);
typeExpression.Parent = fieldReferenceExpression.Parent;
ReplaceCurrentNode(typeExpression);
return null;
}
}
else if (!IsMethodInvocation(fieldReferenceExpression) && ReachToInvocation(fieldReferenceExpression))
{
targetString = GetTargetString(fieldReferenceExpression);
if (targetString.StartsWith("id"))
return null;
string suffix = "__";
if (targetString.IndexOf(suffix) != -1)
{
if (targetString.EndsWith(suffix))
targetString = targetString.Substring(0, targetString.Length - suffix.Length);
else
return base.TrackedVisitFieldReferenceExpression(fieldReferenceExpression, data);
}
TypeReferenceExpression typeExpression = new TypeReferenceExpression(targetString);
typeExpression.Parent = fieldReferenceExpression.Parent;
ReplaceCurrentNode(typeExpression);
return null;
}
return base.TrackedVisitFieldReferenceExpression(fieldReferenceExpression, data);
}
示例3: TrackedVisitIdentifierExpression
public override object TrackedVisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
{
if (identifierExpression.Identifier == "System")
{
TypeReferenceExpression typeReferenceExpression = new TypeReferenceExpression("java.lang.System");
ReplaceCurrentNode(typeReferenceExpression);
}
return base.TrackedVisitIdentifierExpression(identifierExpression, data);
}
示例4: TrackedVisitIdentifierExpression
public override object TrackedVisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
{
if (similarTypes.Contains(identifierExpression.Identifier))
{
string fullTypeName = (string) similarTypes[identifierExpression.Identifier];
TypeReferenceExpression typeReferenceExpression = new TypeReferenceExpression(fullTypeName);
ReplaceCurrentNode(typeReferenceExpression);
}
return base.TrackedVisitIdentifierExpression(identifierExpression, data);
}
示例5: TrackedVisitTypeReferenceExpression
public override object TrackedVisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data)
{
TypeReference typeReference = typeReferenceExpression.TypeReference;
if (typeReference.Kind == TypeReferenceKind.DotClass)
{
Expression replacedExpression = GetReplacedExpression(typeReference);
ReplaceCurrentNode(replacedExpression);
}
return base.TrackedVisitTypeReferenceExpression(typeReferenceExpression, data);
}
示例6: TrackedVisitMethodDeclaration
public override object TrackedVisitMethodDeclaration(MethodDeclaration methodDeclaration, object data)
{
if (AstUtil.ContainsModifier(methodDeclaration, Modifiers.Synchronized))
{
List<Expression> positionalArgs = new List<Expression>();
TypeReferenceExpression system = new TypeReferenceExpression("System.Runtime.CompilerServices.MethodImplOptions");
FieldReferenceExpression attributeArgument = new FieldReferenceExpression(system, "Synchronized");
positionalArgs.Add(attributeArgument);
AttributeSection attributeSection = CreateAttributeSection("System.Runtime.CompilerServices.MethodImplAttribute", positionalArgs);
MethodDeclaration replacedMethod = methodDeclaration;
replacedMethod.Attributes.Add(attributeSection);
attributeSection.Parent = replacedMethod;
ReplaceCurrentNode(replacedMethod);
}
return base.TrackedVisitMethodDeclaration(methodDeclaration, data);
}
示例7: TrackedVisitIdentifierExpression
public override object TrackedVisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
{
string identifier = ContainsIdentifier(identifierExpression);
if (identifier != null)
{
TypeReferenceExpression replacedIdentifier = new TypeReferenceExpression(identifier);
replacedIdentifier.Parent = identifierExpression.Parent;
ReplaceCurrentNode(replacedIdentifier);
}
else
{
TypeDeclaration typeDeclaration = (TypeDeclaration) AstUtil.GetParentOfType(identifierExpression, typeof(TypeDeclaration));
if (typeDeclaration != null)
CheckThroughParents(typeDeclaration, identifierExpression);
}
return null;
}
示例8: CheckThroughParents
private void CheckThroughParents(TypeDeclaration typeDeclaration, IdentifierExpression identifierExpression)
{
if (typeDeclaration.Parent is TypeDeclaration)
{
TypeDeclaration parent = (TypeDeclaration) typeDeclaration.Parent;
CheckThroughParents(parent, identifierExpression);
}
if (typeDeclaration.BaseTypes.Count > 0)
{
foreach (TypeReference baseType in typeDeclaration.BaseTypes)
{
string fullName = GetFullName(baseType);
if (CodeBase.References.Contains(fullName))
{
string referedBaseType = (string) CodeBase.References[fullName];
TypeReference newBaseType = AstUtil.GetTypeReference(referedBaseType, baseType.Parent);
string referenceBaseType = GetFullName(newBaseType);
TypeDeclaration baseTypeDeclaration = (TypeDeclaration) CodeBase.Types[referenceBaseType];
if (baseTypeDeclaration != null)
{
if (DefinedInFieldsClass(baseTypeDeclaration, identifierExpression.Identifier))
{
TypeReferenceExpression id = new TypeReferenceExpression(referedBaseType);
FieldReferenceExpression replaced = new FieldReferenceExpression(id, identifierExpression.Identifier);
replaced.Parent = identifierExpression.Parent;
ReplaceCurrentNode(replaced);
}
else
{
TypeDeclaration type = (TypeDeclaration) CodeBase.Types[fullName];
CheckThroughParents(type, identifierExpression);
}
}
}
else if (CodeBase.Types.Contains(fullName))
{
TypeDeclaration baseTypeDeclaration = (TypeDeclaration) CodeBase.Types[fullName];
CheckThroughParents(baseTypeDeclaration, identifierExpression);
}
}
}
}
示例9: VisitTypeReferenceExpression
public virtual object VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data)
{
Debug.Assert((typeReferenceExpression != null));
Debug.Assert((typeReferenceExpression.TypeReference != null));
return typeReferenceExpression.TypeReference.AcceptVisitor(this, data);
}
示例10: VisitTypeReferenceExpression
public override object VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data)
{
string[] types = typeReferenceExpression.TypeReference.Type.Split ('.');
if (types == null || types.Length == 0)
return null;
if (types.Length == 1) {
ResolveResult result = resolver.ResolveIdentifier (this, typeReferenceExpression.TypeReference.Type);
if (result == null)
result = CreateResult (typeReferenceExpression.TypeReference);
result.StaticResolve = true;
return result;
}
Expression expr = new IdentifierExpression (types[0]);
for (int i = 1; i < types.Length; i++) {
if (types[i] != "?")
expr = new MemberReferenceExpression (expr, types[i]);
}
return expr.AcceptVisitor (this, data);
}
示例11: SimpleNonInvocationExpression
//.........这里部分代码省略.........
break;
}
case 2: case 47: case 49: case 50: case 51: case 70: case 95: case 134: case 144: case 169: case 176: case 177: case 205: {
Identifier();
#line 1616 "VBNET.ATG"
pexpr = new IdentifierExpression(t.val);
#line 1617 "VBNET.ATG"
pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation;
break;
}
case 52: case 54: case 65: case 76: case 77: case 84: case 111: case 117: case 133: case 159: case 160: case 165: case 191: case 192: case 193: case 194: {
#line 1618 "VBNET.ATG"
string val = String.Empty;
if (StartOf(10)) {
PrimitiveTypeName(
#line 1619 "VBNET.ATG"
out val);
} else if (la.kind == 133) {
lexer.NextToken();
#line 1619 "VBNET.ATG"
val = "Object";
} else SynErr(240);
Expect(10);
#line 1620 "VBNET.ATG"
t.val = "";
Identifier();
#line 1620 "VBNET.ATG"
pexpr = new MemberReferenceExpression(new TypeReferenceExpression(val), t.val);
break;
}
case 119: {
lexer.NextToken();
#line 1621 "VBNET.ATG"
pexpr = new ThisReferenceExpression();
break;
}
case 124: case 125: {
#line 1622 "VBNET.ATG"
Expression retExpr = null;
if (la.kind == 124) {
lexer.NextToken();
#line 1623 "VBNET.ATG"
retExpr = new BaseReferenceExpression();
} else if (la.kind == 125) {
lexer.NextToken();
#line 1624 "VBNET.ATG"
retExpr = new ClassReferenceExpression();
} else SynErr(241);
Expect(10);
IdentifierOrKeyword(
#line 1626 "VBNET.ATG"
out name);
#line 1626 "VBNET.ATG"
pexpr = new MemberReferenceExpression(retExpr, name);
break;
示例12: SimpleNonInvocationExpression
//.........这里部分代码省略.........
#line 1755 "VBNET.ATG"
pexpr = new IdentifierExpression(t.val);
pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation;
if (
#line 1758 "VBNET.ATG"
la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) {
lexer.NextToken();
Expect(172);
TypeArgumentList(
#line 1759 "VBNET.ATG"
((IdentifierExpression)pexpr).TypeArguments);
Expect(38);
}
break;
}
case 70: case 73: case 84: case 101: case 102: case 111: case 143: case 154: case 171: case 199: case 204: case 205: case 211: case 224: case 225: case 228: {
#line 1761 "VBNET.ATG"
string val = String.Empty;
if (StartOf(12)) {
PrimitiveTypeName(
#line 1762 "VBNET.ATG"
out val);
} else if (la.kind == 171) {
lexer.NextToken();
#line 1762 "VBNET.ATG"
val = "System.Object";
} else SynErr(284);
#line 1763 "VBNET.ATG"
pexpr = new TypeReferenceExpression(new TypeReference(val, true));
break;
}
case 156: {
lexer.NextToken();
#line 1764 "VBNET.ATG"
pexpr = new ThisReferenceExpression();
break;
}
case 161: case 162: {
#line 1765 "VBNET.ATG"
Expression retExpr = null;
if (la.kind == 161) {
lexer.NextToken();
#line 1766 "VBNET.ATG"
retExpr = new BaseReferenceExpression() { StartLocation = t.Location, EndLocation = t.EndLocation };
} else if (la.kind == 162) {
lexer.NextToken();
#line 1767 "VBNET.ATG"
retExpr = new ClassReferenceExpression() { StartLocation = t.Location, EndLocation = t.EndLocation };
} else SynErr(285);
Expect(26);
IdentifierOrKeyword(
#line 1769 "VBNET.ATG"
out name);
#line 1769 "VBNET.ATG"
pexpr = new MemberReferenceExpression(retExpr, name) { StartLocation = startLocation, EndLocation = t.EndLocation };
break;
示例13: VisitTypeReferenceExpression
// RG: CodeTypeReferenceExpression
public override object VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data)
{
return new CodeTypeReferenceExpression(ConvType(typeReferenceExpression.TypeReference));
}
示例14: TrackedVisitTypeReferenceExpression
public override object TrackedVisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data)
{
this.Append(this.GetTypeName(typeReferenceExpression.TypeReference));
return null;
}
示例15: VisitTypeReferenceExpression
public override object VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data)
{
return CreateReturnType(typeReferenceExpression.TypeReference);
}