Tulip  4.3.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
AutoCompletionDataBase.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 
20 /**
21  *
22  * This file is part of Tulip (www.tulip-software.org)
23  *
24  * Authors: David Auber and the Tulip development Team
25  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
26  *
27  * Tulip is free software; you can redistribute it and/or modify
28  * it under the terms of the GNU Lesser General Public License
29  * as published by the Free Software Foundation, either version 3
30  * of the License, or (at your option) any later version.
31  *
32  * Tulip is distributed in the hope that it will be useful,
33  * but WITHOUT ANY WARRANTY; without even the implied warranty of
34  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
35  * See the GNU General Public License for more details.
36  *
37  */
38 
39 #ifndef AUTOCOMPLETIONDATABASE_H_
40 #define AUTOCOMPLETIONDATABASE_H_
41 
42 #include <QString>
43 #include <QSet>
44 #include <QHash>
45 
46 #include <tulip/Graph.h>
47 #include <tulip/APIDataBase.h>
48 
49 namespace tlp {
50 
51 class TLP_PYTHON_SCOPE AutoCompletionDataBase {
52 
53  QSet<QString> getSubGraphsListIfContext(const QString &context, const QString &editedFunction) const ;
54  QSet<QString> getGraphPropertiesListIfContext(const QString &context, const QString &editedFunction) const ;
55  QSet<QString> getPluginParametersListIfContext(const QString &context, const QString &editedFunction) const;
56  QString getClassAttributeType(const QString &className, const QString &classAttribute) const;
57 
58  tlp::Graph *_graph;
59  APIDataBase *_apiDb;
60  QSet<QString> _globalAutoCompletionList;
61  QHash<QString, QSet<QString> > _functionAutoCompletionList;
62  QHash<QString, QHash<QString, QString> > _varToType;
63  QHash<QString, QHash<QString, QString> > _classAttributeToType;
64  QHash<QString, QHash<QString, QString> > _varToPluginName;
65  QHash<QString, QHash<QString, QSet<QString> > > _pluginParametersDataSet;
66  QHash<QString, QString> _iteratorType;
67  QHash<QString, QSet<QString> > _classContents;
68  QHash<QString, QSet<QString> > _classBases;
69  QString _lastFoundType;
70 
71 public :
72 
73  AutoCompletionDataBase(APIDataBase *_apiDb = NULL);
74 
75  void setGraph(tlp::Graph * graph) {
76  _graph = graph;
77  }
78 
79  void analyseCurrentScriptCode(const QString &code, const int currentLine, const bool interactiveSession=false, const QString &moduleName="");
80 
81  QSet<QString> getAutoCompletionListForContext(const QString &context, const QString &editedFunction, bool dotContext=false);
82 
83  QString getLastFoundType() const {
84  return _lastFoundType;
85  }
86 
87  QString findTypeForExpr(const QString &expr, const QString &funcName) const ;
88 
89  QVector<QVector<QString> > getParamTypesForMethodOrFunction(const QString &type, const QString &funcName) const;
90 
91  QString getReturnTypeForMethodOrFunction(const QString &type, const QString &funcName) const;
92 
93  QSet<QString> getAllDictForType(const QString &type, const QString &prefix, const bool root=true) const;
94 
95  QString getTypeNameForVar(const QString &varName) const;
96 
97  QString getTypeNameForExpr(const QString &varName) const;
98 
99 };
100 
101 }
102 
103 #endif /* AUTOCOMPLETIONDATABASE_H_ */