本文整理汇总了C++中IndexedString类的典型用法代码示例。如果您正苦于以下问题:C++ IndexedString类的具体用法?C++ IndexedString怎么用?C++ IndexedString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IndexedString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
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: execute
void AdaptSignatureAction::execute()
{
ENSURE_CHAIN_NOT_LOCKED
DUChainReadLocker lock;
IndexedString url = m_otherSideTopContext->url();
lock.unlock();
m_otherSideTopContext = DUChain::self()->waitForUpdate(url, TopDUContext::AllDeclarationsContextsAndUses);
if (!m_otherSideTopContext) {
clangDebug() << "failed to update" << url.str();
return;
}
lock.lock();
Declaration* otherSide = m_otherSideId.getDeclaration(m_otherSideTopContext.data());
if (!otherSide) {
clangDebug() << "could not find definition";
return;
}
DUContext* functionContext = DUChainUtils::getFunctionContext(otherSide);
if (!functionContext) {
clangDebug() << "no function context";
return;
}
if (!functionContext || functionContext->type() != DUContext::Function) {
clangDebug() << "no correct function context";
return;
}
DocumentChangeSet changes;
KTextEditor::Range parameterRange = ClangIntegration::DUChainUtils::functionSignatureRange(otherSide);
QString newText = CodegenHelper::makeSignatureString(otherSide, m_newSignature, !m_editingDefinition);
if (!m_editingDefinition) {
// append a newline after the method signature in case the method definition follows
newText += QLatin1Char('\n');
}
DocumentChange changeParameters(functionContext->url(), parameterRange, QString(), newText);
lock.unlock();
changeParameters.m_ignoreOldText = true;
changes.addChange(changeParameters);
changes.setReplacementPolicy(DocumentChangeSet::WarnOnFailedChange);
DocumentChangeSet::ChangeResult result = changes.applyAllChanges();
if (!result) {
KMessageBox::error(nullptr, i18n("Failed to apply changes: %1", result.m_failureReason));
}
emit executed(this);
foreach(RenameAction * renAct, m_renameActions) {
renAct->execute();
}
}
示例3: lock
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);
}
}
}
示例4: getIncludeFileForNode
void UseBuilder::visitUnaryExpression( UnaryExpressionAst* node )
{
IndexedString includeFile = getIncludeFileForNode(node, m_editor);
if ( !includeFile.isEmpty() ) {
QualifiedIdentifier identifier(includeFile.str());
DUChainWriteLocker lock(DUChain::lock());
foreach ( Declaration* dec, currentContext()->topContext()->findDeclarations(identifier) ) {
if ( dec->kind() == Declaration::Import ) {
newUse(node->includeExpression, DeclarationPointer(dec));
return;
}
}
}
示例5: FileCodeRepresentation
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();
}
示例6: 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));
}
示例7: representationForPath
//Return the representation for the given URL if it exists, or an empty pointer otherwise
static QExplicitlySharedDataPointer<ArtificialStringData> representationForPath(const IndexedString& path)
{
if(artificialStrings.contains(path))
return artificialStrings[path];
else
{
IndexedString constructedPath(CodeRepresentation::artificialPath(path.str()));
if(artificialStrings.contains(constructedPath))
return artificialStrings[constructedPath];
else
return QExplicitlySharedDataPointer<ArtificialStringData>();
}
}
示例8: representationForUrl
//Return the representation for the given URL if it exists, or an empty pointer otherwise
KSharedPtr<ArtificialStringData> representationForUrl(const IndexedString& url)
{
if(artificialStrings.contains(url))
return artificialStrings[url];
else
{
IndexedString constructedUrl(CodeRepresentation::artificialUrl(url.str()));
if(artificialStrings.contains(constructedUrl))
return artificialStrings[constructedUrl];
else
return KSharedPtr<ArtificialStringData>();
}
}
示例9: lock
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);
}
}
}
示例10: addDocuments
void ApplyChangesWidget::addDocuments(const IndexedString & original)
{
int idx=d->m_files.indexOf(original);
if(idx<0) {
QWidget * w = new QWidget;
d->m_documentTabs->addTab(w, original.str());
d->m_documentTabs->setCurrentWidget(w);
d->m_files.insert(d->m_index, original);
d->createEditPart(original);
} else {
d->m_index=idx;
}
}
示例11: 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;
}
示例12: m_file
InsertArtificialCodeRepresentation::InsertArtificialCodeRepresentation(const IndexedString& file,
const QString& text)
: m_file(file)
{
if(m_file.toUrl().isRelative())
{
m_file = IndexedString(CodeRepresentation::artificialUrl(file.str()));
int idx = 0;
while(artificialStrings.contains(m_file))
{
++idx;
m_file = IndexedString(CodeRepresentation::artificialUrl(QString("%1_%2").arg(idx).arg(file.str())));
}
}
Q_ASSERT(!artificialStrings.contains(m_file));
artificialStrings.insert(m_file, KSharedPtr<ArtificialStringData>(new ArtificialStringData(text)));
}
示例13: 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);
}
示例14: m_file
InsertArtificialCodeRepresentation::InsertArtificialCodeRepresentation(const IndexedString& file,
const QString& text)
: m_file(file)
{
// make it simpler to use this by converting relative strings into artificial paths
if(QUrl(m_file.str()).isRelative())
{
m_file = IndexedString(CodeRepresentation::artificialPath(file.str()));
int idx = 0;
while(artificialStrings.contains(m_file))
{
++idx;
m_file = IndexedString(CodeRepresentation::artificialPath(QStringLiteral("%1_%2").arg(idx).arg(file.str())));
}
}
Q_ASSERT(!artificialStrings.contains(m_file));
artificialStrings.insert(m_file, QExplicitlySharedDataPointer<ArtificialStringData>(new ArtificialStringData(text)));
}
示例15: 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;
}