summaryrefslogtreecommitdiffstats
path: root/idlc/inc/errorhandler.hxx
blob: 9b49f5df441a5c94a0537a1be67c05ad03e34202 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
#ifndef INCLUDED_IDLC_INC_ERRORHANDLER_HXX
#define INCLUDED_IDLC_INC_ERRORHANDLER_HXX

#include "astdeclaration.hxx"
#include "astexpression.hxx"
#include "astenum.hxx"

enum class ErrorCode
{
    SyntaxError,      // Syntax error in IDL input
                      // More details will be gleaned from examining
                      // the parse state
    RedefScope,       // Redefinition inside defining scope
    CoercionFailure,  // Coercion failure
    ScopeConflict,    // Between fwd declare and full declare
    IllegalAdd,       // Illegal add action
    IllegalRaises,    // Error in "raises" clause
    CantInherit,      // Cannot inherit from non-interface
    IdentNotFound,    // Identifier not found
    CannotInheritFromForward, // Cannot inherit from fwd decl interface
    ExpectedConstant,       // We got something else...
    Eval,                   // Error in evaluating expression
    ForwardDeclLookup,      // Tried to lookup in fwd declared intf
    RecursiveType,          // Illegal recursive use of type
    NotAType,               // Not a type
    InterfaceMemberLookup,  // interface is not defined or a fwd declaration not exists
    ServiceMemberLookup,
    DefinedAttributeFlag,
    WrongAttributeKeyword,
    MissingAttributeKeyword,
    BadAttributeFlags,
    ExpectedOptional,
    MixedInheritance,
    DoubleInheritance,
    DoubleMember,
    ConstructorParameterNotIn,
    ConstructorRestParameterNotFirst,
    RestParameterNotLast,
    RestParameterNotAny,
    MethodHasRestParameter,
    ReadOnlyAttributeSetExceptions,
    UnsignedTypeArgument,
    WrongNumberOfTypeArguments,
    InstantiatedStructTypeTypedef,
    IdenticalTypeParameters,
    StructTypeTemplateWithBase,
    PublishedForward,
    PublishedusesUnpublished,
    SimilarConstructors
};

enum class WarningCode
{
    WrongNamingConvention    // type or identifier doesn't fulfill the UNO naming convention
};

class ErrorHandler
{
public:
    // Report errors with varying numbers of arguments
    static void error0(ErrorCode e);
    static void error1(ErrorCode e, AstDeclaration const * d);
    static void error2(
        ErrorCode e, AstDeclaration const * d1, AstDeclaration const * d2);
    static void error3(ErrorCode e, AstDeclaration const * d1, AstDeclaration const * d2, AstDeclaration const * d3);

    // Warning
    static void warning0(WarningCode e, const char* warningmsg);

    // Report a syntax error in IDL input
    static void syntaxError(ParseState state, sal_Int32 lineNumber, const char* errmsg);

    // Report an unsuccessful coercion attempt
    static void coercionError(AstExpression *pExpr, ExprType et);

    // Report a failed name lookup attempt
    static void lookupError(const OString& n);
    // Report a failed name lookup attempt
    static void lookupError(ErrorCode e, const OString& n, AstDeclaration const * pScope);


    // Report a type error
    static void noTypeError(AstDeclaration const * pDecl);

    static void inheritanceError(NodeType nodeType, const OString* name, AstDeclaration const * pDecl);

    static void flagError(ErrorCode e, sal_uInt32 flag);

    static void forwardLookupError(const AstDeclaration* pForward, const OString& name);

    static void constantExpected(AstDeclaration const * pDecl, const OString& name);

    static void evalError(AstExpression* pExpr);

    static bool checkPublished(AstDeclaration const * decl, bool bOptional=false);
};

#endif // INCLUDED_IDLC_INC_ERRORHANDLER_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */