Changeset View
Changeset View
Standalone View
Standalone View
duchain/expressionvisitor.cpp
Context not available. | |||||
31 | #include <language/duchain/types/functiontype.h> | 31 | #include <language/duchain/types/functiontype.h> | ||
---|---|---|---|---|---|
32 | #include <language/duchain/types/integraltype.h> | 32 | #include <language/duchain/types/integraltype.h> | ||
33 | #include <language/duchain/types/structuretype.h> | 33 | #include <language/duchain/types/structuretype.h> | ||
34 | #include <language/duchain/types/unsuretype.h> | ||||
34 | 35 | | |||
35 | #include "duchaindebug.h" | 36 | #include "duchaindebug.h" | ||
36 | 37 | | |||
Context not available. | |||||
226 | forever { | 227 | forever { | ||
227 | AbstractType::Ptr type; | 228 | AbstractType::Ptr type; | ||
228 | if (it->element->parameterType) { | 229 | if (it->element->parameterType) { | ||
229 | //don't use openTypeFromName as it uses cursor for findDeclarations | 230 | auto parameterType = it->element->parameterType; | ||
230 | DeclarationPointer decl = findDeclarationImport(ClassDeclarationType, | 231 | if (parameterType->objectType) { | ||
231 | identifierForNamespace(it->element->parameterType, m_editor)); | 232 | //don't use openTypeFromName as it uses cursor for findDeclarations | ||
232 | if (decl) { | 233 | DeclarationPointer decl = findDeclarationImport(ClassDeclarationType, | ||
233 | type = decl->abstractType(); | 234 | identifierForNamespace(parameterType->objectType, m_editor)); | ||
235 | if (decl) { | ||||
236 | type = decl->abstractType(); | ||||
237 | } | ||||
238 | } else if (parameterType->arrayType != -1) { | ||||
239 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeArray)); | ||||
240 | } else if (parameterType->boolType != -1) { | ||||
241 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeBoolean)); | ||||
242 | } else if (parameterType->floatType != -1) { | ||||
243 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeFloat)); | ||||
244 | } else if (parameterType->intType != -1) { | ||||
245 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeInt)); | ||||
246 | } else if (parameterType->stringType != -1) { | ||||
247 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeString)); | ||||
248 | } else if (parameterType->iterableType != -1) { | ||||
249 | DeclarationPointer traversableDecl = findDeclarationImport(ClassDeclarationType, QualifiedIdentifier("traversable")); | ||||
250 | | ||||
251 | if (traversableDecl) { | ||||
252 | UnsureType::Ptr unsure(new UnsureType()); | ||||
253 | AbstractType::Ptr arrayType = AbstractType::Ptr(new IntegralType(IntegralType::TypeArray)); | ||||
254 | unsure->addType(arrayType->indexed()); | ||||
255 | unsure->addType(traversableDecl->abstractType()->indexed()); | ||||
256 | | ||||
257 | type = AbstractType::Ptr(unsure); | ||||
258 | } | ||||
259 | } | ||||
260 | | ||||
261 | if (type && parameterType->isNullable != -1) { | ||||
262 | AbstractType::Ptr nullType = AbstractType::Ptr(new IntegralType(IntegralType::TypeNull)); | ||||
263 | if (type.cast<UnsureType>()) { | ||||
264 | UnsureType::Ptr unsure = type.cast<UnsureType>(); | ||||
265 | unsure->addType(nullType->indexed()); | ||||
266 | } else { | ||||
267 | UnsureType::Ptr unsure(new UnsureType()); | ||||
268 | unsure->addType(type->indexed()); | ||||
269 | unsure->addType(nullType->indexed()); | ||||
270 | | ||||
271 | type = AbstractType::Ptr(unsure); | ||||
272 | } | ||||
234 | } | 273 | } | ||
235 | } else if (it->element->arrayType != -1) { | | |||
236 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeArray)); | | |||
237 | } else if (it->element->callableType != -1) { | | |||
238 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeMixed)); | | |||
239 | } else if (it->element->defaultValue) { | 274 | } else if (it->element->defaultValue) { | ||
240 | ExpressionVisitor v(m_editor); | 275 | ExpressionVisitor v(m_editor); | ||
241 | it->element->defaultValue->ducontext = m_currentContext; | 276 | it->element->defaultValue->ducontext = m_currentContext; | ||
Context not available. |