本文整理汇总了C#中ICSharpCode.NRefactory.Ast.IdentifierExpression类的典型用法代码示例。如果您正苦于以下问题:C# IdentifierExpression类的具体用法?C# IdentifierExpression怎么用?C# IdentifierExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IdentifierExpression类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了IdentifierExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:29,代码来源:InvocationExpression_ExtensionMethods.cs
示例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);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:26,代码来源:InnerClassTransformer.cs
示例3: VisitIdentifierExpression
public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
{
if (nameComparer.Equals(identifierExpression.Identifier, from)) {
identifierExpression.Identifier = to;
}
return base.VisitIdentifierExpression(identifierExpression, data);
}
开发者ID:XQuantumForceX,项目名称:Reflexil,代码行数:7,代码来源:RenameIdentifierVisitor.cs
示例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;
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:27,代码来源:TypeMapper.cs
示例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;
}
开发者ID:pusp,项目名称:o2platform,代码行数:8,代码来源:MemberReferenceExpression_ExtensionMethods.cs
示例6: VisitIdentifierExpression
public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
{
if (Compare(identifierExpression))
{
identifiers.Add(identifierExpression);
}
return base.VisitIdentifierExpression(identifierExpression, data);
}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:8,代码来源:FindSpecificCatchClauses.cs
示例7: VisitIdentifierExpression
public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
{
if (RenameTable.ContainsKey(identifierExpression.Identifier))
{
identifierExpression.Identifier = RenameTable[identifierExpression.Identifier];
}
return null;
}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:8,代码来源:RenameLocalVariableRefactoring.cs
示例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);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:9,代码来源:SystemFieldsTransformer.cs
示例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);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:10,代码来源:AccessorRefactoring.cs
示例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;
}
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:10,代码来源:ObjectCreateExpression_ExtensionMethod.cs
示例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);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:10,代码来源:SameProjectAndExternalTypeNameTransformer.cs
示例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);
}
开发者ID:pusp,项目名称:o2platform,代码行数:11,代码来源:PrefixFieldsVisitor.cs
示例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);
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:11,代码来源:InvocationExpressionTest.cs
示例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);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:12,代码来源:SameFieldAndMethodUsagesTransformer.cs
示例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;
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:13,代码来源:DotClassTransformer.cs
示例16: 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);
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:15,代码来源:ConstructorCodeGenerator.cs
示例17: TrackedVisitIdentifierExpression
public override object TrackedVisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
{
if (localVariables.Contains(identifierExpression.Identifier))
{
BlockStatement blockStatement = (BlockStatement) AstUtil.GetParentOfType(identifierExpression, typeof(BlockStatement));
int hashCode = blockStatement.GetHashCode();
if (hashCode != GetScopeHashCode(identifierExpression.Identifier))
{
string renamedVariableName = GetModifiedName(blockStatement, identifierExpression.Identifier);
if (renamedVariableName != null)
identifierExpression.Identifier = renamedVariableName;
}
}
return base.TrackedVisitIdentifierExpression(identifierExpression, data);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:15,代码来源:RenameRepeatedVariableTransformer.cs
示例18: GenerateCode
public override void GenerateCode(List<AbstractNode> nodes, IList items)
{
TypeReference intReference = new TypeReference("System.Int32");
MethodDeclaration method = new MethodDeclaration("GetHashCode", Modifiers.Public | Modifiers.Override, intReference, null, null);
Expression expr = CallGetHashCode(new IdentifierExpression(currentClass.Fields[0].Name));
for (int i = 1; i < currentClass.Fields.Count; i++) {
IdentifierExpression identifier = new IdentifierExpression(currentClass.Fields[i].Name);
expr = new BinaryOperatorExpression(expr, BinaryOperatorType.ExclusiveOr,
CallGetHashCode(identifier));
}
method.Body = new BlockStatement();
method.Body.AddChild(new ReturnStatement(expr));
nodes.Add(method);
TypeReference boolReference = new TypeReference("System.Boolean");
TypeReference objectReference = new TypeReference("System.Object");
method = new MethodDeclaration("Equals", Modifiers.Public | Modifiers.Override, boolReference, null, null);
method.Parameters.Add(new ParameterDeclarationExpression(objectReference, "obj"));
method.Body = new BlockStatement();
TypeReference currentType = ConvertType(currentClass.DefaultReturnType);
expr = new TypeOfIsExpression(new IdentifierExpression("obj"), currentType);
expr = new ParenthesizedExpression(expr);
expr = new UnaryOperatorExpression(expr, UnaryOperatorType.Not);
method.Body.AddChild(new IfElseStatement(expr, new ReturnStatement(new PrimitiveExpression(false, "false"))));
expr = new BinaryOperatorExpression(new ThisReferenceExpression(),
BinaryOperatorType.Equality,
new IdentifierExpression("obj"));
method.Body.AddChild(new IfElseStatement(expr, new ReturnStatement(new PrimitiveExpression(true, "true"))));
VariableDeclaration var = new VariableDeclaration("my" + currentClass.Name,
new CastExpression(currentType, new IdentifierExpression("obj"), CastType.Cast),
currentType);
method.Body.AddChild(new LocalVariableDeclaration(var));
expr = TestEquality(var.Name, currentClass.Fields[0]);
for (int i = 1; i < currentClass.Fields.Count; i++) {
expr = new BinaryOperatorExpression(expr, BinaryOperatorType.LogicalAnd,
TestEquality(var.Name, currentClass.Fields[i]));
}
method.Body.AddChild(new ReturnStatement(expr));
nodes.Add(method);
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:47,代码来源:EqualsCodeGenerator.cs
示例19: 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);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:46,代码来源:FieldInitializerTransformer.cs
示例20: 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;
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:19,代码来源:ReferenceTransformer.cs
注:本文中的ICSharpCode.NRefactory.Ast.IdentifierExpression类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论