本文整理汇总了C#中ICSharpCode.NRefactory.Ast.VariableDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# VariableDeclaration类的具体用法?C# VariableDeclaration怎么用?C# VariableDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VariableDeclaration类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了VariableDeclaration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: add_Variable
public static VariableDeclaration add_Variable(this BlockStatement blockDeclaration, string name, Expression expression, TypeReference typeReference)
{
var variableDeclaration = new VariableDeclaration(name, expression) {TypeReference = typeReference};
var localVariableDeclaration = new LocalVariableDeclaration(variableDeclaration);
blockDeclaration.append(localVariableDeclaration);
return variableDeclaration;
}
开发者ID:SiGhTfOrbACQ,项目名称:O2.Platform.Projects,代码行数:7,代码来源:VariableDeclaration_ExtensionMethods.cs
示例2: VisitVariableDeclaration
public override object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
{
if (nameComparer.Equals(from, variableDeclaration.Name)) {
variableDeclaration.Name = to;
}
return base.VisitVariableDeclaration(variableDeclaration, data);
}
开发者ID:XQuantumForceX,项目名称:Reflexil,代码行数:7,代码来源:RenameIdentifierVisitor.cs
示例3: VisitVariableDeclaration
public override object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
{
// process local variables only
if (fields.Contains(variableDeclaration)) {
return null;
}
curBlock.Add(variableDeclaration.Name);
return base.VisitVariableDeclaration(variableDeclaration, data);
}
开发者ID:XQuantumForceX,项目名称:Reflexil,代码行数:9,代码来源:PrefixFieldsVisitor.cs
示例4: Contains
bool Contains(VariableDeclaration varDecl)
{
foreach (VariableDeclaration v in this.unneededVarDecls) {
if (v.Name == varDecl.Name) {
return true;
}
}
return false;
}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:10,代码来源:ReplaceUnnecessaryVariableDeclarationsTransformer.cs
示例5: VisitVariableDeclaration
public override object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
{
var objectCreateExpression = variableDeclaration.Initializer as ObjectCreateExpression;
if (objectCreateExpression != null && objectCreateExpression.IsAnonymousType)
{
UnlockWith(variableDeclaration);
}
return base.VisitVariableDeclaration(variableDeclaration, data);
}
开发者ID:timdams,项目名称:strokes,代码行数:10,代码来源:AnonymousObjectAchievement.cs
示例6: 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
示例7: TrackedVisitVariableDeclaration
public override object TrackedVisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
{
BlockStatement blockStatement = (BlockStatement) AstUtil.GetParentOfType(variableDeclaration, typeof(BlockStatement));
if (blockStatement != null)
{
int hashCode = blockStatement.GetHashCode();
if (!(blockStatement.Parent is MethodDeclaration) && !localVariables.Contains(variableDeclaration.Name))
localVariables.Add(variableDeclaration.Name, variableDeclaration);
else if (HasConflict(variableDeclaration))
{
string newName = renamer.GetNewName(variableDeclaration.Name);
renamedVariables.Add(variableDeclaration.Name + "_" + hashCode, newName);
variableDeclaration.Name = newName;
}
}
return base.TrackedVisitVariableDeclaration(variableDeclaration, data);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:17,代码来源:RenameRepeatedVariableTransformer.cs
示例8: VisitVariableDeclaration
public override object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
{
string[] foulwords= new string[]
{
"meh","blah", "pft", "rrrr","blib","blab", "blub","lol","uhu","aaah"
};//if anyone wants to go nuts: feel free to add more :)
foreach (var foulword in foulwords)
{
if (System.Text.RegularExpressions.Regex.Matches(variableDeclaration.Name, foulword).Count > 0)
cursecount++;
}
if (cursecount>5)
UnlockWith(variableDeclaration);
return base.VisitVariableDeclaration(variableDeclaration, data);
}
开发者ID:timdams,项目名称:strokes,代码行数:18,代码来源:SpeechlessAchievement.cs
示例9: VisitVariableDeclaration
public override object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
{
string[] foulwords= new string[]
{
"fuck", "shit", "crap", "bollocks"
};//if anyone wants to go nuts: feel free to add more :)
foreach (var foulword in foulwords)
{
if (System.Text.RegularExpressions.Regex.Matches(variableDeclaration.Name, foulword).Count > 0)
cursecount++;
}
if (cursecount>5)
UnlockWith(variableDeclaration);
return base.VisitVariableDeclaration(variableDeclaration, data);
}
开发者ID:timdams,项目名称:strokes,代码行数:18,代码来源:CurseALotAchievement.cs
示例10: CreateCaller
protected static Statement CreateCaller(AttributedNode parent, MethodDeclaration method, VariableDeclaration returnVariable)
{
Statement caller;
InvocationExpression expr = new InvocationExpression(new IdentifierExpression(method.Name), CreateArgumentExpressions(method.Parameters));
if (method.TypeReference.Type != "System.Void") {
TypeReference parentType = GetParentReturnType(parent);
if (method.TypeReference == parentType)
caller = new ReturnStatement(expr);
else {
returnVariable.Initializer = expr;
caller = new LocalVariableDeclaration(returnVariable);
}
} else {
caller = new ExpressionStatement(expr);
}
return caller;
}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:18,代码来源:MethodExtractorBase.cs
示例11: TrackedVisitArrayCreateExpression
public override object TrackedVisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data)
{
string variableName = GetVariableName(arrayCreateExpression);
List<Expression> initializerList = arrayCreateExpression.ArrayInitializer.CreateExpressions;
Expression replacedExpression = arrayCreateExpression;
if (initializerList.Count > 0 && initializerList[0] is CollectionInitializerExpression && data is InsertionBlockData)
{
ArrayCreateExpression replacedArrayCreateExpression = arrayCreateExpression;
replacedArrayCreateExpression.ArrayInitializer = null;
replacedArrayCreateExpression.Arguments.Add(new PrimitiveExpression(initializerList.Count, initializerList.Count.ToString()));
string arrayTypeName = arrayCreateExpression.CreateType.Type + "s";
Position position = Position.After;
if (variableName == null)
{
variableName = arrayTypeName;
position = Position.Before;
}
List<Statement> initStatements = GetArrayInitStatements(replacedArrayCreateExpression, variableName, initializerList);
InsertionBlockData insertionBlockData = (InsertionBlockData) data;
insertionBlockData.Block = (BlockStatement) AstUtil.GetParentOfType(replacedArrayCreateExpression, typeof(BlockStatement));
insertionBlockData.BlockChildIndex = GetBlockChildIndex(replacedArrayCreateExpression, position);
insertionBlockData.Statements = initStatements;
if (variableName == arrayTypeName)
{
IdentifierExpression identifierExpression = new IdentifierExpression(variableName);
replacedExpression = identifierExpression;
VariableDeclaration variableDeclaration = new VariableDeclaration(variableName, arrayCreateExpression);
LocalVariableDeclaration localVariable = new LocalVariableDeclaration(variableDeclaration);
localVariable.TypeReference = arrayCreateExpression.CreateType;
initStatements.Insert(0, localVariable);
}
ReplaceCurrentNode(replacedExpression);
}
return base.TrackedVisitArrayCreateExpression(arrayCreateExpression, data);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:42,代码来源:ArrayInitializerTransformer.cs
示例12: 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
示例13: ConstantDeclarator
void ConstantDeclarator(
#line 1381 "VBNET.ATG"
List<VariableDeclaration> constantDeclaration) {
#line 1383 "VBNET.ATG"
Expression expr = null;
TypeReference type = null;
string name = String.Empty;
Location location;
Identifier();
#line 1388 "VBNET.ATG"
name = t.val; location = t.Location;
if (la.kind == 50) {
lexer.NextToken();
TypeName(
#line 1389 "VBNET.ATG"
out type);
}
Expect(10);
Expr(
#line 1390 "VBNET.ATG"
out expr);
#line 1392 "VBNET.ATG"
VariableDeclaration f = new VariableDeclaration(name, expr);
f.TypeReference = type;
f.StartLocation = location;
constantDeclaration.Add(f);
}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:32,代码来源:Parser.cs
示例14: EnumMemberDecl
void EnumMemberDecl(
#line 743 "VBNET.ATG"
out FieldDeclaration f) {
#line 745 "VBNET.ATG"
Expression expr = null;List<AttributeSection> attributes = new List<AttributeSection>();
AttributeSection section = null;
VariableDeclaration varDecl = null;
while (la.kind == 28) {
AttributeSection(
#line 749 "VBNET.ATG"
out section);
#line 749 "VBNET.ATG"
attributes.Add(section);
}
Identifier();
#line 752 "VBNET.ATG"
f = new FieldDeclaration(attributes);
varDecl = new VariableDeclaration(t.val);
f.Fields.Add(varDecl);
f.StartLocation = varDecl.StartLocation = t.Location;
if (la.kind == 10) {
lexer.NextToken();
Expr(
#line 757 "VBNET.ATG"
out expr);
#line 757 "VBNET.ATG"
varDecl.Initializer = expr;
}
EndOfStmt();
}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:36,代码来源:Parser.cs
示例15: TrackedVisitVariableDeclaration
public override object TrackedVisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
{
// Resolving anything here only makes sense
// if this declaration actually has an initializer.
if (variableDeclaration.Initializer.IsNull) {
return base.TrackedVisitVariableDeclaration(variableDeclaration, data);
}
LocalVariableDeclaration localVariableDeclaration = data as LocalVariableDeclaration;
if (this.isLocalVariable && localVariableDeclaration != null) {
if (variableDeclaration.Name == this.resourceManagerMember.Name) {
// Make sure we got the right declaration by comparing the positions.
// Both must have the same start position.
if (localVariableDeclaration.StartLocation.X == this.resourceManagerMember.Region.BeginColumn && localVariableDeclaration.StartLocation.Y == this.resourceManagerMember.Region.BeginLine) {
#if DEBUG
LoggingService.Debug("ResourceToolkit: BclNRefactoryResourceResolver found local variable declaration: "+localVariableDeclaration.ToString()+" at "+localVariableDeclaration.StartLocation.ToString());
#endif
data = true;
}
}
}
FieldDeclaration fieldDeclaration = data as FieldDeclaration;
if (!this.isLocalVariable && fieldDeclaration != null) {
// Make sure we got the right declaration by comparing the positions.
// Both must have the same start position.
if (variableDeclaration.Name == this.resourceManagerMember.Name &&
fieldDeclaration.StartLocation.X == this.resourceManagerMember.Region.BeginColumn && fieldDeclaration.StartLocation.Y == this.resourceManagerMember.Region.BeginLine) {
#if DEBUG
LoggingService.Debug("ResourceToolkit: BclNRefactoryResourceResolver found field declaration: "+fieldDeclaration.ToString()+" at "+fieldDeclaration.StartLocation.ToString());
#endif
data = true;
} else {
// This field might be referred to by a property
// that we are looking for.
// This association is cached in the
// resourceManagerFieldAccessedByProperty field
// to improve performance.
this.TryResolveResourceManagerProperty();
if (this.resourceManagerFieldAccessedByProperty != null &&
fieldDeclaration.StartLocation.X == this.resourceManagerFieldAccessedByProperty.Region.BeginColumn &&
fieldDeclaration.StartLocation.Y == this.resourceManagerFieldAccessedByProperty.Region.BeginLine) {
#if DEBUG
LoggingService.Debug("ResourceToolkit: BclNRefactoryResourceResolver found field declaration (via associated property): "+fieldDeclaration.ToString()+" at "+fieldDeclaration.StartLocation.ToString());
#endif
data = true;
}
}
}
return base.TrackedVisitVariableDeclaration(variableDeclaration, data);
}
开发者ID:ichengzi,项目名称:SharpDevelop,代码行数:60,代码来源:BclNRefactoryResourceResolver.cs
示例16: VisitVariableDeclaration
public override object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
{
if (this.CheckNode(variableDeclaration)) {
return null;
}
return base.VisitVariableDeclaration(variableDeclaration, data);
}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:7,代码来源:MemberFindAstVisitor.cs
示例17: LocalVariableDeclarator
void LocalVariableDeclarator(
#line 1515 "cs.ATG"
out VariableDeclaration var) {
#line 1516 "cs.ATG"
Expression expr = null;
Identifier();
#line 1518 "cs.ATG"
var = new VariableDeclaration(t.val); var.StartLocation = t.Location;
if (la.kind == 3) {
lexer.NextToken();
VariableInitializer(
#line 1519 "cs.ATG"
out expr);
#line 1519 "cs.ATG"
var.Initializer = expr;
}
#line 1520 "cs.ATG"
var.EndLocation = t.EndLocation;
}
开发者ID:pluraldj,项目名称:SharpDevelop,代码行数:23,代码来源:Parser.cs
示例18: VariableDeclarator
void VariableDeclarator(
#line 1310 "cs.ATG"
FieldDeclaration parentFieldDeclaration) {
#line 1311 "cs.ATG"
Expression expr = null;
Identifier();
#line 1313 "cs.ATG"
VariableDeclaration f = new VariableDeclaration(t.val); f.StartLocation = t.Location;
if (la.kind == 3) {
lexer.NextToken();
VariableInitializer(
#line 1314 "cs.ATG"
out expr);
#line 1314 "cs.ATG"
f.Initializer = expr;
}
#line 1315 "cs.ATG"
f.EndLocation = t.EndLocation; SafeAdd(parentFieldDeclaration, parentFieldDeclaration.Fields, f);
}
开发者ID:pluraldj,项目名称:SharpDevelop,代码行数:23,代码来源:Parser.cs
示例19: ConstantDeclarator
void ConstantDeclarator(
//#line 1438 "VBNET.ATG"
List<VariableDeclaration> constantDeclaration) {
//#line 1440 "VBNET.ATG"
Expression expr = null;
TypeReference type = null;
string name = String.Empty;
Location location;
Identifier();
//#line 1445 "VBNET.ATG"
name = t.val; location = t.Location;
if (la.kind == 63) {
lexer.NextToken();
TypeName(
//#line 1446 "VBNET.ATG"
out type);
}
Expect(20);
Expr(
//#line 1447 "VBNET.ATG"
out expr);
//#line 1449 "VBNET.ATG"
VariableDeclaration f = new VariableDeclaration(name, expr);
f.TypeReference = type;
f.StartLocation = location;
constantDeclaration.Add(f);
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:32,代码来源:Parser.cs
示例20: 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
注:本文中的ICSharpCode.NRefactory.Ast.VariableDeclaration类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论