1 Star 0 Fork 0

旷野芦苇殇/texteditor

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
codeformatter.cpp 1.67 KB
一键复制 编辑 原始数据 按行查看 历史
旷野芦苇殇 提交于 2025-04-30 16:43 +08:00 . 优化代码提示
#include "codeformatter.h"
#include <QDebug>
namespace TextEditor{
CodeFormatter::CodeFormatter(){
}
CodeFormatter::~CodeFormatter(){
}
void CodeFormatter::updateStateUntil(const QTextBlock &block){
}
void CodeFormatter::updateLineStateChange(const QTextBlock &block){
}
int CodeFormatter::indentFor(const QTextBlock &block){
return 0;
}
int CodeFormatter::indentForNewLineAfter(const QTextBlock &block){
return 0;
}
void CodeFormatter::setTabSize(int tabSize){
}
void CodeFormatter::invalidateCache(QTextDocument *document){
}
QList<Code::Token> CodeFormatter::tokenize(const QTextBlock& block){
Q_UNUSED(block);
return {};
}
QList<Code::Token> CodeFormatter::tokenize(const QString& text){
Q_UNUSED(text);
return {};
}
bool CodeFormatter::isInStringORCommentLiteral(const QTextBlock& block,int pos){
if(pos<0 || pos >= block.length()){
return false;
}
auto tokens = this->tokenize(block);
for(auto tk:tokens){
if(tk.offset<=pos && pos <(tk.offset+tk.length)){
if(tk.kind==Code::Token::String || tk.kind==Code::Token::Comment){
return true;
}
}
}
return false;
}
bool CodeFormatter::isIdentifier(QChar chr){
return (chr.isLetterOrNumber() || chr == '_');
}
int CodeFormatter::indentifierPosition(const QTextBlock& block,int pos){
QChar chr;
auto text = block.text();
if(pos<1){
return 0;
}
do{
chr = text.at(--pos);
}while (this->isIdentifier(chr) && pos>0);
return pos;
}
bool CodeFormatter::isVariantKind(int kind){
return (kind == Code::Token::Keyword || kind==Code::Token::Identifier || kind==Code::Token::Variant);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fengzhu2007/texteditor.git
git@gitee.com:fengzhu2007/texteditor.git
fengzhu2007
texteditor
texteditor
main

搜索帮助