Commit fd4dbd74 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Introduced Snapshot::simplified(doc)

parent 300b60fa
...@@ -386,3 +386,25 @@ QSharedPointer<NamespaceBinding> Snapshot::globalNamespaceBinding(Document::Ptr ...@@ -386,3 +386,25 @@ QSharedPointer<NamespaceBinding> Snapshot::globalNamespaceBinding(Document::Ptr
{ {
return CPlusPlus::bind(doc, *this); return CPlusPlus::bind(doc, *this);
} }
Snapshot Snapshot::simplified(Document::Ptr doc) const
{
Snapshot snapshot;
simplified_helper(doc, &snapshot);
return snapshot;
}
void Snapshot::simplified_helper(Document::Ptr doc, Snapshot *snapshot) const
{
if (! doc)
return;
if (! snapshot->contains(doc->fileName())) {
snapshot->insert(doc);
foreach (const Document::Include &incl, doc->includes()) {
Document::Ptr includedDoc = value(incl.fileName());
simplified_helper(includedDoc, snapshot);
}
}
}
...@@ -277,6 +277,8 @@ public: ...@@ -277,6 +277,8 @@ public:
Snapshot(); Snapshot();
~Snapshot(); ~Snapshot();
Snapshot simplified(Document::Ptr doc) const;
QByteArray preprocessedCode(const QString &source, QByteArray preprocessedCode(const QString &source,
const QString &fileName) const; const QString &fileName) const;
...@@ -288,6 +290,9 @@ public: ...@@ -288,6 +290,9 @@ public:
void insert(Document::Ptr doc); void insert(Document::Ptr doc);
using _Base::insert; using _Base::insert;
private:
void simplified_helper(Document::Ptr doc, Snapshot *snapshot) const;
}; };
} // end of namespace CPlusPlus } // end of namespace CPlusPlus
......
...@@ -1727,6 +1727,7 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source) const ...@@ -1727,6 +1727,7 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source) const
{ {
const QByteArray preprocessedCode = source.snapshot.preprocessedCode(source.code, source.fileName); const QByteArray preprocessedCode = source.snapshot.preprocessedCode(source.code, source.fileName);
Document::Ptr doc = source.snapshot.documentFromSource(preprocessedCode, source.fileName); Document::Ptr doc = source.snapshot.documentFromSource(preprocessedCode, source.fileName);
const Snapshot snapshot = source.snapshot.simplified(doc);
doc->check(); doc->check();
Control *control = doc->control(); Control *control = doc->control();
...@@ -1741,6 +1742,7 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source) const ...@@ -1741,6 +1742,7 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source) const
SemanticInfo semanticInfo; SemanticInfo semanticInfo;
semanticInfo.revision = source.revision; semanticInfo.revision = source.revision;
semanticInfo.snapshot = snapshot;
semanticInfo.doc = doc; semanticInfo.doc = doc;
semanticInfo.localUses = useTable.localUses; semanticInfo.localUses = useTable.localUses;
semanticInfo.externalUses = useTable.externalUses; semanticInfo.externalUses = useTable.externalUses;
......
...@@ -88,6 +88,7 @@ public: ...@@ -88,6 +88,7 @@ public:
{ } { }
int revision; int revision;
CPlusPlus::Snapshot snapshot;
CPlusPlus::Document::Ptr doc; CPlusPlus::Document::Ptr doc;
LocalUseMap localUses; LocalUseMap localUses;
ExternalUseMap externalUses; ExternalUseMap externalUses;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment