Doxygen
Loading...
Searching...
No Matches
symbolresolver.h
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2020 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16#ifndef SYMBOLRESOLVER_H
17#define SYMBOLRESOLVER_H
18
19#include <memory>
20
21#include "qcstring.h"
22#include "classdef.h"
23#include "construct.h"
24
25class Definition;
26class FileDef;
27class MemberDef;
28
29//! Helper class to find a class definition or check if
30//! A symbol is accessible in a given scope.
32{
33 public:
34 explicit SymbolResolver(const FileDef *fileScope = nullptr);
37
38 // actions
39
40 /** Find the class definition matching name within
41 * the scope set.
42 * @param scope The scope to search from.
43 * @param name The name of the symbol.
44 * @param maybeUnlinkable include unlinkable symbols in the search.
45 * @param mayBeHidden include hidden symbols in the search.
46 * @note As a result of this call the getters getTypedef(),
47 * getTemplateSpec(), and getResolvedType() are set as well.
48 */
49 const ClassDef *resolveClass(const Definition *scope,
50 const QCString &name,
51 bool maybeUnlinkable=false,
52 bool mayBeHidden=false);
53
54 /** Wrapper around resolveClass that returns a mutable interface to
55 * the class object or a nullptr if the symbol is immutable.
56 */
58 const QCString &name,
59 bool mayBeUnlinkable=false,
60 bool mayBeHidden=false)
61 {
62 return toClassDefMutable(const_cast<ClassDef*>(resolveClass(scope,name,mayBeUnlinkable,mayBeHidden)));
63 }
64
65 /** Find the symbool definition matching name within the scope set.
66 * @param scope The scope to search from.
67 * @param name The name of the symbol.
68 * @param args Argument list associated with the symbol (for functions)
69 * @param checkCV Check const/volatile qualifiers (for methods)
70 * @param insideCode Is the symbol found in a code fragment
71 * @param onlyLinkable Only search linkable definitions
72 */
73 const Definition *resolveSymbol(const Definition *scope,
74 const QCString &name,
75 const QCString &args=QCString(),
76 bool checkCV=false,
77 bool insideCode=false,
78 bool onlyLinkable=false
79 );
80
81 /** Checks if symbol \a item is accessible from within \a scope.
82 * @returns -1 if \a item is not accessible or a number indicating how
83 * many scope levels up the nearest match was found.
84 */
85 int isAccessibleFrom(const Definition *scope,
86 const Definition *item);
87
88 /** Check if symbol \a item is accessible from within \a scope,
89 * where it has to match the \a explicitScopePart.
90 * @returns -1 if \a item is not accessible or a number indicating how
91 * many scope levels up the nearest match was found.
92 */
94 const Definition *item,
95 const QCString &explicitScopePart
96 );
97
98 /** Sets or updates the file scope using when resolving symbols. */
99 void setFileScope(const FileDef *fd);
100
101 // getters
102
103 /** In case a call to resolveClass() resolves to a type member (e.g. an enum)
104 * this method will return it.
105 */
106 const MemberDef *getTypedef() const;
107
108 /** In case a call to resolveClass() points to a template specialization, the
109 * template part is return via this method.
110 */
112
113 /** In case a call to resolveClass() points to a typedef or using declaration.
114 * The type name it resolved to is returned via this method.
115 */
117
118 private:
119 struct Private;
120 std::unique_ptr<Private> p;
121};
122
123#endif
A abstract class representing of a compound symbol.
Definition classdef.h:104
The common base class of all entity definitions found in the sources.
Definition definition.h:76
A model of a file symbol.
Definition filedef.h:99
A model of a class/file/namespace member symbol.
Definition memberdef.h:48
This is an alternative implementation of QCString.
Definition qcstring.h:101
int isAccessibleFrom(const Definition *scope, const Definition *item)
Checks if symbol item is accessible from within scope.
int isAccessibleFromWithExpScope(const Definition *scope, const Definition *item, const QCString &explicitScopePart)
Check if symbol item is accessible from within scope, where it has to match the explicitScopePart.
QCString getResolvedType() const
In case a call to resolveClass() points to a typedef or using declaration.
const Definition * resolveSymbol(const Definition *scope, const QCString &name, const QCString &args=QCString(), bool checkCV=false, bool insideCode=false, bool onlyLinkable=false)
Find the symbool definition matching name within the scope set.
std::unique_ptr< Private > p
const ClassDef * resolveClass(const Definition *scope, const QCString &name, bool maybeUnlinkable=false, bool mayBeHidden=false)
Find the class definition matching name within the scope set.
SymbolResolver(const FileDef *fileScope=nullptr)
QCString getTemplateSpec() const
In case a call to resolveClass() points to a template specialization, the template part is return via...
ClassDefMutable * resolveClassMutable(const Definition *scope, const QCString &name, bool mayBeUnlinkable=false, bool mayBeHidden=false)
Wrapper around resolveClass that returns a mutable interface to the class object or a nullptr if the ...
void setFileScope(const FileDef *fd)
Sets or updates the file scope using when resolving symbols.
const MemberDef * getTypedef() const
In case a call to resolveClass() resolves to a type member (e.g.
ClassDefMutable * toClassDefMutable(Definition *d)
#define NON_COPYABLE(cls)
Macro to help implementing the rule of 5 for a non-copyable & movable class.
Definition construct.h:37