Changeset View
Changeset View
Standalone View
Standalone View
duchain/builders/typebuilder.h
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 50 | protected: | |||
---|---|---|---|---|---|
58 | void visitParameter(ParameterAst *node) override; | 58 | void visitParameter(ParameterAst *node) override; | ||
59 | void visitFunctionDeclarationStatement(FunctionDeclarationStatementAst* node) override; | 59 | void visitFunctionDeclarationStatement(FunctionDeclarationStatementAst* node) override; | ||
60 | void visitClosure(ClosureAst* node) override; | 60 | void visitClosure(ClosureAst* node) override; | ||
61 | 61 | | |||
62 | void visitStatement(StatementAst* node) override; | 62 | void visitStatement(StatementAst* node) override; | ||
63 | void visitAssignmentExpression(AssignmentExpressionAst* node) override; | 63 | void visitAssignmentExpression(AssignmentExpressionAst* node) override; | ||
64 | void visitStaticVar(StaticVarAst *node) override; | 64 | void visitStaticVar(StaticVarAst *node) override; | ||
65 | void visitCatchItem(CatchItemAst *node) override; | 65 | void visitCatchItem(CatchItemAst *node) override; | ||
66 | void visitVarExpression(VarExpressionAst *node) override; | ||||
66 | 67 | | |||
67 | /// The declaration builder implements this and updates | 68 | /// The declaration builder implements this and updates | ||
68 | /// the type of the current declaration | 69 | /// the type of the current declaration | ||
69 | virtual void updateCurrentType(); | 70 | virtual void updateCurrentType(); | ||
70 | 71 | | |||
71 | KDevelop::AbstractType::Ptr getTypeForNode(AstNode* node); | 72 | KDevelop::AbstractType::Ptr getTypeForNode(AstNode* node); | ||
73 | | ||||
74 | /** | ||||
75 | * Opens the given context type, and sets it to be the current context type. | ||||
76 | */ | ||||
77 | void openContextType(const KDevelop::AbstractType::Ptr& type) | ||||
78 | { | ||||
79 | m_contextTypes.append(type); | ||||
80 | } | ||||
81 | | ||||
82 | /** | ||||
83 | * Close the current context type. | ||||
84 | */ | ||||
85 | void closeContextType() | ||||
86 | { | ||||
87 | // And the reference will be lost... | ||||
88 | m_contextTypes.pop(); | ||||
89 | } | ||||
90 | | ||||
91 | /** | ||||
92 | * Retrieve the type of the current context. | ||||
93 | * | ||||
94 | * \returns the abstract type of the current context. | ||||
95 | */ | ||||
96 | inline KDevelop::AbstractType::Ptr currentContextType() | ||||
97 | { | ||||
98 | if (m_contextTypes.isEmpty()) { | ||||
99 | return KDevelop::AbstractType::Ptr(); | ||||
100 | } else { | ||||
101 | return m_contextTypes.top(); | ||||
102 | } | ||||
103 | } | ||||
104 | | ||||
105 | /// Determine if the type builder has a type for the current context. \returns true if there is a current context type, else returns false. | ||||
106 | inline bool hasCurrentContextType() { return !m_contextTypes.isEmpty(); } | ||||
107 | | ||||
72 | private: | 108 | private: | ||
73 | KDevelop::FunctionType::Ptr m_currentFunctionType; | 109 | KDevelop::FunctionType::Ptr m_currentFunctionType; | ||
74 | QList<KDevelop::AbstractType::Ptr> m_currentFunctionParams; | 110 | QList<KDevelop::AbstractType::Ptr> m_currentFunctionParams; | ||
111 | KDevelop::Stack<KDevelop::AbstractType::Ptr> m_contextTypes; | ||||
75 | 112 | | |||
76 | bool m_gotTypeFromDocComment; | 113 | bool m_gotTypeFromDocComment; | ||
77 | bool m_gotReturnTypeFromDocComment; | 114 | bool m_gotReturnTypeFromDocComment; | ||
78 | 115 | | |||
79 | KDevelop::AbstractType::Ptr injectParseType(QString type, AstNode* node); | 116 | KDevelop::AbstractType::Ptr injectParseType(QString type, AstNode* node); | ||
80 | KDevelop::AbstractType::Ptr parseType(QString type, AstNode* node); | 117 | KDevelop::AbstractType::Ptr parseType(QString type, AstNode* node); | ||
81 | KDevelop::AbstractType::Ptr parseDocComment(AstNode* node, const QString& docCommentName); | 118 | KDevelop::AbstractType::Ptr parseDocComment(AstNode* node, const QString& docCommentName); | ||
82 | QList<KDevelop::AbstractType::Ptr> parseDocCommentParams(AstNode* node); | 119 | QList<KDevelop::AbstractType::Ptr> parseDocCommentParams(AstNode* node); | ||
83 | }; | 120 | }; | ||
84 | 121 | | |||
85 | } | 122 | } | ||
86 | 123 | | |||
87 | #endif // TYPEBUILDER_H | 124 | #endif // TYPEBUILDER_H | ||
88 | 125 | |