编辑器

优化tsl语法解析
This commit is contained in:
JianjunLiu 2022-09-21 15:00:27 +08:00
parent 3b9ac6f107
commit 8cd8af1f06
1 changed files with 24 additions and 29 deletions

View File

@ -4,7 +4,6 @@ interface
@explan(说明) tsl语法编辑器库
**}
uses utslvclauxiliary,UTslMemo;
function FileSaveThreader(o,d);
type TTSLCompletion= class(TSynCompletion)
{**
@explan(说明) tsl提示自动完成类
@ -1266,7 +1265,7 @@ type TBBState =class(tpairstate) //
inherited;
end
end
type TTsfFileParser = class //文件解析
type TTsfFileParser = class() //文件解析
private
fiofs;
public
@ -1276,7 +1275,6 @@ type TTsfFileParser = class //
fiofs := ioFileseparator();
FCacheDir :=TS_GetUserProfileHome()+"TslSynMemo"+fiofs+"cmpCaches";// d["value"];
//FCacheAbsFileName := FCacheDir+"\\cacheabstruct.stm";
//FFileWorker := new TThreadWorker("this.OnMessage :=findfunction('UTslSynMemo.FileSaveThreader') ;");
FFindDirs := array();
end
function DispatchMethod(o,d);//分发消息
@ -1623,7 +1621,6 @@ type TTsfFileParser = class //
end
function ParserFindDir(f); //解析缓存
begin
//mtic;
if FCacheDir then
begin
FFileNames := array();
@ -1651,7 +1648,7 @@ type TTsfFileParser = class //
begin
if FCacheDir then
begin
return ReadParseredFile(n+".tsf");
return ReadParseredFile((n+".tsf"),true);
end
end
function parserafile(dir,v);
@ -1708,7 +1705,6 @@ type TTsfFileParser = class //
for i,v in dirs do
begin
fn := v["FileName"] ;
if not(pos("D",v["Attr"])) and (1=ParseRegExpr("\\.tsf$",fn,"i",m,mp,ml)) then //tsf文件处理
begin
parserafile(dir,v);
@ -1749,7 +1745,7 @@ type TTsfFileParser = class //
if importfile(ftstream(),"",fn,d)=1 then return d;
end
end
function ReadParseredFile(n); //读取解析的文件
function ReadParseredFile(n,g); //读取解析的文件
begin
if FCacheDir then
begin
@ -1760,14 +1756,16 @@ type TTsfFileParser = class //
if d then
begin
FFilePaths[lowercase(n)] := d["fullpath"];
return d;
if g then return d;
return 1;
end
fn := FCacheDir+fiofs+ModifyFname(n)+".p";
if importfile(ftstream(),"",fn,d)=1 and ifarray(d) then
begin
FCacheS[lowercase(n)] := r;//new tparserdobject(d);
FCacheS[lowercase(n)] := d;//new tparserdobject(d);
FFilePaths[lowercase(n)] := d["fullpath"];
return d;
if g then return d;
return 1;
end
end
end
@ -1779,14 +1777,20 @@ type TTsfFileParser = class //
FFinddirsseted := true;
if ifarray(d) and d then
begin
cl := FFindDirs?true:falsse;
FFindDirs := d;
ClearCache();
ClearCache(cl);
end
return r;
end
function ClearCache(); //清空缓存
function ClearCache(cl); //清空缓存
begin
DeleteAllFiles(FCacheDir);
if cl then
begin
DeleteAllFiles(FCacheDir);
end
FFileNames := array();
FFilePaths := array();
FCacheS := array();
end
function filechanged(d);
@ -1806,21 +1810,12 @@ type TTsfFileParser = class //
FFindDirs; //查找目录
fmsgcaches;
end
function FileSaveThreader(o,d);
begin
if not ifarray(d) then return ;
m := d["method"];
f := d["file"];
c := d["content"];
if (m="exportfile") and ifstring(f) and f then
function errtslcode(s); //判断 function procedure结尾搞不定
begin
exportfile(ftstream(),"",f,c);
return 0;
return 0;
end
end
function errtslcode(s); //判断 function procedure结尾搞不定
begin
return 0;
return 0;
end
end.