static void findTag (const char *const name, const int options) { tagFileInfo info; tagEntry entry; tagFile *const file = tagsOpen (TagFileName, &info); if (file == NULL) { fprintf (stderr, "%s: cannot open tag file: %s: %s\n", ProgramName, strerror (info.status.error_number), name); exit (1); } else { if (SortOverride) tagsSetSortType (file, SortMethod); if (tagsFind (file, &entry, name, options) == TagSuccess) { do { printTag (&entry); } while (tagsFindNext (file, &entry) == TagSuccess); } tagsClose (file); } }
static gboolean find_first(tagFile *tf, tagEntry *entry, const gchar *name, MatchType match_type) { gboolean ret; if (match_type == MATCH_PATTERN) ret = tagsFirst(tf, entry) == TagSuccess; else { int options = TAG_IGNORECASE; options |= match_type == MATCH_PREFIX ? TAG_PARTIALMATCH : TAG_FULLMATCH; ret = tagsFind(tf, entry, name, options) == TagSuccess; } return ret; }
bool wxExCTags::Find(const std::string& name) const { tagEntry entry; if (tagsFind(m_File, &entry, name.c_str(), TAG_FULLMATCH) == TagFailure) { if (m_File != nullptr) { wxLogStatus("tag not found: " + wxString(name)); } return false; } const wxExCTagsEntry ct(entry); std::map< std::string, wxExCTagsEntry > v{{ct.GetName(), ct}}; while (tagsFindNext(m_File, &entry) == TagSuccess) { const wxExCTagsEntry ct(entry); v.insert({ct.GetName(), ct}); } if (v.size() == 1) { v.begin()->second.OpenFile(m_Frame); } else { wxArrayString as; for (const auto it : v) as.Add(it.second.GetName()); wxSingleChoiceDialog dialog(m_Frame, _("Input") + ":", _("Select File"), as); if (dialog.ShowModal() != wxID_OK) return false; const auto & it = v.find(dialog.GetStringSelection().ToStdString()); it->second.OpenFile(m_Frame); } return true; }
static void findTag (const char *const name, const int options) { tagFileInfo info; tagEntry entry; tagFile *const file = tagsOpen (TagFileName, &info); if (file == NULL) { fprintf (stderr, "%s: cannot open tag file: %s: %s\n", ProgramName, strerror (info.status.error_number), name); exit (1); } else { if (SortOverride) tagsSetSortType (file, SortMethod); if (debugMode) fprintf (stderr, "%s: searching for \"%s\" in \"%s\"\n", ProgramName, name, TagFileName); if (tagsFind (file, &entry, name, options) == TagSuccess) { do { #ifdef QUALIFIER if (Qualifier) { int i = q_is_acceptable (Qualifier, &entry); switch (i) { case Q_REJECT: continue; case Q_ERROR: exit (1); } } #endif printTag (&entry); } while (tagsFindNext (file, &entry) == TagSuccess); } tagsClose (file); } }
void appl::TextPluginCtags::jumpTo(const std::string& _name) { if (m_ctagFile == nullptr) { APPL_WARNING("No ctags file open"); return; } tagEntry entry; APPL_INFO("try to find the tag : " << _name); if (tagsFind (m_ctagFile, &entry, _name.c_str(), 0) != TagSuccess) { APPL_INFO("no tag find ..."); return; } tagEntry entrySave = entry; int32_t numberOfTags = 0; // For all tags : Save in an internal Structure : std::string tmpFile(m_tagFolderBase + "/" + entry.file); etk::FSNode myfile(tmpFile); int32_t lineID = entry.address.lineNumber; printTag(&entry); if (tagsFindNext (m_ctagFile, &entry) == TagSuccess) { APPL_INFO("Multiple file destination ..."); ememory::SharedPtr<appl::TagFileSelection> tmpWidget = appl::TagFileSelection::create(); if (tmpWidget == nullptr) { APPL_ERROR("Can not allocate widget == > display might be in error"); } else { tmpWidget->addCtagsNewItem(myfile.getFileSystemName(), lineID); do { tmpFile = m_tagFolderBase + "/" + entry.file; myfile = tmpFile; lineID = entry.address.lineNumber; printTag(&entry); tmpWidget->addCtagsNewItem(myfile.getFileSystemName(), lineID); } while (tagsFindNext (m_ctagFile, &entry) == TagSuccess); ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget); tmpWidget->signalSelect.connect(sharedFromThis(), &appl::TextPluginCtags::onCallbackOpenCtagsSelectReturn); } } else { jumpFile(myfile.getName(), lineID - 1); } }
QString Parse::getTypeOfToken(const QString &ident, const QString &className, Scope * scope, bool token_is_function) { /* if we have a variable and already found a local definition, just return it after duplicating */ if (!token_is_function && scope->localdef.length()) return scope->localdef; /* if the identifier is this-> return the current class */ if (ident == "this") return scope->scope; Tree *tree = NULL; if (className.length()) { tree = Tree::buildInheritanceTree(className); if (!tree) return NULL; } tagFileInfo info; tagEntry entry; tagFile *tfile = tagsOpen(tagsFilePath.toAscii(), &info); if (tfile && info.status.opened) { if (tagsFind(tfile, &entry, ident.toAscii(), TAG_OBSERVECASE | TAG_FULLMATCH) == TagSuccess) { do { if (tree && !tree->isMemberOfScope(&entry, scope)) continue; const char *kind = tagsField(&entry, "kind"); if (token_is_function) /* only list if tag is a function */ { if (!kind || (strcmp(kind, "function") && strcmp(kind, "prototype"))) continue; } else /* or a variable */ { //brc: add externvar for extern variables like cout if (!kind || (strcmp(kind, "variable") && strcmp(kind, "externvar") //brc: namespace workarround: add namespace && strcmp(kind, "namespace") && strcmp(kind, "member"))) continue; } /* need to duplicate the pattern, don't ask me why */ QString type = extractTypeQualifier(entry.address.pattern, ident); if(tree) tree->freeTree(); tagsClose(tfile); return type; } while (tagsFindNext(tfile, &entry) == TagSuccess); } tagsClose(tfile); } return NULL; }