本文整理汇总了C++中IndexedString::toUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ IndexedString::toUrl方法的具体用法?C++ IndexedString::toUrl怎么用?C++ IndexedString::toUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IndexedString
的用法示例。
在下文中一共展示了IndexedString::toUrl方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: quickOpenDeclaration
void QuickOpenPlugin::quickOpenDeclaration()
{
if(jumpToSpecialObject())
return;
KDevelop::DUChainReadLocker lock( DUChain::lock() );
Declaration* decl = cursorDeclaration();
if(!decl) {
qCDebug(PLUGIN_QUICKOPEN) << "Found no declaration for cursor, cannot jump";
return;
}
decl->activateSpecialization();
IndexedString u = decl->url();
KTextEditor::Cursor c = decl->rangeInCurrentRevision().start();
if(u.isEmpty()) {
qCDebug(PLUGIN_QUICKOPEN) << "Got empty url for declaration" << decl->toString();
return;
}
lock.unlock();
core()->documentController()->openDocument(u.toUrl(), c);
}
示例2: createCodeRepresentation
CodeRepresentation::Ptr createCodeRepresentation(const IndexedString& path) {
if(artificialCodeRepresentationExists(path))
return CodeRepresentation::Ptr(new StringCodeRepresentation(representationForPath(path)));
IDocument* document = ICore::self()->documentController()->documentForUrl(path.toUrl());
if(document && document->textDocument())
return CodeRepresentation::Ptr(new EditorCodeRepresentation(document->textDocument()));
else
return CodeRepresentation::Ptr(new FileCodeRepresentation(path));
}
示例3: localFile
FileCodeRepresentation(const IndexedString& document) : m_document(document) {
QString localFile(document.toUrl().toLocalFile());
QFile file( localFile );
if ( file.open(QIODevice::ReadOnly) ) {
data = QString::fromLocal8Bit(file.readAll());
lineData = data.split('\n');
}
m_exists = file.exists();
}
示例4: translationUnitForUrl
IndexedString ClangIndex::translationUnitForUrl(const IndexedString& url)
{
{ // try explicit pin data first
QMutexLocker lock(&m_mappingMutex);
auto tu = m_tuForUrl.find(url);
if (tu != m_tuForUrl.end()) {
if (!QFile::exists(tu.value().str())) {
// TU doesn't exist, unpin
m_tuForUrl.erase(tu);
return url;
}
return tu.value();
}
}
// if no explicit pin data is available, follow back the duchain import chain
{
DUChainReadLocker lock;
TopDUContext* top = DUChain::self()->chainForDocument(url);
if (top) {
TopDUContext* tuTop = top;
QSet<TopDUContext*> visited;
while(true) {
visited.insert(tuTop);
TopDUContext* next = nullptr;
auto importers = tuTop->indexedImporters();
foreach(IndexedDUContext ctx, importers) {
if (ctx.data()) {
next = ctx.data()->topContext();
break;
}
}
if (!next || visited.contains(next)) {
break;
}
tuTop = next;
}
if (tuTop != top) {
return tuTop->url();
}
}
}
// otherwise, fallback to a simple buddy search for headers
if (ClangHelpers::isHeader(url.str())) {
foreach(const QUrl& buddy, DocumentFinderHelpers::getPotentialBuddies(url.toUrl(), false)) {
const QString buddyPath = buddy.toLocalFile();
if (QFile::exists(buddyPath)) {
return IndexedString(buddyPath);
}
}
}
示例5: path
QList< ReferencedTopDUContext > ParseSession::contextForThisPackage(IndexedString package)
{
QList<ReferencedTopDUContext> contexts;
QUrl url = package.toUrl();
QDir path(url.adjusted(QUrl::RemoveFilename).path());
if(path.exists())
{
int priority = BackgroundParser::WorstPriority;
if(!forExport)
priority = -1; //import this package as soon as possible
else if(m_priority<=-1)
priority = BackgroundParser::WorstPriority-2;//all needed files should be scheduled already
else
priority = m_priority;//currently parsejob does not get created in this cases to reduce recursion
QStringList files = path.entryList(QStringList("*.go"), QDir::Files | QDir::NoSymLinks);
bool shouldReparse=false;
for(QString filename : files)
{
filename = path.filePath(filename);
QFile file(filename);
if(!file.exists())
continue;
if(forExport && filename.endsWith("_test.go"))
continue;
IndexedString url(filename);
DUChainReadLocker lock;
ReferencedTopDUContext context = DUChain::self()->chainForDocument(url);
lock.unlock();
if(context)
contexts.append(context);
else
{
if(scheduleForParsing(url, priority, (TopDUContext::Features)(TopDUContext::ForceUpdate | TopDUContext::AllDeclarationsAndContexts)))
shouldReparse=true;
}
}
if(shouldReparse)
scheduleForParsing(m_document, priority+1, (TopDUContext::Features)(m_features | TopDUContext::ForceUpdate));
}
return contexts;
}
示例6: createEditPart
void ApplyChangesWidgetPrivate::createEditPart(const IndexedString & file)
{
QWidget * widget = m_documentTabs->currentWidget();
Q_ASSERT(widget);
QVBoxLayout *m=new QVBoxLayout(widget);
QSplitter *v=new QSplitter(widget);
m->addWidget(v);
QUrl url = file.toUrl();
QMimeType mimetype = QMimeDatabase().mimeTypeForUrl(url);
KParts::ReadWritePart* part=KMimeTypeTrader::self()->createPartInstanceFromQuery<KParts::ReadWritePart>(mimetype.name(), widget, widget);
KTextEditor::Document* document=qobject_cast<KTextEditor::Document*>(part);
Q_ASSERT(document);
Q_ASSERT(document->action("file_save"));
document->action("file_save")->setEnabled(false);
m_editParts.insert(m_index, part);
//Open the best code representation, even if it is artificial
CodeRepresentation::Ptr repr = createCodeRepresentation(file);
if(!repr->fileExists())
{
const QString templateName = QDir::tempPath() + QLatin1Char('/') + url.fileName().split('.').last();
QTemporaryFile * temp(new QTemporaryFile(templateName));
temp->open();
temp->write(repr->text().toUtf8());
temp->close();
url = QUrl::fromLocalFile(temp->fileName());
m_temps << temp;
}
m_editParts[m_index]->openUrl(url);
v->addWidget(m_editParts[m_index]->widget());
v->setSizes(QList<int>() << 400 << 100);
}
示例7: compare
bool KompareWidgets::compare(const IndexedString & original, const QString & modified, QWidget * widget, int index)
{
//If there is no current part created, Create it
if( !d->partExists(index) &&
!d->createWidget(index, widget))
return false;
//Prepare the part
KParts::Part * part = d->m_parts[index];
KompareInterface * ipart = qobject_cast<KompareInterface * >(part);
Q_ASSERT(part);
part->widget()->setVisible(true);
part->widget()->resize(part->widget()->parentWidget()->size());
part->widget()->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
//Compare
ipart->compareFileString(original.toUrl(), modified);
//Set to used
d->m_usedWidgets[index] = true;
return true;
}
示例8: translationUnitForUrl
IndexedString ClangIndex::translationUnitForUrl(const IndexedString& url)
{
{ // try explicit pin data first
QMutexLocker lock(&m_mappingMutex);
auto tu = m_tuForUrl.find(url);
if (tu != m_tuForUrl.end()) {
if (!QFile::exists(tu.value().str())) {
// TU doesn't exist, unpin
m_tuForUrl.erase(tu);
return url;
}
return tu.value();
}
}
// otherwise, fallback to a simple buddy search for headers
if (ClangHelpers::isHeader(url.str())) {
foreach(const QUrl& buddy, DocumentFinderHelpers::getPotentialBuddies(url.toUrl(), false)) {
const QString buddyPath = buddy.toLocalFile();
if (QFile::exists(buddyPath)) {
return IndexedString(buddyPath);
}
}
}
示例9: shouldRespectFile
bool UsesCollector::shouldRespectFile(IndexedString document) {
return (bool)ICore::self()->projectController()->findProjectForUrl(document.toUrl()) || (bool)ICore::self()->documentController()->documentForUrl(document.toUrl());
}