编辑器

修正namespace 代码跳转问题
This commit is contained in:
JianjunLiu 2023-04-17 11:54:35 +08:00
parent b171538798
commit 13e5738b61
2 changed files with 63 additions and 19 deletions

View File

@ -1744,6 +1744,7 @@ type TTsfFileParser = class() //
public public
function Create(); function Create();
begin begin
FNsCaches := array();
fmsgcaches := array(); fmsgcaches := array();
fiofs := ioFileseparator(); fiofs := ioFileseparator();
FCacheDir :=TS_GetUserProfileHome()+"TslSynMemo"+fiofs+"cmpCaches";// d["value"]; FCacheDir :=TS_GetUserProfileHome()+"TslSynMemo"+fiofs+"cmpCaches";// d["value"];
@ -1770,6 +1771,10 @@ type TTsfFileParser = class() //
"finddirs": //查找目录 "finddirs": //查找目录
begin begin
return DirSet(d["value"]); return DirSet(d["value"]);
end
"namespace":
begin
end end
"getfinddirs": "getfinddirs":
begin begin
@ -1797,15 +1802,33 @@ type TTsfFileParser = class() //
end end
end end
private private
function addnsfile(us);
begin
if not ifarray(us) then return array();
r := us;
rl := length(r);
for i,v in us do
begin
for j,vj in FNsCaches[v] do
begin
if vj then
begin
r[rl++] := v+j;
end
end
end
return r;
end
function getinheriteds(r,m,dounits,us,uso,cs,cso); function getinheriteds(r,m,dounits,us,uso,cs,cso);
begin begin
if not ifarray(us) then us := array(); if not ifarray(us) then us := array();
if not ifarray(uso) then uso := array(); if not ifarray(uso) then uso := array();
if not ifarray(cs) then cs := array(); if not ifarray(cs) then cs := array();
if not ifarray(cso) then cso := array(); if not ifarray(cso) then cso := array();
for i,v in r["units"] do for i,v in addnsfile(r["units"]) do
begin begin
vfn := checknamespacename(v); //vfn := checknamespacename(v);
vfn := v;
if m=(lowercase(vfn)+".tsf") then continue; if m=(lowercase(vfn)+".tsf") then continue;
vi := LoadByName(vfn); vi := LoadByName(vfn);
if vi then if vi then
@ -1820,9 +1843,10 @@ type TTsfFileParser = class() //
getinheriteds(vi,m,dounits,us,uso,cs,cso); getinheriteds(vi,m,dounits,us,uso,cs,cso);
end end
end end
for i,v in r["class"] do for i,v in addnsfile(r["class"]) do
begin begin
vfn := checknamespacename(v); vfn := v;
//vfn := checknamespacename(v);
if m=(lowercase(vfn)+".tsf") then continue; if m=(lowercase(vfn)+".tsf") then continue;
vi := LoadByName(vfn); vi := LoadByName(vfn);
if vi then if vi then
@ -1911,16 +1935,17 @@ type TTsfFileParser = class() //
//echo FFilePaths; //echo FFilePaths;
if FFilePaths and not(FFilePaths[v]) then continue; //已经排除 if FFilePaths and not(FFilePaths[v]) then continue; //已经排除
wd := vv["functions"][0]; wd := vv["functions"][0];
if wd and ifarray(wd) and (wd0:=wd[0]) and wd0 and (v=lowercase(wd0)+vv["nspace"]+".tsf") then // nns := vv["nspace"];
if wd and ifarray(wd) and (wd0:=wd[0]) and wd0 and (v=lowercase(wd0)+nns+".tsf") then //
begin begin
t := Formatfparams(wd)+" <locfunc> "+inttostr(vv["lines"][0]); t := Formatfparams(wd)+" <locfunc"+nns+"> "+inttostr(vv["lines"][0]);
d[idx]["value"]:= wd0; d[idx]["value"]:= wd0;
d[idx]["lvalue"] := lowercase(wd0); d[idx]["lvalue"] := lowercase(wd0);
d[idx]["vlen"] := length(wd0); d[idx]["vlen"] := length(wd0);
d[idx]["clen"] := length(t); d[idx]["clen"] := length(t);
d[idx]["jump"] := true; d[idx]["jump"] := true;
d[idx]["caption"] :=t; d[idx]["caption"] :=t;
d[idx]["file"] := wd0+vv["nspace"]; d[idx]["file"] := wd0+nns;
if od>=0 then d[idx]["order"] := od; if od>=0 then d[idx]["order"] := od;
d[idx]["line"] := vv["lines"][0]; d[idx]["line"] := vv["lines"][0];
idx++; idx++;
@ -1931,7 +1956,7 @@ type TTsfFileParser = class() //
begin begin
wd0 := vv["words"][0]; wd0 := vv["words"][0];
if wd0 and ( (lowercase(wd0)+vv["nspace"]+".tsf")=v) then if wd0 and ( (lowercase(wd0)+nns+".tsf")=v) then
begin begin
end else end else
@ -1939,11 +1964,11 @@ type TTsfFileParser = class() //
d[idx]["value"]:= wd0; d[idx]["value"]:= wd0;
d[idx]["lvalue"] := lowercase(wd0); d[idx]["lvalue"] := lowercase(wd0);
d[idx]["vlen"] := length(wd0); d[idx]["vlen"] := length(wd0);
t := wd0+" <file>" ; t := wd0+" <file"+nns+ ">" ;
d[idx]["jump"] := true; d[idx]["jump"] := true;
d[idx]["caption"] := t; d[idx]["caption"] := t;
d[idx]["clen"] := length(t); d[idx]["clen"] := length(t);
d[idx]["file"] := wd0+vv["nspace"]; d[idx]["file"] := wd0+nns;
d[idx]["line"] := 1; d[idx]["line"] := 1;
idx++; idx++;
end end
@ -2061,7 +2086,6 @@ type TTsfFileParser = class() //
li := li .& 0x3FFFFFFF; li := li .& 0x3FFFFFFF;
end end
end end
d[idx]["value"]:= v0; d[idx]["value"]:= v0;
lvl := lowercase(v0); lvl := lowercase(v0);
d[idx]["lvalue"]:= lvl; d[idx]["lvalue"]:= lvl;
@ -2128,7 +2152,7 @@ type TTsfFileParser = class() //
begin begin
fn := lowercase( v["FileName"]); fn := lowercase( v["FileName"]);
if FFileNames[fn] then return ; if FFileNames[fn] then return ;
if fn=mf then return ; //if fn=mf then return ;
pfn := dir+fiofs+fn; pfn := dir+fiofs+fn;
sz := v["Size"]; sz := v["Size"];
flt := v["Time"]; flt := v["Time"];
@ -2158,8 +2182,11 @@ type TTsfFileParser = class() //
r["name"] := fn; r["name"] := fn;
if (aid := pos("@",fn)) then if (aid := pos("@",fn)) then
begin begin
r["nspace"] := fn[aid:(length(fn)-4)]; nn := fn[1:(aid-1)];
r["name"] := fn[1:(aid-1)]; nns := fn[aid:(length(fn)-4)];
r["nspace"] := nns;
r["name"] := nn;
FNsCaches[nn][nns] := 1;
//echo "\r\nfn:",fn[aid:]; //echo "\r\nfn:",fn[aid:];
end else r["nspace"] := ""; end else r["nspace"] := "";
r["msg"] := getmsgd_Crc32(rdd);//GetMsgdigest(rdd,0); r["msg"] := getmsgd_Crc32(rdd);//GetMsgdigest(rdd,0);
@ -2215,7 +2242,13 @@ type TTsfFileParser = class() //
if FCacheDir then if FCacheDir then
begin begin
fn := FCacheDir+fiofs+"lasttime"+fiofs+ModifyFname(n)+".t"; fn := FCacheDir+fiofs+"lasttime"+fiofs+ModifyFname(n)+".t";
if importfile(ftstream(),"",fn,d)=1 then return d; if importfile(ftstream(),"",fn,d)=1 and ifarray(d) then
begin
nns := d["nspace"];
nn := d["name"];
FNsCaches[nn][nns] := 1;
return d;
end
end end
end end
function ReadParseredFile(n,g); //读取解析的文件 function ReadParseredFile(n,g); //读取解析的文件
@ -2242,6 +2275,14 @@ type TTsfFileParser = class() //
end end
end end
end end
function setnamespace(ns);
begin
if FNamespace<>ns then
begin
FNamespace := ns;
ClearCache(FFindDirs?true:false);
end
end
function DirSet(d); //设置 function DirSet(d); //设置
begin begin
if not ifarray(d) then return FFindDirs; if not ifarray(d) then return FFindDirs;
@ -2250,7 +2291,7 @@ type TTsfFileParser = class() //
FFinddirsseted := true; FFinddirsseted := true;
if ifarray(d) and d then if ifarray(d) and d then
begin begin
cl := FFindDirs?true:falsse; cl := FFindDirs?true:false;
FFindDirs := d; FFindDirs := d;
ClearCache(cl); ClearCache(cl);
end end
@ -2265,6 +2306,7 @@ type TTsfFileParser = class() //
FFileNames := array(); FFileNames := array();
FFilePaths := array(); FFilePaths := array();
FCacheS := array(); FCacheS := array();
FNsCaches := array();
end end
function filechanged(d); function filechanged(d);
begin begin
@ -2275,12 +2317,14 @@ type TTsfFileParser = class() //
FFileWorker; FFileWorker;
FFilePaths; FFilePaths;
FCacheS; //缓存 FCacheS; //缓存
FNsCaches;
FCacheblk; FCacheblk;
FFileNames; //文件名 FFileNames; //文件名
FCacheDir; //缓存目录非 \结尾 FCacheDir; //缓存目录非 \结尾
FCacheList;//目录列表 以 FCacheList;//目录列表 以
//FCacheAbsFileName;//缓存概要 //FCacheAbsFileName;//缓存概要
FFindDirs; //查找目录 FFindDirs; //查找目录
FNamespace; //±ðÃû
fmsgcaches; fmsgcaches;
function errtslcode(s); //判断 function procedure结尾搞不定 function errtslcode(s); //判断 function procedure结尾搞不定