public bool CheckType(ICS.TypeDeclaration node, InspectionData data) { if (MatchKind != 0) { switch (MatchKind) { case DeclarationKinds.Class: if (node.ClassType != ICSharpCode.NRefactory.CSharp.ClassType.Class) { return(false); } break; case DeclarationKinds.Enum: if (node.ClassType != ICSharpCode.NRefactory.CSharp.ClassType.Enum) { return(false); } break; case DeclarationKinds.Struct: if (node.ClassType != ICSharpCode.NRefactory.CSharp.ClassType.Struct) { return(false); } break; case DeclarationKinds.Interface: if (node.ClassType != ICSharpCode.NRefactory.CSharp.ClassType.Interface) { return(false); } break; // case DeclarationKinds.Delegate: // if (node.ClassType != ICSharpCode.NRefactory.CSharp.ClassType.Delegate) // return false; // break; default: return(false); } } if (!CheckAttributedNode(node, ICS.Modifiers.Internal)) { return(false); } string name = node.Name; if (IsValid(name)) { return(true); } data.Add(GetFixableResult(node.NameToken.StartLocation, null, name)); return(true); }
protected void AddResult (InspectionData data, DomRegion region, string menuText, Action fix) { var severity = node.GetSeverity (); if (severity == MonoDevelop.SourceEditor.QuickTaskSeverity.None) return; data.Add ( new GenericResults ( region, node.Title, severity, ResultCertainty.High, ResultImportance.Low, new GenericFix (menuText, fix) ) ); }
public bool CheckNamespace(ICS.NamespaceDeclaration node, InspectionData data) { if ((MatchKind != 0 && (MatchKind & DeclarationKinds.Namespace) == 0)) { return(false); } string name = node.Name; if (IsValid(name)) { return(true); } data.Add(GetFixableResult(node.Identifiers.First().StartLocation, null, name)); return(true); }
public bool CheckEnumMember(ICS.EnumMemberDeclaration node, InspectionData data) { if ((MatchKind != 0 && (MatchKind & DeclarationKinds.EnumMember) == 0)) { return(false); } string name = node.Name; if (IsValid(name)) { return(true); } data.Add(GetFixableResult(node.NameToken.StartLocation, null, name)); return(true); }
public bool CheckDelegate(ICS.DelegateDeclaration node, InspectionData data) { if ((MatchKind != 0 && (MatchKind & DeclarationKinds.Delegate) == 0) || !CheckAttributedNode(node, ICS.Modifiers.Internal)) { return(false); } string name = node.Name; if (IsValid(name)) { return(true); } data.Add(GetFixableResult(node.NameToken.StartLocation, null, name)); return(true); }
public bool CheckEvent(ICS.CustomEventDeclaration node, InspectionData data) { if ((MatchKind != 0 && (MatchKind & DeclarationKinds.Event) == 0) || !CheckAttributedNode(node, ICS.Modifiers.Private)) { return(false); } var name = node.Name; if (IsValid(name)) { return(true); } data.Add(GetFixableResult(node.NameToken.StartLocation, null, name)); return(true); }
protected void AddResult(InspectionData data, DomRegion region, string menuText, Action fix) { var severity = node.GetSeverity(); if (severity == MonoDevelop.SourceEditor.QuickTaskSeverity.None) { return; } data.Add( new GenericResults( region, node.Title, severity, ResultCertainty.High, ResultImportance.Low, new GenericFix(menuText, fix) ) ); }
public bool CheckEvent(ICS.EventDeclaration node, InspectionData data) { if ((MatchKind != 0 && (MatchKind & DeclarationKinds.Event) == 0) || !CheckAttributedNode(node, ICS.Modifiers.Private)) { return(false); } foreach (var v in node.Variables) { string name = v.Name; if (IsValid(name)) { continue; } data.Add(GetFixableResult(v.NameToken.StartLocation, null, name)); } return(true); }
public bool CheckVariableDeclaration(ICS.VariableDeclarationStatement node, InspectionData data) { if ((MatchKind != 0 && (MatchKind & DeclarationKinds.LocalVariable) == 0) || !CheckModifiers(node.Modifiers, ICS.Modifiers.Private)) { return(false); } var member = data.Document.CompilationUnit.GetMemberAt(node.StartLocation.Line, node.StartLocation.Column); foreach (var var in node.Variables) { string name = var.Name; if (IsValid(name)) { continue; } var v = new LocalVariable(member, name, DomReturnType.Void, new DomRegion(node.StartLocation.Line, node.StartLocation.Column, node.EndLocation.Line, node.EndLocation.Column)); data.Add(GetFixableResult(var.NameToken.StartLocation, v, name)); } return(true); }
public bool CheckDelegate (ICS.DelegateDeclaration node, InspectionData data) { if ((MatchKind != 0 && (MatchKind & DeclarationKinds.Delegate) == 0) || !CheckAttributedNode (node, ICS.Modifiers.Internal)) return false; string name = node.Name; if (IsValid (name)) return true; data.Add (GetFixableResult (node.NameToken.StartLocation, null, name)); return true; }
public bool CheckType (ICS.TypeDeclaration node, InspectionData data) { if (MatchKind != 0) { switch (MatchKind) { case DeclarationKinds.Class: if (node.ClassType != ICSharpCode.NRefactory.TypeSystem.ClassType.Class) return false; break; case DeclarationKinds.Enum: if (node.ClassType != ICSharpCode.NRefactory.TypeSystem.ClassType.Enum) return false; break; case DeclarationKinds.Struct: if (node.ClassType != ICSharpCode.NRefactory.TypeSystem.ClassType.Struct) return false; break; case DeclarationKinds.Interface: if (node.ClassType != ICSharpCode.NRefactory.TypeSystem.ClassType.Interface) return false; break; case DeclarationKinds.Delegate: if (node.ClassType != ICSharpCode.NRefactory.TypeSystem.ClassType.Delegate) return false; break; default: return false; } } if (!CheckAttributedNode (node, ICS.Modifiers.Internal)) return false; string name = node.Name; if (IsValid (name)) return true; data.Add (GetFixableResult (node.NameToken.StartLocation, null, name)); return true; }
public bool CheckEvent (ICS.CustomEventDeclaration node, InspectionData data) { if ((MatchKind != 0 && (MatchKind & DeclarationKinds.Event) == 0) || !CheckAttributedNode (node, ICS.Modifiers.Private)) return false; var name = node.Name; if (IsValid (name)) return true; data.Add (GetFixableResult (node.NameToken.StartLocation, null, name)); return true; }
public bool CheckEvent (ICS.EventDeclaration node, InspectionData data) { if ((MatchKind != 0 && (MatchKind & DeclarationKinds.Event) == 0) || !CheckAttributedNode (node, ICS.Modifiers.Private)) return false; foreach (var v in node.Variables) { string name = v.Name; if (IsValid (name)) continue; data.Add (GetFixableResult (v.NameToken.StartLocation, null, name)); } return true; }
public bool CheckVariableDeclaration (ICS.VariableDeclarationStatement node, InspectionData data) { if ((MatchKind != 0 && (MatchKind & DeclarationKinds.LocalVariable) == 0) || !CheckModifiers (node.Modifiers, ICS.Modifiers.Private)) return false; var member = data.Document.CompilationUnit.GetMemberAt (node.StartLocation.Line, node.StartLocation.Column); foreach (var var in node.Variables) { string name = var.Name; if (IsValid (name)) continue; var v = new LocalVariable (member, name, DomReturnType.Void, new DomRegion (node.StartLocation.Line, node.StartLocation.Column, node.EndLocation.Line, node.EndLocation.Column)); data.Add (GetFixableResult (var.NameToken.StartLocation, v, name)); } return true; }
public bool CheckEnumMember (ICS.EnumMemberDeclaration node, InspectionData data) { if ((MatchKind != 0 && (MatchKind & DeclarationKinds.EnumMember) == 0)) return false; string name = node.Name; if (IsValid (name)) return true; data.Add (GetFixableResult (node.NameToken.StartLocation, null, name)); return true; }
void HandleVisitiorVariableDeclarationStatementVisited(VariableDeclarationStatement node, InspectionData data) { if (node.Type is PrimitiveType) { return; } if (node.Type is SimpleType && ((SimpleType)node.Type).Identifier == "var") { return; } var severity = base.node.GetSeverity(); if (severity == MonoDevelop.SourceEditor.QuickTaskSeverity.None) { return; } //only checks for cases where the type would be obvious - assignment of new, cast, etc. //also check the type actually matches else the user might want to assign different subclasses later foreach (var v in node.Variables) { if (v.Initializer.IsNull) { return; } var arrCreate = v.Initializer as ArrayCreateExpression; if (arrCreate != null) { var n = node.Type as ComposedType; //FIXME: check the specifier compatibility if (n != null && n.ArraySpecifiers.Any() && n.BaseType.IsMatch(arrCreate.Type)) { continue; } return; } var objCreate = v.Initializer as ObjectCreateExpression; if (objCreate != null) { if (objCreate.Type.IsMatch(node.Type)) { continue; } return; } var asCast = v.Initializer as AsExpression; if (asCast != null) { if (asCast.Type.IsMatch(node.Type)) { continue; } return; } var cast = v.Initializer as CastExpression; if (cast != null) { if (cast.Type.IsMatch(node.Type)) { continue; } return; } return; } data.Add(new Result( new DomRegion(node.Type.StartLocation.Line, node.Type.StartLocation.Column, node.Type.EndLocation.Line, node.Type.EndLocation.Column), GettextCatalog.GetString("Use implicitly typed local variable decaration"), severity, ResultCertainty.High, ResultImportance.Medium, severity != MonoDevelop.SourceEditor.QuickTaskSeverity.Suggestion) ); }
public bool CheckNamespace (ICS.NamespaceDeclaration node, InspectionData data) { if ((MatchKind != 0 && (MatchKind & DeclarationKinds.Namespace) == 0)) return false; string name = node.Name; if (IsValid (name)) return true; data.Add (GetFixableResult (node.Identifiers.First ().StartLocation, null, name)); return true; }
void HandleVisitiorVariableDeclarationStatementVisited (VariableDeclarationStatement node, InspectionData data) { if (node.Type is PrimitiveType) return; if (node.Type is SimpleType && ((SimpleType)node.Type).Identifier == "var") return; var severity = base.node.GetSeverity (); if (severity == MonoDevelop.SourceEditor.QuickTaskSeverity.None) return; //only checks for cases where the type would be obvious - assignment of new, cast, etc. //also check the type actually matches else the user might want to assign different subclasses later foreach (var v in node.Variables) { if (v.Initializer.IsNull) return; var arrCreate = v.Initializer as ArrayCreateExpression; if (arrCreate != null) { var n = node.Type as ComposedType; //FIXME: check the specifier compatibility if (n != null && n.ArraySpecifiers.Any () && n.BaseType.IsMatch (arrCreate.Type)) continue; return; } var objCreate = v.Initializer as ObjectCreateExpression; if (objCreate != null) { if (objCreate.Type.IsMatch (node.Type)) continue; return; } var asCast = v.Initializer as AsExpression; if (asCast != null) { if (asCast.Type.IsMatch (node.Type)) continue; return; } var cast = v.Initializer as CastExpression; if (cast != null) { if (cast.Type.IsMatch (node.Type)) continue; return; } return; } data.Add (new Result ( new DomRegion (node.Type.StartLocation.Line, node.Type.StartLocation.Column, node.Type.EndLocation.Line, node.Type.EndLocation.Column), GettextCatalog.GetString ("Use implicitly typed local variable decaration"), severity, ResultCertainty.High, ResultImportance.Medium, severity != MonoDevelop.SourceEditor.QuickTaskSeverity.Suggestion) ); }