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 void listTags (void) { 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), TagFileName); exit (1); } else { while (tagsNext (file, &entry) == TagSuccess) { #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); } tagsClose (file); } }
bool Parse::getScopeAndLocals(Scope * sc, const QString &expr, const QString &ident) { // initialize scope if nothing better is found sc->scope = ""; sc->localdef = ""; /* create a tags file for `expr' with function names only. * The function with the highest line number is our valid scope * --sort=no, because tags generation probably faster, and * so I just have to look for the last entry to find 'my' tag */ QString command = ctagsCmdPath + " --language-force=c++ --sort=no --fields=fKmnsz --c++-kinds=fn -o \"" + smallTagsFilePath + "\" \"" + parsedFilePath + '\"'; // I don't process any user input, so system() should be safe enough QProcess ctags; ctags.execute(command); QFile::remove (parsedFilePath); if (ctags.exitStatus() == QProcess::CrashExit) return false; /* find the last entry, this is our current scope */ tagFileInfo info; tagFile *tfile = tagsOpen(smallTagsFilePath.toAscii(), &info); tagEntry entry; const char *scope = NULL; if (tfile && info.status.opened) { if (tagsFirst(tfile, &entry) == TagSuccess) { do scope = tagsField(&entry, "class"); while (tagsNext(tfile, &entry) == TagSuccess); } tagsClose(tfile); } /* must be before the 'type = extract_type_qualifier()' code, which modifies scope */ if (scope) sc->scope = scope; /* get local definition (if any) */ if (ident!="") { QString type = extractTypeQualifier(expr, ident); if (type.length()) { sc->localdef = type; } else sc->localdef = ""; } QFile::remove (smallTagsFilePath); return true; }
wxExCTags::wxExCTags(wxExFrame* frame, const std::string& filename) : m_Frame(frame) { tagFileInfo info; for (const auto & it : std::vector < std::string > { "./", wxExConfigDir() + "/"}) { if ((m_File = tagsOpen(std::string(it + filename).c_str(), &info)) != nullptr) { return; // finish, we found a file } } }
static void listTags (void) { 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), TagFileName); exit (1); } else { while (tagsNext (file, &entry) == TagSuccess) printTag (&entry); tagsClose (file); } }
void appl::TextPluginCtags::loadTagFile() { tagFileInfo info; // close previous tag file if (nullptr != m_ctagFile) { tagsClose(m_ctagFile); m_ctagFile = nullptr; } if (m_tagFilename == "") { return; } // load (open) the tag file : APPL_INFO("try to open tag file : " << m_tagFilename); m_ctagFile = tagsOpen(m_tagFilename.c_str(), &info); if (nullptr != m_ctagFile) { APPL_INFO("open exuberant Ctags file is OK ..."); } else { APPL_INFO("Error to open ctags file ..."); } }
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); } }
static void find_tags(const gchar *name, gboolean declaration, gboolean case_sensitive, MatchType match_type) { tagFile *tf; GeanyProject *prj; gchar *tag_filename = NULL; tagEntry entry; tagFileInfo info; prj = geany_data->app->project; if (!prj) return; msgwin_clear_tab(MSG_MESSAGE); msgwin_set_messages_dir(prj->base_path); tag_filename = get_tags_filename(); tf = tagsOpen(tag_filename, &info); if (tf) { if (find_first(tf, &entry, name, match_type)) { GPatternSpec *name_pat; gchar *name_case; gchar *path = NULL; gint num = 0; if (case_sensitive) name_case = g_strdup(name); else name_case = g_utf8_strdown(name, -1); SETPTR(name_case, g_strconcat("*", name_case, "*", NULL)); name_pat = g_pattern_spec_new(name_case); if (!filter_tag(&entry, name_pat, declaration, case_sensitive)) { path = g_build_filename(prj->base_path, entry.file, NULL); show_entry(&entry); num++; } while (find_next(tf, &entry, match_type)) { if (!filter_tag(&entry, name_pat, declaration, case_sensitive)) { if (!path) path = g_build_filename(prj->base_path, entry.file, NULL); show_entry(&entry); num++; } } if (num == 1) { GeanyDocument *doc = document_open_file(path, FALSE, NULL, NULL); if (doc != NULL) { navqueue_goto_line(document_get_current(), doc, entry.address.lineNumber); gtk_widget_grab_focus(GTK_WIDGET(doc->editor->sci)); } } g_pattern_spec_free(name_pat); g_free(name_case); g_free(path); } tagsClose(tf); } msgwin_switch_tab(MSG_MESSAGE, TRUE); g_free(tag_filename); }
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; }