BOO-988: Added else block to the for and while statements, and include a suite of...
[boo.git] / src / Boo.Lang.Compiler / CompilerWarningFactory.cs
blob89cb2947837dc2c16981be2a0e088c93e329f58d
1 #region license
2 // Copyright (c) 2004, Rodrigo B. de Oliveira (rbo@acm.org)
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 // * Neither the name of Rodrigo B. de Oliveira nor the names of its
14 // contributors may be used to endorse or promote products derived from this
15 // software without specific prior written permission.
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
21 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #endregion
29 using System;
30 using System.Text;
31 using Boo.Lang.Compiler.Ast;
32 using Boo.Lang.Compiler.TypeSystem;
34 namespace Boo.Lang.Compiler
36 public class CompilerWarningFactory
38 private CompilerWarningFactory()
42 public static CompilerWarning CustomWarning(LexicalInfo lexicalInfo, string msg)
44 return new CompilerWarning(lexicalInfo, msg);
47 public static CompilerWarning CustomWarning(string msg)
49 return new CompilerWarning(msg);
52 public static CompilerWarning AbstractMemberNotImplemented(Node node, string typeName, string memberName)
54 return new CompilerWarning("BCW0001", node.LexicalInfo, typeName, memberName);
57 public static CompilerWarning ModifiersInLabelsHaveNoEffect(Node node)
59 return new CompilerWarning("BCW0002", node.LexicalInfo);
62 public static CompilerWarning UnusedLocalVariable(Node node, string name)
64 return new CompilerWarning("BCW0003", node.LexicalInfo, name);
67 public static CompilerWarning IsInsteadOfIsa(Node node)
69 return new CompilerWarning("BCW0004", node.LexicalInfo);
72 public static CompilerWarning InvalidEventUnsubscribe(Node node, string eventName, CallableSignature expected)
74 return new CompilerWarning("BCW0005", node.LexicalInfo, eventName, expected);
77 public static CompilerWarning AssignmentToTemporary(Node node)
79 return new CompilerWarning("BCW0006", node.LexicalInfo);
82 public static CompilerWarning EqualsInsteadOfAssign(BinaryExpression node)
84 return new CompilerWarning("BCW0007", node.LexicalInfo, node.ToCodeString());
87 public static CompilerWarning DuplicateNamespace(Import import, string name)
89 return new CompilerWarning("BCW0008", import.LexicalInfo, name);
92 public static CompilerWarning HaveBothKeyFileAndAttribute(Node node)
94 return new CompilerWarning("BCW0009", node.LexicalInfo);
97 public static CompilerWarning HaveBothKeyNameAndAttribute(Node node)
99 return new CompilerWarning("BCW0010", node.LexicalInfo);
102 public static CompilerWarning AbstractMemberNotImplementedStubCreated(Node node, string typeName, string memberName)
104 return new CompilerWarning("BCW0011", node.LexicalInfo, typeName, memberName);
107 public static CompilerWarning Obsolete(Node node, string memberName, string message)
109 return new CompilerWarning("BCW0012", node.LexicalInfo, memberName, message);
112 public static CompilerWarning StaticClassMemberRedundantlyMarkedStatic(Node node, string typeName, string memberName)
114 return new CompilerWarning("BCW0013", node.LexicalInfo, typeName, memberName);
117 public static CompilerWarning PrivateMemberNeverUsed(Node node)
119 return new CompilerWarning("BCW0014", node.LexicalInfo, node.NodeType.ToString().ToLower(), (node as TypeMember).FullName);
122 public static CompilerWarning UnreachableCodeDetected(Node node)
124 return new CompilerWarning("BCW0015", node.LexicalInfo);
127 public static CompilerWarning NamespaceNeverUsed(Import node)
129 return new CompilerWarning("BCW0016", node.LexicalInfo, node.Namespace);