本文整理汇总了C++中document::Ptr::source方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::source方法的具体用法?C++ Ptr::source怎么用?C++ Ptr::source使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类document::Ptr
的用法示例。
在下文中一共展示了Ptr::source方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addMessages
void addMessages(QList<QmlJS::DiagnosticMessage> messages,
const Document::Ptr &doc)
{
foreach (const DiagnosticMessage &d, messages) {
int line = d.loc.startLine;
int column = qMax(1U, d.loc.startColumn);
int length = d.loc.length;
int begin = d.loc.begin();
if (d.loc.length == 0) {
QString source(doc->source());
int end = begin;
if (begin == source.size() || source.at(begin) == QLatin1Char('\n')
|| source.at(begin) == QLatin1Char('\r')) {
while (begin > end - column && !source.at(--begin).isSpace()) { }
} else {
while (end < source.size() && source.at(++end).isLetterOrNumber()) { }
}
column += begin - d.loc.begin();
length = end-begin;
}
QTextCharFormat format;
if (d.isWarning())
format.setUnderlineColor(Qt::darkYellow);
else
format.setUnderlineColor(Qt::red);
format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
format.setToolTip(d.message);
collectRanges(begin, length, format);
addDelayedUse(SemanticHighlighter::Use(line, column, length, addFormat(format)));
}
示例2: addMessages
void addMessages(QList<DiagnosticMessage> messages,
const Document::Ptr &doc)
{
foreach (const DiagnosticMessage &d, messages) {
int line = d.loc.startLine;
int column = qMax(1U, d.loc.startColumn);
int length = d.loc.length;
int begin = d.loc.begin();
if (d.loc.length == 0) {
QString source(doc->source());
int end = begin;
if (begin == source.size() || source.at(begin) == QLatin1Char('\n')
|| source.at(begin) == QLatin1Char('\r')) {
while (begin > end - column && !source.at(--begin).isSpace()) { }
} else {
while (end < source.size() && source.at(++end).isLetterOrNumber()) { }
}
column += begin - d.loc.begin();
length = end-begin;
}
const TextEditor::FontSettings &fontSettings = TextEditor::TextEditorSettings::instance()->fontSettings();
QTextCharFormat format;
if (d.isWarning())
format = fontSettings.toTextCharFormat(TextEditor::C_WARNING);
else
format = fontSettings.toTextCharFormat(TextEditor::C_ERROR);
format.setToolTip(d.message);
collectRanges(begin, length, format);
addDelayedUse(SemanticHighlighter::Use(line, column, length, addFormat(format)));
}
示例3: link
QList<QmlJSEditor::FindReferences::Usage> FindImplementation::run(const QString &fileName,
const QString &typeName,
const QString &itemName)
{
QList<QmlJSEditor::FindReferences::Usage> usages;
QmlJS::ModelManagerInterface *modelManager = ModelManagerInterface::instance();
//Parse always the latest version of document
QmlJS::Dialect dialect = QmlJS::ModelManagerInterface::guessLanguageOfFile(fileName);
QmlJS::Document::MutablePtr documentUpdate = QmlJS::Document::create(fileName, dialect);
documentUpdate->setSource(modelManager->workingCopy().source(fileName));
if (documentUpdate->parseQml())
modelManager->updateDocument(documentUpdate);
Document::Ptr document = modelManager->snapshot().document(fileName);
if (!document)
return usages;
QmlJS::Link link(modelManager->snapshot(),
modelManager->defaultVContext(document->language(), document),
modelManager->builtins(document));
ContextPtr context = link();
ScopeChain scopeChain(document, context);
const ObjectValue *targetValue = scopeChain.context()->lookupType(document.data(), QStringList(typeName));
FindImplementationVisitor visitor(document, context);
FindImplementationVisitor::Results results = visitor(typeName, itemName, targetValue);
foreach (const AST::SourceLocation &location, results) {
usages.append(QmlJSEditor::FindReferences::Usage(fileName,
matchingLine(location.offset, document->source()),
location.startLine, location.startColumn - 1, location.length));
}