本文整理汇总了C#中ICSharpCode.NRefactory.Ast.AssignmentExpression类的典型用法代码示例。如果您正苦于以下问题:C# AssignmentExpression类的具体用法?C# AssignmentExpression怎么用?C# AssignmentExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AssignmentExpression类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了AssignmentExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitAssignmentExpression
public virtual object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data) {
Debug.Assert((assignmentExpression != null));
Debug.Assert((assignmentExpression.Left != null));
Debug.Assert((assignmentExpression.Right != null));
assignmentExpression.Left.AcceptVisitor(this, data);
return assignmentExpression.Right.AcceptVisitor(this, data);
}
示例2: VisitAssignmentExpression
public override object VisitAssignmentExpression(AssignmentExpression assignment, object data)
{
IdentifierExpression ident = assignment.Left as IdentifierExpression;
BinaryOperatorExpression binary = assignment.Right as BinaryOperatorExpression;
if (ident != null && binary != null) {
IdentifierExpression binaryLeft = binary.Left as IdentifierExpression;
if (binaryLeft != null &&
binaryLeft.Identifier == ident.Identifier) {
if (binary.Right is PrimitiveExpression &&
1.Equals((binary.Right as PrimitiveExpression).Value)) {
if (binary.Op == BinaryOperatorType.Add) {
ReplaceCurrentNode(new UnaryOperatorExpression(ident, UnaryOperatorType.PostIncrement));
}
if (binary.Op == BinaryOperatorType.Subtract) {
ReplaceCurrentNode(new UnaryOperatorExpression(ident, UnaryOperatorType.PostDecrement));
}
} else {
if (binary.Op == BinaryOperatorType.Add) {
ReplaceCurrentNode(new AssignmentExpression(ident, AssignmentOperatorType.Add, binary.Right));
}
if (binary.Op == BinaryOperatorType.Subtract) {
ReplaceCurrentNode(new AssignmentExpression(ident, AssignmentOperatorType.Subtract, binary.Right));
}
}
return null;
}
}
return null;
}
示例3: VisitAssignmentExpression
public override object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data)
{
tw.WriteStartElement("AssignmentExpression");
tw.WriteAttributeString("Op", assignmentExpression.Op.ToString());
base.VisitAssignmentExpression(assignmentExpression, data);
tw.WriteEndElement();
return null;
}
示例4: VisitAssignmentExpression
public override object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data)
{
var primitiveExpression = assignmentExpression.Right as PrimitiveExpression;
if (primitiveExpression != null)
{
}
return base.VisitAssignmentExpression(assignmentExpression, data);
}
示例5: VisitAssignmentExpression
public override object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data)
{
if (!hasAssignment) {
if (assignmentExpression.Left is IdentifierExpression) {
hasAssignment = (((IdentifierExpression)assignmentExpression.Left).Identifier == name) &&
(assignmentExpression.StartLocation >= startRange && assignmentExpression.EndLocation <= endRange);
}
}
return base.VisitAssignmentExpression(assignmentExpression, data);
}
示例6: VisitTypeDeclaration
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
base.VisitTypeDeclaration(typeDeclaration, data); // visit methods
typeDeclaration.Attributes.Clear();
typeDeclaration.BaseTypes.Clear();
// add constructor accepting the wrapped object and the field holding the object
FieldDeclaration fd = new FieldDeclaration(null, // no attributes
new TypeReference(typeDeclaration.Name),
Modifiers.Private);
fd.Fields.Add(new VariableDeclaration("wrappedObject"));
typeDeclaration.AddChild(fd);
typeDeclaration.Name += "Wrapper";
if (typeDeclaration.Type == ClassType.Interface) {
typeDeclaration.Type = ClassType.Class;
typeDeclaration.Name = typeDeclaration.Name.Substring(1);
}
ConstructorDeclaration cd = new ConstructorDeclaration(typeDeclaration.Name,
Modifiers.Public,
new List<ParameterDeclarationExpression>(),
null);
cd.Parameters.Add(new ParameterDeclarationExpression(fd.TypeReference,
"wrappedObject"));
// this.wrappedObject = wrappedObject;
Expression fieldReference = new MemberReferenceExpression(new ThisReferenceExpression(),
"wrappedObject");
Expression assignment = new AssignmentExpression(fieldReference,
AssignmentOperatorType.Assign,
new IdentifierExpression("wrappedObject"));
cd.Body = new BlockStatement();
cd.Body.AddChild(new ExpressionStatement(assignment));
typeDeclaration.AddChild(cd);
for (int i = 0; i < typeDeclaration.Children.Count; i++) {
object child = typeDeclaration.Children[i];
if (child is MethodDeclaration) {
MethodDeclaration method = (MethodDeclaration)child;
if (method.Parameters.Count == 0 &&
(method.Name.StartsWith("Is") || method.Name.StartsWith("Get")))
{
// replace the method with a property
PropertyDeclaration prop = new PropertyDeclaration(method.Modifier,
method.Attributes,
method.Name,
null);
prop.TypeReference = method.TypeReference;
prop.GetRegion = new PropertyGetRegion(method.Body, null);
typeDeclaration.Children[i] = prop;
}
}
}
return null;
}
示例7: VisitAssignmentExpression
public override object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data)
{
// Calculate right first so that left does not get invalidated by its calculation
Value right = ((Value)assignmentExpression.Right.AcceptVisitor(this, null)).GetPermanentReference();
Value left = (Value)assignmentExpression.Left.AcceptVisitor(this, null);
if (!left.IsReference && left.Type.FullName != right.Type.FullName) {
throw new GetValueException(string.Format("Type {0} expected, {1} seen", left.Type.FullName, right.Type.FullName));
}
left.SetValue(right);
return right;
}
示例8: GetVariableNameFromAssignment
string GetVariableNameFromAssignment(AssignmentExpression assignment)
{
if (assignment == null)
return null;
var identifier = assignment.Left as IdentifierExpression;
if (identifier == null)
return null;
if (assignment.Right is ObjectCreateExpression)
// // don't offer action for "a = new Foo()"
return null;
return identifier.Identifier;
}
示例9: GetVariableNameFromAssignment
string GetVariableNameFromAssignment(AssignmentExpression assignment)
{
if (assignment == null)
return null;
var identifier = assignment.Left as IdentifierExpression;
if (identifier == null)
return null;
if ((!ExpressionCanBeNull(assignment.Right)) || ExpressionIsValueType(assignment.Right))
// don't offer action where it makes no sense
return null;
return identifier.Identifier;
}
示例10: VisitAssignmentExpression
public override object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data)
{
base.VisitAssignmentExpression(assignmentExpression, data);
if (assignmentExpression.Op == AssignmentOperatorType.Assign && !(assignmentExpression.Parent is ExpressionStatement)) {
AddInlineAssignHelper();
ReplaceCurrentNode(
new InvocationExpression(
new IdentifierExpression("InlineAssignHelper"),
new List<Expression>().add(assignmentExpression.Left)
.add(assignmentExpression.Right)));
}
return null;
}
示例11: GenerateCode
public override void GenerateCode(List<AbstractNode> nodes, IList items)
{
ConstructorDeclaration ctor = new ConstructorDeclaration(currentClass.Name, Modifiers.Public, null, null);
ctor.Body = new BlockStatement();
foreach (FieldWrapper w in items) {
string parameterName = codeGen.GetParameterName(w.Field.Name);
ctor.Parameters.Add(new ParameterDeclarationExpression(ConvertType(w.Field.ReturnType),
parameterName));
Expression left = new MemberReferenceExpression(new ThisReferenceExpression(), w.Field.Name);
Expression right = new IdentifierExpression(parameterName);
Expression expr = new AssignmentExpression(left, AssignmentOperatorType.Assign, right);
ctor.Body.AddChild(new ExpressionStatement(expr));
}
nodes.Add(ctor);
}
示例12: VisitAssignmentExpression
public override object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data)
{
if(assignmentExpression.Right is PrimitiveExpression)
{
PrimitiveExpression prim = (PrimitiveExpression) assignmentExpression.Right;
int number;
if (int.TryParse(prim.StringValue, out number))
{
if (number == 666)
UnlockWith(assignmentExpression);
}
}
return base.VisitAssignmentExpression(assignmentExpression, data);
}
示例13: TrackedVisitFieldDeclaration
public override object TrackedVisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
{
VariableDeclaration field = (VariableDeclaration) fieldDeclaration.Fields[0];
TypeDeclaration typeDeclaration = (TypeDeclaration) fieldDeclaration.Parent;
NodeTypeExistenceVisitor nodeTypeExistenceVisitor = new NodeTypeExistenceVisitor(typeof(ThisReferenceExpression));
NodeTypeExistenceVisitor indexerNodeExistenceVisitor = new NodeTypeExistenceVisitor(typeof(IndexerExpression));
field.Initializer.AcceptVisitor(nodeTypeExistenceVisitor, null);
field.Initializer.AcceptVisitor(indexerNodeExistenceVisitor, null);
if (field.Initializer != null && (field.Initializer is InvocationExpression || IsArrayCreation(fieldDeclaration) || nodeTypeExistenceVisitor.Contains || indexerNodeExistenceVisitor.Contains)
&& !AstUtil.ContainsModifier(fieldDeclaration, Modifiers.Static))
{
IList constructors = AstUtil.GetChildrenWithType(typeDeclaration, typeof(ConstructorDeclaration));
IdentifierExpression left = new IdentifierExpression(field.Name);
Expression right = field.Initializer;
AssignmentExpression assignmentExpression = new AssignmentExpression(left, AssignmentOperatorType.Assign, right);
ExpressionStatement ExpressionStatement = new ExpressionStatement(assignmentExpression);
field.Initializer = null;
ConstructorDeclaration constructorDeclaration = null;
ExpressionStatement.Parent = constructorDeclaration;
foreach (ConstructorDeclaration consDec in constructors)
{
if (!AstUtil.ContainsModifier(consDec, Modifiers.Static))
{
if (consDec.Parameters.Count == 0)
{
constructorDeclaration = consDec;
constructorDeclaration.Body.Children.Add(ExpressionStatement);
constructorDeclaration.Parent = typeDeclaration;
return base.TrackedVisitFieldDeclaration(fieldDeclaration, data);
}
else
{
consDec.ConstructorInitializer = new ConstructorInitializer();
consDec.ConstructorInitializer.ConstructorInitializerType = ConstructorInitializerType.This;
}
}
}
constructorDeclaration = GetConstructor(ExpressionStatement, typeDeclaration);
constructorDeclaration.Parent = typeDeclaration;
return base.TrackedVisitFieldDeclaration(fieldDeclaration, data);
}
return base.TrackedVisitFieldDeclaration(fieldDeclaration, data);
}
示例14: VisitAssignmentExpression
public override object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data)
{
base.VisitAssignmentExpression(assignmentExpression, data);
if (vbMyFormsClass != null) {
TypeResolveResult trr = Resolve(assignmentExpression.Right) as TypeResolveResult;
if (trr != null && trr.ResolvedClass != null) {
foreach (IProperty p in vbMyFormsClass.Properties) {
if (p.ReturnType.FullyQualifiedName == trr.ResolvedClass.FullyQualifiedName) {
assignmentExpression.Right = MakeFieldReferenceExpression("My.MyProject.Forms." + p.Name);
break;
}
}
}
}
return null;
}
示例15: VisitAssignmentExpression
public override object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data)
{
if (assignmentExpression.Left is MemberReferenceExpression)
{
MemberReferenceExpression left = (MemberReferenceExpression)assignmentExpression.Left;
if (eventVars.Contains(left.MemberName)) // I don't check against correct type yet
{
if (assignmentExpression.Right is ObjectCreateExpression)
{
ObjectCreateExpression right = (ObjectCreateExpression)assignmentExpression.Right;
if (right.CreateType.Type.Contains("EventHandler") && assignmentExpression.Op == AssignmentOperatorType.Add)
UnlockWith(assignmentExpression); // Only works when using the implicit += new SomeEventHandler() syntax
}
}
}
return base.VisitAssignmentExpression(assignmentExpression, data);
}