本文整理汇总了C#中ICSharpCode.NRefactory.Ast.IdentifierExpression类的典型用法代码示例。如果您正苦于以下问题:C# IdentifierExpression类的具体用法?C# IdentifierExpression怎么用?C# IdentifierExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IdentifierExpression类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了IdentifierExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: add_Invocation
//, AstExpression expression)
public static InvocationExpression add_Invocation(this BlockStatement blockStatement, string typeName, string methodName, params object[] parameters)
{
if (methodName.valid().isFalse())
return null;
Expression memberExpression = null;
if (typeName.valid())
memberExpression = new MemberReferenceExpression(new IdentifierExpression(typeName), methodName);
else
memberExpression = new IdentifierExpression(methodName);
var memberReference = new InvocationExpression(memberExpression);
if (parameters != null)
{
var arguments = new List<Expression>();
foreach (var parameter in parameters)
if (parameter is Expression)
arguments.add(parameter as Expression);
else
arguments.add(new PrimitiveExpression(parameter, parameter.str()));
memberReference.Arguments = arguments;
}
blockStatement.append(memberReference.expressionStatement());
return memberReference;
}
示例2: TrackedVisitIdentifierExpression
public override object TrackedVisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
{
TypeDeclaration typeDeclaration = (TypeDeclaration) AstUtil.GetParentOfType(identifierExpression, typeof(TypeDeclaration));
if (typeDeclaration != null && typeDeclaration.Parent is TypeDeclaration && !IsInvocation(identifierExpression))
{
IList parentFields = AstUtil.GetChildrenWithType(typeDeclaration.Parent, typeof(FieldDeclaration));
IList innerFields = AstUtil.GetChildrenWithType(typeDeclaration, typeof(FieldDeclaration));
FieldDeclaration field = new FieldDeclaration(null);
field.Fields.Add(new VariableDeclaration(identifierExpression.Identifier));
if (!ContainsField(innerFields, field, false) &&
!IdentifierDeclaredInParameter(identifierExpression) &&
ContainsField(parentFields, field, false))
{
string parentTypeName = ((TypeDeclaration) typeDeclaration.Parent).Name;
AddInstanceField(typeDeclaration, parentTypeName);
IdentifierExpression ins = new IdentifierExpression(parentTypeName);
FieldReferenceExpression fieldReferenceExpression = new FieldReferenceExpression(ins, identifierExpression.Identifier);
fieldReferenceExpression.Parent = identifierExpression.Parent;
ReplaceCurrentNode(fieldReferenceExpression);
}
}
return base.TrackedVisitIdentifierExpression(identifierExpression, data);
}
示例3: VisitIdentifierExpression
public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
{
if (nameComparer.Equals(identifierExpression.Identifier, from)) {
identifierExpression.Identifier = to;
}
return base.VisitIdentifierExpression(identifierExpression, data);
}
示例4: 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;
}
示例5: add_MemberReference
//, AstExpression expression)
public static MemberReferenceExpression add_MemberReference(this BlockStatement blockStatement, string memberName, string className)
{
var identifier = new IdentifierExpression(memberName);
var memberReference = new MemberReferenceExpression(identifier, className);
blockStatement.append(memberReference.expressionStatement());
return memberReference;
}
示例6: VisitIdentifierExpression
public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
{
if (Compare(identifierExpression))
{
identifiers.Add(identifierExpression);
}
return base.VisitIdentifierExpression(identifierExpression, data);
}
示例7: VisitIdentifierExpression
public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
{
if (RenameTable.ContainsKey(identifierExpression.Identifier))
{
identifierExpression.Identifier = RenameTable[identifierExpression.Identifier];
}
return null;
}
示例8: 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);
}
示例9: TrackedVisitIdentifierExpression
public override object TrackedVisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
{
if (data != null && data is string)
{
string identifier = identifierExpression.Identifier;
if (identifier == (string) data)
ReplaceCurrentNode(new IdentifierExpression("value"));
}
return base.TrackedVisitIdentifierExpression(identifierExpression, data);
}
示例10: parameterPosition
public static int parameterPosition(this ObjectCreateExpression objectCreateExpression, IdentifierExpression identifierExpression)
{
if (objectCreateExpression != null && identifierExpression != null)
for (int i = 0; i < objectCreateExpression.Parameters.Count; i++) // for each arguments
foreach (var iNode in objectCreateExpression.Parameters[i].iNodes<IdentifierExpression>()) // get the IdentifierExpression
if (iNode == identifierExpression) // and compare the values
return i;
"in ObjectCreateExpression.parameterPosition could not find provided IdentifierExpression as a current parameter".error();
return -1;
}
示例11: 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);
}
示例12: VisitIdentifierExpression
public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
{
string name = identifierExpression.Identifier;
foreach (VariableDeclaration var in fields) {
if (var.Name == name && !IsLocal(name)) {
identifierExpression.Identifier = prefix + name;
break;
}
}
return base.VisitIdentifierExpression(identifierExpression, data);
}
示例13: IdentifierOnlyInvocation
public void IdentifierOnlyInvocation()
{
// InitializeComponents();
IdentifierExpression identifier = new IdentifierExpression("InitializeComponents");
InvocationExpression invocation = new InvocationExpression(identifier, new List<Expression>());
object output = invocation.AcceptVisitor(new CodeDomVisitor(), null);
Assert.IsTrue(output is CodeMethodInvokeExpression);
CodeMethodInvokeExpression mie = (CodeMethodInvokeExpression)output;
Assert.AreEqual("InitializeComponents", mie.Method.MethodName);
Assert.IsTrue(mie.Method.TargetObject is CodeThisReferenceExpression);
}
示例14: TrackedVisitIdentifierExpression
public override object TrackedVisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
{
if (!IsMethodInvocation(identifierExpression))
{
TypeDeclaration typeDeclaration = (TypeDeclaration) AstUtil.GetParentOfType(identifierExpression, typeof(TypeDeclaration));
string fullName = GetFullName(typeDeclaration);
string key = fullName + "." + identifierExpression.Identifier;
if (CodeBase.References.Contains(key))
identifierExpression.Identifier = (string) CodeBase.References[key];
}
return base.TrackedVisitIdentifierExpression(identifierExpression, data);
}
示例15: CreateGetClassMethodInvocation
private InvocationExpression CreateGetClassMethodInvocation(TypeOfExpression typeOfExpression)
{
FieldReferenceExpression argument = new FieldReferenceExpression(typeOfExpression, "AssemblyQualifiedName");
typeOfExpression.Parent = argument;
List<Expression> arguments = new List<Expression>();
arguments.Add(argument);
IdentifierExpression methodIdentifier = new IdentifierExpression("java.lang.Class");
FieldReferenceExpression methodReference = new FieldReferenceExpression(methodIdentifier, "forName");
InvocationExpression invocationExpression = new InvocationExpression(methodReference, arguments);
argument.Parent = invocationExpression;
methodReference.Parent = invocationExpression;
return invocationExpression;
}