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
{
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:
Snapshot();
~Snapshot();
Snapshot simplified(Document::Ptr doc) const;
QByteArray preprocessedCode(const QString &source,
const QString &fileName) const;
......@@ -288,6 +290,9 @@ public:
void insert(Document::Ptr doc);
using _Base::insert;
private:
void simplified_helper(Document::Ptr doc, Snapshot *snapshot) const;
};
} // end of namespace CPlusPlus
......
......@@ -1727,6 +1727,7 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source) const
{
const QByteArray preprocessedCode = source.snapshot.preprocessedCode(source.code, source.fileName);
Document::Ptr doc = source.snapshot.documentFromSource(preprocessedCode, source.fileName);
const Snapshot snapshot = source.snapshot.simplified(doc);
doc->check();
Control *control = doc->control();
......@@ -1741,6 +1742,7 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source) const
SemanticInfo semanticInfo;
semanticInfo.revision = source.revision;
semanticInfo.snapshot = snapshot;
semanticInfo.doc = doc;
semanticInfo.localUses = useTable.localUses;
semanticInfo.externalUses = useTable.externalUses;
......
......@@ -88,6 +88,7 @@ public:
{ }
int revision;
CPlusPlus::Snapshot snapshot;
CPlusPlus::Document::Ptr doc;
LocalUseMap localUses;
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