~ubuntu-branches/ubuntu/trusty/kdevplatform/trusty-proposed

« back to all changes in this revision

Viewing changes to language/backgroundparser/parsejob.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-05-08 18:15:55 UTC
  • mfrom: (0.3.22)
  • Revision ID: package-import@ubuntu.com-20130508181555-iu9n3sh6azd3rs9s
Tags: 1.5.0-0ubuntu1
* New upstream release
* Add build-dep on libgrantlee-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
namespace KDevelop
36
36
{
 
37
class ControlFlowGraph;
 
38
class DataAccessRepository;
37
39
class BackgroundParser;
38
40
class TopDUContext;
39
41
class ReferencedTopDUContext;
48
50
    Q_OBJECT
49
51
 
50
52
public:
51
 
    ParseJob( const KUrl &url );
 
53
    explicit ParseJob( const IndexedString &url, ILanguageSupport* languageSupport );
52
54
    /**
53
55
     * _No_ mutexes/locks are allowed to be locked when this object is destroyed (except for optionally the foreground lock)
54
56
     * */
55
57
    virtual ~ParseJob();
56
58
 
 
59
    /**
 
60
     * @return the language support that created this parse job.
 
61
     */
 
62
    ILanguageSupport* languageSupport() const;
 
63
 
57
64
    struct Contents {
58
65
        // Modification-time of the read content
59
66
        ModificationRevision modification;
79
86
 
80
87
    /**
81
88
     * _No_ mutexes/locks are allowed to be locked when this is called (except for optionally the foreground lock)
82
 
     * 
 
89
     *
83
90
     * Locks the document revision so that mapping from/to the revision in the editor using MovingInterface will be possible.
84
 
     * 
 
91
     *
85
92
     * Returns an invalid pointer if the call succeeds, and a valid one if the reading fails.
86
93
     * */
87
94
    KDevelop::ProblemPointer readContents();
88
 
    
 
95
 
89
96
    /**
90
97
     * After reading the contents, you can call this to retrieve it.
91
98
     * */
92
99
    const Contents& contents() const;
93
 
    
 
100
 
94
101
    /**
95
102
     * Translates the given context from its previous revision to the revision that has
96
103
     * been retrieved during readContents(). The top-context meta-data will be updated
97
104
     * with the revision.
98
 
     * 
 
105
     *
99
106
     * This can be done after reading the context before updating, so
100
107
     * that the correct ranges are matched onto each other during the update.
101
 
     * 
 
108
     *
102
109
     * _No_ mutexes/locks are allowed to be locked when this is called (except for optionally the foreground lock)
103
110
     */
104
111
    void translateDUChainToRevision(TopDUContext* context);
105
 
    
 
112
 
106
113
    /**
107
114
     * Query whether this job is needed to be waited for when trying to process a job with a lower priority.
108
115
     **/
124
131
    * The notification is guaranteed to be called once the parse-job finishes, from within its destructor.
125
132
    * The given top-context may be invalid if the update failed.
126
133
    */
127
 
    Q_SCRIPTABLE void setNotifyWhenReady(QList<QWeakPointer<QObject> > notify);
128
 
    
 
134
    Q_SCRIPTABLE void setNotifyWhenReady(const QList<QWeakPointer<QObject> >& notify);
 
135
 
129
136
    /// Sets the du-context that was created by this parse-job
130
137
    Q_SCRIPTABLE virtual void setDuChain(ReferencedTopDUContext duChain);
131
138
    /// Returns the set du-context, or zero of none was set.
143
150
 
144
151
    /// Set the minimum features the resulting top-context should have
145
152
    Q_SCRIPTABLE void setMinimumFeatures(TopDUContext::Features features);
146
 
    
 
153
 
147
154
    /// Minimum set of features the resulting top-context should have
148
155
    Q_SCRIPTABLE TopDUContext::Features minimumFeatures() const;
149
 
    
 
156
 
150
157
    /// Allows statically specifying an amount of features required for an url.
151
158
    /// These features will automatically be or'ed with the minimumFeatures() returned
152
159
    /// by any ParseJob with the given url.
153
160
    /// Since this causes some additional complixity in update-checking, minimum features should not
154
161
    /// be set permanently.
155
 
    static void setStaticMinimumFeatures(IndexedString url, TopDUContext::Features features);
156
 
    
 
162
    static void setStaticMinimumFeatures(const IndexedString& url, TopDUContext::Features features);
 
163
 
157
164
    /// Must be called exactly once for each call to setStaticMinimumFeatures, with the same features.
158
 
    static void unsetStaticMinimumFeatures(IndexedString url, TopDUContext::Features features);
159
 
    
 
165
    static void unsetStaticMinimumFeatures(const IndexedString& url, TopDUContext::Features features);
 
166
 
160
167
    /// Returns the statically set minimum features for  the given url, or zero.
161
 
    static TopDUContext::Features staticMinimumFeatures(IndexedString url);
162
 
    
 
168
    static TopDUContext::Features staticMinimumFeatures(const IndexedString& url);
 
169
 
163
170
    /// Returns whether there is minimum features set up for some url
164
171
    static bool hasStaticMinimumFeatures();
 
172
    
 
173
    ///Returns a structure containing information about data accesses in the parsed file.
 
174
    /// It's up to the caller to remove the returned instance
 
175
    virtual KDevelop::DataAccessRepository* dataAccessInformation();
 
176
    
 
177
    ///Returns a control flow graph for the code in the parsed file.
 
178
    /// It's up to the caller to remove the returned instance
 
179
    virtual KDevelop::ControlFlowGraph* controlFlowGraph();
165
180
 
166
181
Q_SIGNALS:
167
182
    /**Can be used to give progress feedback to the background-parser. @param value should be between 0 and 1, where 0 = 0% and 1 = 100%
168
183
     * @param text may be a text that describes the current state of parsing
169
184
     * Do not trigger this too often, for performance reasons. */
170
 
    void progress(KDevelop::ParseJob*, float value, QString text);
 
185
    void progress(KDevelop::ParseJob*, float value, const QString& text);
 
186
 
 
187
protected:
 
188
    /**
 
189
     * Checks whether there is already an up to date context available for the
 
190
     * current document. If so, it returns true and ensures that the document
 
191
     * is highlighted properly. Otherwise returns false.
 
192
     *
 
193
     * NOTE: This should be called while holding an URLParseLock for the
 
194
     * current document.
 
195
     *
 
196
     * @param languageString The unique string identifying your language.
 
197
     * This must be the same as you assign to the DUChain's environment file.
 
198
     *
 
199
     * @return True if an update is required, false if the job can return early.
 
200
     */
 
201
    bool isUpdateRequired(const IndexedString& languageString);
 
202
 
 
203
    /**
 
204
     * Trigger an update to the code highlighting of the current file based
 
205
     * on the DUChain set in setDuChain.
 
206
     *
 
207
     * If the file for this parse job is not opened in an editor or if the language
 
208
     * support does not return a code highlighter, this will do nothing.
 
209
     *
 
210
     * NOTE: No DUChain lock should be held when you call this.
 
211
     */
 
212
    void highlightDUChain();
171
213
 
172
214
private:
173
215
    class ParseJobPrivate* const d;