Changeset View
Changeset View
Standalone View
Standalone View
src/backends/maxima/maximacompletionobject.cpp
Show All 28 Lines | |||||
29 | MaximaCompletionObject::MaximaCompletionObject(const QString& command, int index,MaximaSession* session) : Cantor::CompletionObject(session) | 29 | MaximaCompletionObject::MaximaCompletionObject(const QString& command, int index,MaximaSession* session) : Cantor::CompletionObject(session) | ||
30 | { | 30 | { | ||
31 | qDebug() << "MaximaCompletionObject constructor"; | 31 | qDebug() << "MaximaCompletionObject constructor"; | ||
32 | setLine(command, index); | 32 | setLine(command, index); | ||
33 | } | 33 | } | ||
34 | 34 | | |||
35 | void MaximaCompletionObject::fetchIdentifierType() | 35 | void MaximaCompletionObject::fetchIdentifierType() | ||
36 | { | 36 | { | ||
37 | MaximaVariableModel* model=static_cast<MaximaVariableModel*>(session()->variableModel()); | 37 | QStringList userVariableNames=session()->variableModel()->variableNames(); | ||
38 | QStringList userVariableNames=model->variableNames(); | 38 | QStringList userFunctionNames=session()->variableModel()->functions(); | ||
39 | QStringList userFunctionNames=model->functionNames(true); | | |||
40 | if (qBinaryFind(userVariableNames.begin(), userVariableNames.end(), identifier()) | 39 | if (qBinaryFind(userVariableNames.begin(), userVariableNames.end(), identifier()) | ||
41 | != userVariableNames.end()) | 40 | != userVariableNames.end()) | ||
42 | emit fetchingTypeDone(VariableType); | 41 | emit fetchingTypeDone(VariableType); | ||
43 | else if (qBinaryFind(userFunctionNames.begin(), userFunctionNames.end(), identifier()) | 42 | else if (qBinaryFind(userFunctionNames.begin(), userFunctionNames.end(), identifier()) | ||
44 | != userFunctionNames.end()) | 43 | != userFunctionNames.end()) | ||
45 | emit fetchingTypeDone(FunctionType); | 44 | emit fetchingTypeDone(FunctionType); | ||
46 | else if (qBinaryFind(MaximaKeywords::instance()->functions().begin(), | 45 | else if (qBinaryFind(MaximaKeywords::instance()->functions().begin(), | ||
47 | MaximaKeywords::instance()->functions().end(), identifier()) | 46 | MaximaKeywords::instance()->functions().end(), identifier()) | ||
48 | != MaximaKeywords::instance()->functions().end()) | 47 | != MaximaKeywords::instance()->functions().end()) | ||
49 | emit fetchingTypeDone(FunctionType); | 48 | emit fetchingTypeDone(FunctionType); | ||
50 | else if (qBinaryFind(MaximaKeywords::instance()->keywords().begin(), | 49 | else if (qBinaryFind(MaximaKeywords::instance()->keywords().begin(), | ||
51 | MaximaKeywords::instance()->keywords().end(), identifier()) | 50 | MaximaKeywords::instance()->keywords().end(), identifier()) | ||
52 | != MaximaKeywords::instance()->keywords().end()) | 51 | != MaximaKeywords::instance()->keywords().end()) | ||
53 | emit fetchingTypeDone(KeywordType); | 52 | emit fetchingTypeDone(KeywordType); | ||
54 | else | 53 | else | ||
55 | emit fetchingTypeDone(VariableType); | 54 | emit fetchingTypeDone(VariableType); | ||
56 | } | 55 | } | ||
57 | 56 | | |||
58 | void MaximaCompletionObject::fetchCompletions() | 57 | void MaximaCompletionObject::fetchCompletions() | ||
59 | { | 58 | { | ||
60 | MaximaVariableModel* model=static_cast<MaximaVariableModel*>(session()->variableModel()); | | |||
61 | | ||||
62 | QStringList allCompletions; | 59 | QStringList allCompletions; | ||
63 | allCompletions<<MaximaKeywords::instance()->variables(); | 60 | allCompletions<<MaximaKeywords::instance()->variables(); | ||
64 | allCompletions<<MaximaKeywords::instance()->functions(); | 61 | allCompletions<<MaximaKeywords::instance()->functions(); | ||
65 | allCompletions<<MaximaKeywords::instance()->keywords(); | 62 | allCompletions<<MaximaKeywords::instance()->keywords(); | ||
66 | allCompletions<<model->variableNames(); | 63 | allCompletions<<session()->variableModel()->variableNames(); | ||
67 | allCompletions<<model->functionNames(true); | 64 | allCompletions<<session()->variableModel()->functions(); | ||
68 | 65 | | |||
69 | setCompletions(allCompletions); | 66 | setCompletions(allCompletions); | ||
70 | 67 | | |||
71 | emit fetchingDone(); | 68 | emit fetchingDone(); | ||
72 | } | 69 | } | ||
73 | 70 | | |||
74 | bool MaximaCompletionObject::mayIdentifierContain(QChar c) const | 71 | bool MaximaCompletionObject::mayIdentifierContain(QChar c) const | ||
75 | { | 72 | { | ||
76 | return c.isLetter() || c.isDigit() || c == QLatin1Char('_') || c == QLatin1Char('%'); | 73 | return c.isLetter() || c.isDigit() || c == QLatin1Char('_') || c == QLatin1Char('%'); | ||
77 | } | 74 | } | ||
78 | 75 | | |||
79 | bool MaximaCompletionObject::mayIdentifierBeginWith(QChar c) const | 76 | bool MaximaCompletionObject::mayIdentifierBeginWith(QChar c) const | ||
80 | { | 77 | { | ||
81 | return c.isLetter() || c == QLatin1Char('_') || c == QLatin1Char('%'); | 78 | return c.isLetter() || c == QLatin1Char('_') || c == QLatin1Char('%'); | ||
82 | } | 79 | } |