本文整理汇总了C#中IErrorHandler.ReportError方法的典型用法代码示例。如果您正苦于以下问题:C# IErrorHandler.ReportError方法的具体用法?C# IErrorHandler.ReportError怎么用?C# IErrorHandler.ReportError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IErrorHandler
的用法示例。
在下文中一共展示了IErrorHandler.ReportError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: foreach
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler)
{
CompilationUnitNode compilationUnitNode = (CompilationUnitNode)node;
foreach (AttributeBlockNode attribBlock in compilationUnitNode.Attributes) {
AttributeNode scriptNamespaceNode = AttributeNode.FindAttribute(attribBlock.Attributes, "ScriptNamespace");
if (scriptNamespaceNode != null) {
string scriptNamespace = (string)((LiteralNode)scriptNamespaceNode.Arguments[0]).Value;
if (Utility.IsValidScriptNamespace(scriptNamespace) == false) {
errorHandler.ReportError("A script namespace must be a valid script identifier.",
scriptNamespaceNode.Token.Location);
}
}
}
foreach (ParseNode childNode in compilationUnitNode.Members) {
if (!(childNode is NamespaceNode)) {
errorHandler.ReportError("Non-namespaced types are not supported.",
childNode.Token.Location);
return false;
}
}
return true;
}
示例2:
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler) {
NewNode newNode = (NewNode)node;
// TODO: This is somewhat hacky - it only looks for any type named Dictionary
// rather than resolving the type and checking if its actually
// System.Dictionary.
// This is because validators don't have a reference to the SymbolSet.
NameNode typeNode = newNode.TypeReference as NameNode;
if ((typeNode != null) && (typeNode.Name.Equals("Dictionary"))) {
if (newNode.Arguments != null) {
Debug.Assert(newNode.Arguments is ExpressionListNode);
ParseNodeList arguments = ((ExpressionListNode)newNode.Arguments).Expressions;
if (arguments.Count != 0) {
if (arguments.Count % 2 != 0) {
errorHandler.ReportError("Missing value parameter for the last name parameter in Dictionary instantiation.",
newNode.Token.Location);
}
for (int i = 0; i < arguments.Count; i += 2) {
ParseNode nameArgumentNode = arguments[i];
if ((nameArgumentNode.NodeType != ParseNodeType.Literal) ||
(((LiteralNode)nameArgumentNode).Literal.LiteralType != LiteralTokenType.String)) {
errorHandler.ReportError("Name parameters in Dictionary instantiation must be string literals.",
nameArgumentNode.Token.Location);
}
}
}
}
}
return true;
}
示例3: foreach
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler)
{
MethodDeclarationNode methodNode = (MethodDeclarationNode)node;
if (((methodNode.Modifiers & Modifiers.Static) == 0) &&
((methodNode.Modifiers & Modifiers.New) != 0)) {
errorHandler.ReportError("The new modifier is not supported on instance members.",
methodNode.Token.Location);
return false;
}
if ((methodNode.Modifiers & Modifiers.Extern) != 0) {
AttributeNode altSigAttribute
= AttributeNode.FindAttribute(methodNode.Attributes, "AlternateSignature");
if (altSigAttribute == null) {
errorHandler.ReportError("Extern methods should only be used to declare alternate signatures and marked with [AlternateSignature].",
methodNode.Token.Location);
return false;
}
CustomTypeNode typeNode = (CustomTypeNode)methodNode.Parent;
MethodDeclarationNode implMethodNode = null;
if (methodNode.NodeType == ParseNodeType.MethodDeclaration) {
foreach (MemberNode memberNode in typeNode.Members) {
if ((memberNode.NodeType == ParseNodeType.MethodDeclaration) &&
((memberNode.Modifiers & Modifiers.Extern) == 0) &&
memberNode.Name.Equals(methodNode.Name, StringComparison.Ordinal)) {
implMethodNode = (MethodDeclarationNode)memberNode;
break;
}
}
}
else if (methodNode.NodeType == ParseNodeType.ConstructorDeclaration) {
foreach (MemberNode memberNode in typeNode.Members) {
if ((memberNode.NodeType == ParseNodeType.ConstructorDeclaration) &&
((memberNode.Modifiers & Modifiers.Extern) == 0)) {
implMethodNode = (MethodDeclarationNode)memberNode;
break;
}
}
}
if (implMethodNode == null) {
errorHandler.ReportError("Extern methods used to declare alternate signatures should have a corresponding non-extern implementation as well.",
methodNode.Token.Location);
return false;
}
if ((methodNode.Modifiers & (Modifiers.Static | Modifiers.AccessMask)) !=
(implMethodNode.Modifiers & (Modifiers.Static | Modifiers.AccessMask))) {
errorHandler.ReportError("The implemenation method and associated alternate signature methods should have the same access type.",
methodNode.Token.Location);
}
}
return true;
}
示例4:
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler) {
EnumerationFieldNode enumFieldNode = (EnumerationFieldNode)node;
object fieldValue = enumFieldNode.Value;
if (fieldValue == null) {
errorHandler.ReportError("Enumeration fields must have an explicit constant value specified.",
enumFieldNode.Token.Location);
return false;
}
if ((fieldValue is long) || (fieldValue is ulong)) {
errorHandler.ReportError("Enumeration fields cannot have long or ulong underlying type.",
enumFieldNode.Token.Location);
}
return true;
}
示例5:
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler) {
PropertyDeclarationNode propertyNode = (PropertyDeclarationNode)node;
if (((propertyNode.Modifiers & Modifiers.Static) == 0) &&
((propertyNode.Modifiers & Modifiers.New) != 0)) {
errorHandler.ReportError("The new modifier is not supported on instance members.",
propertyNode.Token.Location);
return false;
}
if (propertyNode.GetAccessor == null) {
errorHandler.ReportError("Set-only properties are not supported. Use a set method instead.",
propertyNode.Token.Location);
return false;
}
return true;
}
示例6:
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler) {
IndexerDeclarationNode indexerNode = (IndexerDeclarationNode)node;
if ((indexerNode.Modifiers & Modifiers.New) != 0) {
errorHandler.ReportError("The new modifier is not supported.",
indexerNode.Token.Location);
return false;
}
if (indexerNode.GetAccessor == null) {
errorHandler.ReportError("Set-only properties are not supported. Use a set method instead.",
indexerNode.Token.Location);
return false;
}
return true;
}
示例7:
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler) {
ArrayTypeNode typeNode = (ArrayTypeNode)node;
if (typeNode.Rank != 1) {
errorHandler.ReportError("Only single dimensional arrays are supported.",
typeNode.Token.Location);
}
return true;
}
示例8:
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler) {
NameNode nameNode = (NameNode)node;
if (Utility.IsKeyword(nameNode.Name)) {
errorHandler.ReportError(nameNode.Name + " is a reserved word.",
nameNode.Token.Location);
}
return true;
}
示例9:
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler) {
ThrowNode throwNode = (ThrowNode)node;
if (throwNode.Value == null) {
errorHandler.ReportError("Throw statements must specify an exception object.",
throwNode.Token.Location);
return false;
}
return true;
}
示例10:
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler) {
ParameterNode paramNode = (ParameterNode)node;
if (paramNode.Flags != ParameterFlags.None) {
errorHandler.ReportError("Out, Ref and Params style of parameters are not yet implemented.",
paramNode.Token.Location);
return false;
}
return true;
}
示例11:
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler) {
FieldDeclarationNode fieldNode = (FieldDeclarationNode)node;
if (fieldNode.Initializers.Count > 1) {
errorHandler.ReportError("Field declarations are limited to a single field per declaration.",
fieldNode.Token.Location);
return false;
}
return true;
}
示例12:
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler) {
TryNode tryNode = (TryNode)node;
if ((tryNode.CatchClauses != null) && (tryNode.CatchClauses.Count > 1)) {
errorHandler.ReportError("Try/Catch statements are limited to a single catch clause.",
tryNode.Token.Location);
return false;
}
return true;
}
示例13:
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler) {
EventDeclarationNode eventNode = (EventDeclarationNode)node;
if (((eventNode.Modifiers & Modifiers.Static) == 0) &&
((eventNode.Modifiers & Modifiers.New) != 0)) {
errorHandler.ReportError("The new modifier is not supported on instance members.",
eventNode.Token.Location);
return false;
}
return true;
}
示例14: foreach
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler)
{
NamespaceNode namespaceNode = (NamespaceNode)node;
bool valid = true;
foreach (ParseNode childNode in namespaceNode.Members) {
if (childNode is NamespaceNode) {
errorHandler.ReportError("Nested namespaces are not supported.",
childNode.Token.Location);
valid = false;
}
}
if (namespaceNode.Name.Equals("System") ||
namespaceNode.Name.StartsWith("System.")) {
// Usage of the System namespace is limited to imported types.
foreach (ParseNode childNode in namespaceNode.Members) {
bool allowed = false;
if (childNode is UserTypeNode) {
ParseNodeList attributes = ((UserTypeNode)childNode).Attributes;
if (AttributeNode.FindAttribute(attributes, "ScriptImport") != null) {
allowed = true;
}
}
if (allowed == false) {
errorHandler.ReportError("Only types marked as Imported are allowed within the System namespace.",
namespaceNode.Token.Location);
valid = false;
break;
}
}
}
return valid;
}
示例15:
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler) {
ArrayNewNode newNode = (ArrayNewNode)node;
if (newNode.ExpressionList != null) {
Debug.Assert(newNode.ExpressionList.NodeType == ParseNodeType.ExpressionList);
ExpressionListNode argsList = (ExpressionListNode)newNode.ExpressionList;
if (argsList.Expressions.Count != 1) {
errorHandler.ReportError("Only single dimensional arrays are supported.",
newNode.ExpressionList.Token.Location);
}
}
return true;
}