本文整理汇总了C#中ICSharpCode.NRefactory.Ast.FieldDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# FieldDeclaration类的具体用法?C# FieldDeclaration怎么用?C# FieldDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FieldDeclaration类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了FieldDeclaration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: VisitFieldDeclaration
public override object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
{
base.VisitFieldDeclaration(fieldDeclaration, data); // visit methods
foreach(var field in fieldDeclaration.Fields)
Fields.Add(new AstValue<FieldDeclaration>(field.Name, fieldDeclaration, fieldDeclaration.StartLocation, fieldDeclaration.EndLocation));
return null;
}
开发者ID:pusp,项目名称:o2platform,代码行数:7,代码来源:AstDetails.cs
示例2: VisitLocalVariableDeclaration
public override object VisitLocalVariableDeclaration(LocalVariableDeclaration localVariableDeclaration, object data)
{
base.VisitLocalVariableDeclaration(localVariableDeclaration, data);
if ((localVariableDeclaration.Modifier & Modifiers.Static) == Modifiers.Static) {
INode parent = localVariableDeclaration.Parent;
while (parent != null && !IsTypeLevel(parent)) {
parent = parent.Parent;
}
if (parent != null) {
INode type = parent.Parent;
if (type != null) {
int pos = type.Children.IndexOf(parent);
if (pos >= 0) {
FieldDeclaration field = new FieldDeclaration(null);
field.TypeReference = localVariableDeclaration.TypeReference;
field.Modifier = Modifiers.Static;
field.Fields = localVariableDeclaration.Variables;
new PrefixFieldsVisitor(field.Fields, "static_" + GetTypeLevelEntityName(parent) + "_").Run(parent);
type.Children.Insert(pos + 1, field);
RemoveCurrentNode();
}
}
}
}
return null;
}
开发者ID:almazik,项目名称:ILSpy,代码行数:26,代码来源:ToCSharpConvertVisitor.cs
示例3: 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
示例4: VisitFieldDeclaration
public object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
{
for (int i = 0; i < fieldDeclaration.Fields.Count; i++) {
ConvertField(fieldDeclaration.GetTypeForField(i), fieldDeclaration.Fields[i], fieldDeclaration);
}
return null;
}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:7,代码来源:ConvertVisitorTypeMembers.cs
示例5: VisitFieldDeclaration
public override object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
{
if (currentInfo != null)
{
currentInfo.AddField(fieldDeclaration);
}
return base.VisitFieldDeclaration(fieldDeclaration, data);
}
开发者ID:modulexcite,项目名称:magic-1,代码行数:8,代码来源:ValueObjectFinder.cs
示例6: VisitFieldDeclaration
public override object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
{
if ((fieldDeclaration.Modifier & Modifiers.Const) == Modifiers.Const)
{
UnlockWith(fieldDeclaration);
}
return base.VisitFieldDeclaration(fieldDeclaration, data);
}
开发者ID:timdams,项目名称:strokes,代码行数:9,代码来源:ConstKeywordAchievement.cs
示例7: add_Field
public static FieldDeclaration add_Field(this TypeDeclaration typeDeclaration, FieldDeclaration fieldDeclaration)
{
if (typeDeclaration.notNull() && fieldDeclaration.notNull() && typeDeclaration.Children.notNull())
{
//var insertPosition = typeDeclaration.Children.Count;
var insertPosition = 0; // fields are OK to go at the top
typeDeclaration.Children.Insert(insertPosition, fieldDeclaration);
}
return fieldDeclaration;
}
开发者ID:pusp,项目名称:o2platform,代码行数:10,代码来源:FieldDeclaration_ExtensionMethods.cs
示例8: 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;
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:55,代码来源:WrapperGeneratorVisitor.cs
示例9: TrackedVisitFieldDeclaration
public override object TrackedVisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
{
if (AstUtil.ContainsModifier(fieldDeclaration, Modifiers.Transient))
{
AttributeSection ats = CreateAttributeSection("System.NonSerializedAttribute", null);
FieldDeclaration replacedField = fieldDeclaration;
replacedField.Attributes.Add(ats);
ReplaceCurrentNode(replacedField);
}
return base.TrackedVisitFieldDeclaration(fieldDeclaration, data);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:11,代码来源:JavaModifiersTransformer.cs
示例10: HasSimilarName
private bool HasSimilarName(FieldDeclaration fieldDeclaration, IList methods)
{
VariableDeclaration declaration = (VariableDeclaration) fieldDeclaration.Fields[0];
string variableName = declaration.Name;
foreach (MethodDeclaration methodDeclaration in methods)
{
if (variableName == methodDeclaration.Name)
return true;
}
return false;
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:12,代码来源:SameFieldAndMethodNameTransformer.cs
示例11: GenerateCode_Field_CreatesField
public void GenerateCode_Field_CreatesField()
{
CreateCodeGenerator();
var field = new FieldDeclaration(new List<AttributeSection>());
field.TypeReference = new TypeReference("MyClass");
field.Modifier = Modifiers.Public;
field.Fields.Add(new VariableDeclaration("myField"));
string code = codeGenerator.GenerateCode(field, String.Empty);
string expectedCode = "public MyClass myField;\r\n";
Assert.AreEqual(expectedCode, code);
}
开发者ID:rbrunhuber,项目名称:SharpDevelop,代码行数:14,代码来源:CodeGeneratorTests.cs
示例12: TrackedVisitFieldDeclaration
public override object TrackedVisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
{
if (AstUtil.ContainsModifier(fieldDeclaration, Modifiers.Static) && IsJavaPrimitiveType(fieldDeclaration.TypeReference))
{
if (fieldDeclaration.TypeReference.RankSpecifier == null || fieldDeclaration.TypeReference.RankSpecifier.Length == 0)
{
VariableDeclaration field = (VariableDeclaration) fieldDeclaration.Fields[0];
if (field.Initializer != null && (field.Initializer is PrimitiveExpression))
AstUtil.ReplaceModifiers(fieldDeclaration, Modifiers.Static, Modifiers.Const);
}
}
return base.TrackedVisitFieldDeclaration(fieldDeclaration, data);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:14,代码来源:StaticPrimitiveTypeFieldsTransformer.cs
示例13: RenameFeildNameSimilarToMethods
private void RenameFeildNameSimilarToMethods(FieldDeclaration fieldDeclaration, IList methods)
{
if (HasSimilarName(fieldDeclaration, methods))
{
VariableDeclaration declaration = (VariableDeclaration) fieldDeclaration.Fields[0];
TypeDeclaration typeDeclaration = (TypeDeclaration) fieldDeclaration.Parent;
string fullName = GetFullName(typeDeclaration);
string key = fullName + "." + declaration.Name;
string newName = declaration.Name + "_Field";
CodeBase.References.Add(key, newName);
declaration.Name = newName;
}
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:15,代码来源:SameFieldAndMethodNameTransformer.cs
示例14: 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
示例15: IsArrayCreation
private bool IsArrayCreation(FieldDeclaration fieldDeclaration)
{
VariableDeclaration field = (VariableDeclaration) fieldDeclaration.Fields[0];
if ((field.Initializer is ArrayCreateExpression) && (fieldDeclaration.TypeReference.RankSpecifier.Length > 0))
{
ArrayCreateExpression arrayCreateExpression = (ArrayCreateExpression) field.Initializer;
if (arrayCreateExpression.Arguments.Count > 0)
{
foreach (Expression argument in arrayCreateExpression.Arguments)
{
if (!(argument is PrimitiveExpression))
return true;
}
}
}
return false;
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:17,代码来源:FieldInitializerTransformer.cs
示例16: VisitFieldDeclaration
public override object VisitFieldDeclaration(FieldDeclaration fieldsDeclaration, object data)
{
Contract.Requires(fieldsDeclaration != null);
fieldsDeclaration.AcceptChildren(this, data);
if (fieldsDeclaration.Attributes.Any(s => s.Attributes.Any(a => a.Name == "DataMember")))
{
foreach (var fieldDeclaration in fieldsDeclaration.Fields)
{
var jsProperty = new JsProperty()
{
OfType = fieldsDeclaration.TypeReference.GenericTypes.Count == 0 ?
fieldsDeclaration.TypeReference.Type :
fieldsDeclaration.TypeReference.GenericTypes[0].Type,
Name = fieldDeclaration.Name,
IsArray = (fieldsDeclaration.TypeReference.GenericTypes.Count > 0 ||
fieldsDeclaration.TypeReference.IsArrayType)
};
CurrentParent.Properties.Add(jsProperty);
// I can't figure out what this part is for, but I'm preserving it anyway
if (fieldsDeclaration.Attributes.Count > 0)
{
var jsAttributes = new List<JsAttribute>();
foreach (var attribute in fieldsDeclaration.Attributes)
{
var a = attribute.Attributes[0];
jsAttributes.Add(new JsAttribute()
{
Name = a.Name
});
}
jsProperty.Attributes = jsAttributes;
}
}
}
return null;
}
开发者ID:chinaniit,项目名称:KnockoutGenerator,代码行数:43,代码来源:AstVisitor.cs
示例17: ConvertField
void ConvertField(TypeReference typeRef, VariableDeclaration variable, FieldDeclaration fieldDeclaration)
{
B.TypeMember m;
if (currentType is B.EnumDefinition) {
if (variable.Initializer.IsNull) {
m = new B.EnumMember(GetLexicalInfo(fieldDeclaration));
} else {
PrimitiveExpression p = variable.Initializer as PrimitiveExpression;
if (p == null || !(p.Value is int)) {
AddError(fieldDeclaration, "enum member initializer must be integer value");
return;
}
m = new B.EnumMember(GetLexicalInfo(fieldDeclaration), new B.IntegerLiteralExpression((int)p.Value));
}
} else {
m = new B.Field(GetLexicalInfo(fieldDeclaration), ConvertTypeReference(typeRef), ConvertExpression(variable.Initializer));
m.Modifiers = ConvertModifier(fieldDeclaration, B.TypeMemberModifiers.Private);
}
m.Name = variable.Name;
ConvertAttributes(fieldDeclaration.Attributes, m.Attributes);
if (currentType != null) currentType.Members.Add(m);
}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:22,代码来源:ConvertVisitorTypeMembers.cs
示例18: EnumMemberDecl
void EnumMemberDecl(
//#line 774 "VBNET.ATG"
out FieldDeclaration f) {
//#line 776 "VBNET.ATG"
Expression expr = null;List<AttributeSection> attributes = new List<AttributeSection>();
AttributeSection section = null;
VariableDeclaration varDecl = null;
while (la.kind == 40) {
AttributeSection(
//#line 780 "VBNET.ATG"
out section);
//#line 780 "VBNET.ATG"
attributes.Add(section);
}
Identifier();
//#line 783 "VBNET.ATG"
f = new FieldDeclaration(attributes);
varDecl = new VariableDeclaration(t.val);
f.Fields.Add(varDecl);
f.StartLocation = varDecl.StartLocation = t.Location;
if (la.kind == 20) {
lexer.NextToken();
Expr(
//#line 788 "VBNET.ATG"
out expr);
//#line 788 "VBNET.ATG"
varDecl.Initializer = expr;
}
//#line 789 "VBNET.ATG"
f.EndLocation = varDecl.EndLocation = t.EndLocation;
EndOfStmt();
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:39,代码来源:Parser.cs
示例19: StructureMemberDecl
//.........这里部分代码省略.........
} else if (StartOf(16)) {
if (la.kind == 37) {
lexer.NextToken();
if (StartOf(6)) {
FormalParameterList(
//#line 1047 "VBNET.ATG"
p);
}
Expect(38);
}
} else SynErr(260);
if (la.kind == 136) {
ImplementsClause(
//#line 1049 "VBNET.ATG"
out implementsClause);
}
//#line 1051 "VBNET.ATG"
eventDeclaration = new EventDeclaration {
Name = name, TypeReference = type, Modifier = m.Modifier,
Parameters = p, Attributes = attributes, InterfaceImplementations = implementsClause,
StartLocation = m.GetDeclarationLocation(startPos),
EndLocation = t.EndLocation
};
AddChild(eventDeclaration);
EndOfStmt();
break;
}
case 2: case 58: case 62: case 64: case 65: case 66: case 67: case 70: case 87: case 104: case 107: case 116: case 121: case 126: case 133: case 139: case 143: case 146: case 147: case 170: case 176: case 178: case 184: case 203: case 212: case 213: case 223: case 224: case 230: {
//#line 1062 "VBNET.ATG"
m.Check(Modifiers.Fields);
FieldDeclaration fd = new FieldDeclaration(attributes, null, m.Modifier);
IdentifierForFieldDeclaration();
//#line 1065 "VBNET.ATG"
string name = t.val;
//#line 1066 "VBNET.ATG"
fd.StartLocation = m.GetDeclarationLocation(t.Location);
VariableDeclaratorPartAfterIdentifier(
//#line 1068 "VBNET.ATG"
variableDeclarators, name);
while (la.kind == 22) {
lexer.NextToken();
VariableDeclarator(
//#line 1069 "VBNET.ATG"
variableDeclarators);
}
EndOfStmt();
//#line 1072 "VBNET.ATG"
fd.EndLocation = t.EndLocation;
fd.Fields = variableDeclarators;
AddChild(fd);
break;
}
case 88: {
//#line 1077 "VBNET.ATG"
m.Check(Modifiers.Fields);
lexer.NextToken();
开发者ID:Altaxo,项目名称:Altaxo,代码行数:66,代码来源:Parser.cs
示例20: TrackedVisitFieldDeclaration
public override object TrackedVisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
{
return null;
}
开发者ID:L3tum,项目名称:BesiegeScriptingMod,代码行数:4,代码来源:NRefactoryToPythonConverter.cs
注:本文中的ICSharpCode.NRefactory.Ast.FieldDeclaration类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论