Changeset View
Changeset View
Standalone View
Standalone View
duchain/expressionvisitor.h
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 43 | public: | |||
---|---|---|---|---|---|
51 | void visitNode(AstNode *node) override; | 51 | void visitNode(AstNode *node) override; | ||
52 | 52 | | |||
53 | protected: | 53 | protected: | ||
54 | KDevelop::DeclarationPointer processVariable( VariableIdentifierAst* variable); | 54 | KDevelop::DeclarationPointer processVariable( VariableIdentifierAst* variable); | ||
55 | 55 | | |||
56 | void visitAssignmentExpression(AssignmentExpressionAst *node) override; | 56 | void visitAssignmentExpression(AssignmentExpressionAst *node) override; | ||
57 | void visitArrayIndexSpecifier(ArrayIndexSpecifierAst* node) override; | 57 | void visitArrayIndexSpecifier(ArrayIndexSpecifierAst* node) override; | ||
58 | void visitCompoundVariableWithSimpleIndirectReference(CompoundVariableWithSimpleIndirectReferenceAst *node) override; | 58 | void visitCompoundVariableWithSimpleIndirectReference(CompoundVariableWithSimpleIndirectReferenceAst *node) override; | ||
59 | void visitVarExpression(VarExpressionAst *node) override; | ||||
59 | void visitVarExpressionNewObject(VarExpressionNewObjectAst *node) override; | 60 | void visitVarExpressionNewObject(VarExpressionNewObjectAst *node) override; | ||
60 | void visitVarExpressionArray(VarExpressionArrayAst *node) override; | 61 | void visitVarExpressionArray(VarExpressionArrayAst *node) override; | ||
61 | void visitClosure(ClosureAst* node) override; | 62 | void visitClosure(ClosureAst* node) override; | ||
62 | void visitFunctionCall(FunctionCallAst* node) override; | 63 | void visitFunctionCall(FunctionCallAst* node) override; | ||
63 | void visitConstantOrClassConst(ConstantOrClassConstAst *node) override; | 64 | void visitConstantOrClassConst(ConstantOrClassConstAst *node) override; | ||
64 | void visitScalar(ScalarAst *node) override; | 65 | void visitScalar(ScalarAst *node) override; | ||
65 | void visitStaticScalar(StaticScalarAst *node) override; | 66 | void visitStaticScalar(StaticScalarAst *node) override; | ||
66 | void visitEncapsVar(EncapsVarAst *node) override; | 67 | void visitEncapsVar(EncapsVarAst *node) override; | ||
67 | void visitVariableProperty(VariablePropertyAst *node) override; | 68 | void visitVariableProperty(VariablePropertyAst *node) override; | ||
68 | void visitStaticMember(StaticMemberAst* node) override; | 69 | void visitStaticMember(StaticMemberAst* node) override; | ||
69 | void visitUnaryExpression(UnaryExpressionAst* node) override; | 70 | void visitUnaryExpression(UnaryExpressionAst* node) override; | ||
70 | void visitAdditiveExpressionRest(AdditiveExpressionRestAst* node) override; | 71 | void visitAdditiveExpressionRest(AdditiveExpressionRestAst* node) override; | ||
71 | void visitVariable(VariableAst* node) override; | 72 | void visitVariable(VariableAst* node) override; | ||
72 | void visitFunctionCallParameterList( FunctionCallParameterListAst* node ) override; | 73 | void visitFunctionCallParameterList( FunctionCallParameterListAst* node ) override; | ||
73 | void visitFunctionCallParameterListElement(FunctionCallParameterListElementAst* node) override; | 74 | void visitFunctionCallParameterListElement(FunctionCallParameterListElementAst* node) override; | ||
74 | void visitRelationalExpression(RelationalExpressionAst* node) override; | 75 | void visitRelationalExpression(RelationalExpressionAst* node) override; | ||
76 | void visitStatement(StatementAst* node) override; | ||||
75 | 77 | | |||
76 | QString stringForNode(AstNode* id); | 78 | QString stringForNode(AstNode* id); | ||
77 | KDevelop::QualifiedIdentifier identifierForNode(IdentifierAst* id); | 79 | KDevelop::QualifiedIdentifier identifierForNode(IdentifierAst* id); | ||
78 | QString stringForNode(VariableIdentifierAst* id); | 80 | QString stringForNode(VariableIdentifierAst* id); | ||
79 | KDevelop::QualifiedIdentifier identifierForNode(VariableIdentifierAst* id); | 81 | KDevelop::QualifiedIdentifier identifierForNode(VariableIdentifierAst* id); | ||
80 | 82 | | |||
81 | 83 | | |||
82 | virtual void usingDeclaration(AstNode* node, const KDevelop::DeclarationPointer& decl) { | 84 | virtual void usingDeclaration(AstNode* node, const KDevelop::DeclarationPointer& decl) { | ||
83 | Q_UNUSED(node) Q_UNUSED(decl) | 85 | Q_UNUSED(node) Q_UNUSED(decl) | ||
84 | } | 86 | } | ||
85 | 87 | | |||
86 | KDevelop::DeclarationPointer findDeclarationImport(DeclarationType declarationType, IdentifierAst* node); | 88 | KDevelop::DeclarationPointer findDeclarationImport(DeclarationType declarationType, IdentifierAst* node); | ||
87 | KDevelop::DeclarationPointer findDeclarationImport(DeclarationType declarationType, VariableIdentifierAst* node); | 89 | KDevelop::DeclarationPointer findDeclarationImport(DeclarationType declarationType, VariableIdentifierAst* node); | ||
88 | KDevelop::DeclarationPointer findDeclarationImport(DeclarationType declarationType, | 90 | KDevelop::DeclarationPointer findDeclarationImport(DeclarationType declarationType, | ||
89 | const KDevelop::QualifiedIdentifier& identifier); | 91 | const KDevelop::QualifiedIdentifier& identifier); | ||
90 | KDevelop::Declaration* findVariableDeclaration(KDevelop::DUContext* context, KDevelop::Identifier identifier, | 92 | KDevelop::Declaration* findVariableDeclaration(KDevelop::DUContext* context, KDevelop::Identifier identifier, | ||
91 | KDevelop::CursorInRevision position, KDevelop::DUContext::SearchFlag flag); | 93 | KDevelop::CursorInRevision position, KDevelop::DUContext::SearchFlag flag); | ||
92 | protected: | 94 | protected: | ||
93 | EditorIntegrator* m_editor; | 95 | EditorIntegrator* m_editor; | ||
94 | 96 | | |||
97 | /** | ||||
98 | * Opens the given closure return type, and sets it to be the current closure return type. | ||||
99 | */ | ||||
100 | void openClosureReturnType(const KDevelop::AbstractType::Ptr& type) | ||||
101 | { | ||||
102 | m_closureReturnTypes.append(type); | ||||
103 | } | ||||
104 | | ||||
105 | /** | ||||
106 | * Close the current closure return type. | ||||
107 | */ | ||||
108 | void closeClosureReturnType() | ||||
109 | { | ||||
110 | // And the reference will be lost... | ||||
111 | m_closureReturnTypes.pop(); | ||||
112 | } | ||||
113 | | ||||
114 | /** | ||||
115 | * Retrieve the return type of the current closure. | ||||
116 | * | ||||
117 | * \returns the abstract type of the current context. | ||||
118 | */ | ||||
119 | inline KDevelop::AbstractType::Ptr currentClosureReturnType() | ||||
120 | { | ||||
121 | if (m_closureReturnTypes.isEmpty()) { | ||||
122 | return KDevelop::AbstractType::Ptr(); | ||||
123 | } else { | ||||
124 | return m_closureReturnTypes.top(); | ||||
125 | } | ||||
126 | } | ||||
127 | | ||||
128 | /// Determine if the expression visitor has a return type for the current closure. \returns true if there is a current closure return type, else returns false. | ||||
129 | inline bool hasCurrentClosureReturnType() { return !m_closureReturnTypes.isEmpty(); } | ||||
130 | | ||||
95 | private: | 131 | private: | ||
96 | KDevelop::DUContext* findClassContext(NamespacedIdentifierAst* className); | 132 | KDevelop::DUContext* findClassContext(NamespacedIdentifierAst* className); | ||
97 | KDevelop::DUContext* findClassContext(IdentifierAst* className); | 133 | KDevelop::DUContext* findClassContext(IdentifierAst* className); | ||
98 | void buildNamespaceUses(NamespacedIdentifierAst* namespaces, const KDevelop::QualifiedIdentifier& identifier); | 134 | void buildNamespaceUses(NamespacedIdentifierAst* namespaces, const KDevelop::QualifiedIdentifier& identifier); | ||
99 | 135 | | |||
100 | bool m_createProblems; | 136 | bool m_createProblems; | ||
101 | KDevelop::CursorInRevision m_offset; | 137 | KDevelop::CursorInRevision m_offset; | ||
102 | KDevelop::DUContext* m_currentContext; | 138 | KDevelop::DUContext* m_currentContext; | ||
103 | 139 | | |||
104 | ExpressionEvaluationResult m_result; | 140 | ExpressionEvaluationResult m_result; | ||
141 | KDevelop::Stack<KDevelop::AbstractType::Ptr> m_closureReturnTypes; | ||||
105 | 142 | | |||
106 | bool m_isAssignmentExpressionEqual; | 143 | bool m_isAssignmentExpressionEqual; | ||
107 | bool m_inDefine; | 144 | bool m_inDefine; | ||
108 | }; | 145 | }; | ||
109 | 146 | | |||
110 | } | 147 | } | ||
111 | #endif | 148 | #endif |