Newer
Older
// somebody typed "id." and error recovery still gave us a valid tree,
// so just bail out here.
return 0;
}
idPart = idPart->next;
propertyName = idPart->name->asString();
value = objectValue->lookupMember(propertyName, _context);
if (! value) {
error(idPart->identifierToken,
Check::tr("'%1' is not a member of '%2'").arg(
propertyName, objectValue->className()));
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
void Check::checkAssignInCondition(AST::ExpressionNode *condition)
{
if (_options & WarnAssignInCondition) {
if (BinaryExpression *binary = cast<BinaryExpression *>(condition)) {
if (binary->op == QSOperator::Assign)
warning(binary->operatorToken, tr("avoid assignments in conditions"));
}
}
}
void Check::checkEndsWithControlFlow(StatementList *statements, SourceLocation errorLoc)
{
// full flow analysis would be neat
if (!statements || !(_options & WarnCaseWithoutFlowControlEnd))
return;
Statement *lastStatement = 0;
for (StatementList *slist = statements; slist; slist = slist->next)
lastStatement = slist->statement;
if (!cast<ReturnStatement *>(lastStatement)
&& !cast<ThrowStatement *>(lastStatement)
&& !cast<BreakStatement *>(lastStatement)
&& !cast<ContinueStatement *>(lastStatement)) {
warning(errorLoc, tr("case does not end with return, break, continue or throw"));
}
}
void Check::error(const AST::SourceLocation &loc, const QString &message)
{
_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc, message));
}
void Check::warning(const AST::SourceLocation &loc, const QString &message)
{
_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, loc, message));
}
Node *Check::parent(int distance)
{
const int index = _chain.size() - 2 - distance;
if (index < 0)
return 0;
return _chain.at(index);
}