Skip to content

Commit 8a49e32

Browse files
committed
Detect when we are in the uses section or elsewhere
1 parent d042826 commit 8a49e32

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

apps/ide/sourcepage.pas

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,8 +1202,20 @@ procedure tsourcepage.hidehint;
12021202
end;
12031203

12041204
procedure tsourcepage.showlink(const apos: gridcoordty);
1205+
var
1206+
pos1: sourceposty;
1207+
str1: msestring;
1208+
startword: gridcoordty;
12051209
begin
1206-
edit.showlink(apos,pascaldelims + '[]');
1210+
pos1.pos:= apos;
1211+
if inusessection(edit,pos1) then
1212+
begin
1213+
// In uses statements, don't use dot as delimiter to support namespace units
1214+
startword := edit.wordatpos(pos1.pos,str1,defaultdelimchars + ',;{}/',[]);
1215+
edit.showlink(startword,pascaldelims + '[]')
1216+
end
1217+
else
1218+
edit.showlink(apos,pascaldelims + '.[]');
12071219
end;
12081220

12091221
procedure tsourcepage.editontextmouseevent(const sender: tobject;
@@ -1253,6 +1265,8 @@ procedure tsourcepage.editontextmouseevent(const sender: tobject;
12531265
if (shiftstate1 = [ss_ctrl,ss_left]) {and active} then begin
12541266
// include(info.mouseeventinfopo^.eventstate,es_processed);
12551267
pos1.pos:= info.pos;
1268+
if inusessection(edit,pos1) then
1269+
pos1.pos:= edit.wordatpos(info.pos,str1,defaultdelimchars + ',;{}/',[]);
12561270
pos1.filename:= designer.designfiles.find(edit.filename);
12571271
if findlinkdest(edit,pos1,str1) then begin
12581272
fshowsourcepos:= pos1;

apps/ide/sourceupdate.pas

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ function completeclass(const filename: filenamety; var pos: sourceposty): boolea
256256
function getimplementationtext(const amodule: tmsecomponent; out aunit: punitinfoty;
257257
out start,stop: sourceposty; out adest: msestring): boolean;
258258
//false if not found
259+
260+
function inusessection(const edit: tsyntaxedit; var apos: sourceposty): Boolean;
261+
259262
implementation
260263
uses
261264
sysutils,msesys,msefileutils,sourceform,sourcepage,projectoptionsform,
@@ -269,6 +272,34 @@ implementation
269272
{$endif}
270273
{$endif}
271274

275+
function inusessection(const edit: tsyntaxedit; var apos: sourceposty): Boolean;
276+
var
277+
po1: punitinfoty;
278+
po2: psourceitemty;
279+
str1: msestring;
280+
startword: gridcoordty;
281+
apos2: sourceposty;
282+
begin
283+
Result := False;
284+
285+
startword := edit.wordatpos(apos.pos,str1,defaultdelimchars + ',;{}/',[]);
286+
apos2.pos := startword;
287+
288+
with sourceupdater do
289+
if not application.waitcanceled then
290+
begin
291+
po1 := updatesourceunit(edit.filename, apos2.filenum, false);
292+
293+
if updateline(po1, apos2) then
294+
begin
295+
po2 := findsourceitem(po1, apos2);
296+
if po2 <> nil then
297+
if po2^.kind = sik_uses then
298+
Result := True;
299+
end;
300+
end;
301+
end;
302+
272303
function findprogramlanguage(const afilename: filenamety): proglangty;
273304
var
274305
mstr1: msestring;

0 commit comments

Comments
 (0)