📄 ctags.cpp
字号:
/*************************************************************************** * Copyright (C) 2007-2009 by Elad Lahav * elad_lahav@users.sourceforge.net * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the * Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ***************************************************************************/#include "ctags.h"#include "exception.h"namespace KScope{namespace Cscope{QString Ctags::execPath_ = "/usr/bin/ctags";/** * Class constructor. */Ctags::Ctags() : Process(), conn_(NULL){ // Parse a line starting with the following format: // TAG_NAME\tFILE_NAME\tLINE_NUMBER;"\tTAG_TYPE addRule(initState_, Parser::String<>('\t') << Parser::Literal("\t") << Parser::String<>('\t') << Parser::Literal("\t") << Parser::Number() << Parser::Literal(";\"\t") << Parser::String<QRegExp>(QRegExp("[\t\n]")), attrListState_, ParseAction(*this)); // Attribute lists: // *(\tATTRIBUTE_NAME:[ATTRIBUTE_VALUE])\n addRule(attrListState_, Parser::Literal("\t") << Parser::String<>(':') << Parser::Literal(":") << Parser::String<QRegExp, true>(QRegExp("[\t\n]")), attrListState_, ParseAttributeAction(*this)); addRule(attrListState_, Parser::Literal("\n"), initState_);}/** * Class destructor. */Ctags::~Ctags(){}void Ctags::query(Core::Engine::Connection* conn, const QString& file){ // Abort if a process is already running. if (state() != QProcess::NotRunning || conn_ != NULL) throw Core::Exception("Process already running"); // Prepare the argument list. QStringList args; args << "-n" // use line numbers instead of patterns << "--fields=+s" // add scope information << "--sort=no" // do not sort by tag name << "-f" << "-" // output to stdout instead of a file << file; // Initialise parsing. conn_ = conn; conn_->setCtrlObject(this); locList_.clear(); // Start the process. qDebug() << "Running" << execPath_ << args; start(execPath_, args);}/** * Called when the process terminates. * @param code The exit code of the process * @param status Used to indicate process crashes */void Ctags::handleFinished(int code, QProcess::ExitStatus status){ Process::handleFinished(code, status); // Hand over data to the other side of the connection. if (!locList_.isEmpty()) conn_->onDataReady(locList_); // Signal normal termination. conn_->onFinished(); // Detach from the connection object. conn_->setCtrlObject(NULL); conn_ = NULL;}} // namespace Cscope} // namespace KScope
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -