mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 17:19:23 +02:00
Codetools: Add unit names correctly to project source. Issue #35803.
git-svn-id: trunk@62169 -
This commit is contained in:
parent
45446f15b8
commit
1ff30d6bfd
@ -2827,8 +2827,7 @@ begin
|
|||||||
MoveCursorToCleanPos(StartPos);
|
MoveCursorToCleanPos(StartPos);
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
ReadNextUsedUnit(NamePos,InPos);
|
ReadNextUsedUnit(NamePos,InPos);
|
||||||
Result:=true;
|
exit(true);
|
||||||
exit;
|
|
||||||
end;
|
end;
|
||||||
if CurPos.Flag=cafSemicolon then break;
|
if CurPos.Flag=cafSemicolon then break;
|
||||||
if CurPos.Flag<>cafComma then break;
|
if CurPos.Flag<>cafComma then break;
|
||||||
@ -2856,8 +2855,8 @@ begin
|
|||||||
if not IsDottedIdentifier(AnUnitName) then
|
if not IsDottedIdentifier(AnUnitName) then
|
||||||
RaiseInvalidUnitName;
|
RaiseInvalidUnitName;
|
||||||
BuildTree(lsrImplementationUsesSectionEnd);
|
BuildTree(lsrImplementationUsesSectionEnd);
|
||||||
if FindInSection(FindMainUsesNode) then exit;
|
if FindInSection(FindMainUsesNode) then exit(true);
|
||||||
if FindInSection(FindImplementationUsesNode) then exit;
|
if FindInSection(FindImplementationUsesNode) then exit(true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFindDeclarationTool.GetUnitNameForUsesSection(
|
function TFindDeclarationTool.GetUnitNameForUsesSection(
|
||||||
@ -6706,12 +6705,13 @@ function TFindDeclarationTool.FindUnitReferences(UnitCode: TCodeBuffer;
|
|||||||
var
|
var
|
||||||
AUnitName, UpperUnitName: String;
|
AUnitName, UpperUnitName: String;
|
||||||
|
|
||||||
function CheckUsesSection(UsesNode: TCodeTreeNode; out Found: boolean): boolean;
|
function CheckUsesSection(UsesNode: TCodeTreeNode): boolean;
|
||||||
|
// Returns True if unit name is found.
|
||||||
var
|
var
|
||||||
ReferencePos: TCodeXYPosition;
|
ReferencePos: TCodeXYPosition;
|
||||||
|
UnitNamePos, UnitInFilePos: TAtomPosition;
|
||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=false;
|
||||||
Found:=false;
|
|
||||||
if UsesNode=nil then exit;
|
if UsesNode=nil then exit;
|
||||||
//DebugLn(['CheckUsesSection ']);
|
//DebugLn(['CheckUsesSection ']);
|
||||||
MoveCursorToNodeStart(UsesNode);
|
MoveCursorToNodeStart(UsesNode);
|
||||||
@ -6722,23 +6722,16 @@ var
|
|||||||
end;
|
end;
|
||||||
repeat
|
repeat
|
||||||
ReadNextAtom; // read name
|
ReadNextAtom; // read name
|
||||||
|
ReadNextUsedUnit(UnitNamePos,UnitInFilePos); // read dotted name + IN file
|
||||||
if CurPos.StartPos>SrcLen then break;
|
if CurPos.StartPos>SrcLen then break;
|
||||||
if AtomIsChar(';') then break;
|
if AtomIsChar(';') then break;
|
||||||
AtomIsIdentifierE;
|
|
||||||
//DebugLn(['CheckUsesSection ',GetAtom,' ',AUnitName]);
|
|
||||||
if UpAtomIs(UpperUnitName) then begin // compare case insensitive
|
if UpAtomIs(UpperUnitName) then begin // compare case insensitive
|
||||||
if CleanPosToCaret(CurPos.StartPos,ReferencePos) then begin
|
if CleanPosToCaret(CurPos.StartPos,ReferencePos) then begin
|
||||||
//DebugLn(['CheckUsesSection found in uses section: ',Dbgs(ReferencePos)]);
|
//DebugLn(['CheckUsesSection found in uses section: ',Dbgs(ReferencePos)]);
|
||||||
Found:=true;
|
Result:=true;
|
||||||
AddCodePosition(ListOfPCodeXYPosition,ReferencePos);
|
AddCodePosition(ListOfPCodeXYPosition,ReferencePos);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
ReadNextAtom;
|
|
||||||
if UpAtomIs('IN') then begin
|
|
||||||
ReadNextAtom;
|
|
||||||
if not AtomIsStringConstant then RaiseStrConstExpected(20170421200522);
|
|
||||||
ReadNextAtom;
|
|
||||||
end;
|
|
||||||
if AtomIsChar(';') then break;
|
if AtomIsChar(';') then break;
|
||||||
if not AtomIsChar(',') then
|
if not AtomIsChar(',') then
|
||||||
RaiseExceptionFmt(20170421200217,ctsStrExpectedButAtomFound,[';',GetAtom])
|
RaiseExceptionFmt(20170421200217,ctsStrExpectedButAtomFound,[';',GetAtom])
|
||||||
@ -6768,7 +6761,6 @@ var
|
|||||||
var
|
var
|
||||||
InterfaceUsesNode: TCodeTreeNode;
|
InterfaceUsesNode: TCodeTreeNode;
|
||||||
ImplementationUsesNode: TCodeTreeNode;
|
ImplementationUsesNode: TCodeTreeNode;
|
||||||
Found: boolean;
|
|
||||||
StartPos: Integer;
|
StartPos: Integer;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
@ -6782,16 +6774,14 @@ begin
|
|||||||
BuildTree(lsrEnd);
|
BuildTree(lsrEnd);
|
||||||
|
|
||||||
InterfaceUsesNode:=FindMainUsesNode;
|
InterfaceUsesNode:=FindMainUsesNode;
|
||||||
if not CheckUsesSection(InterfaceUsesNode,Found) then exit;
|
if CheckUsesSection(InterfaceUsesNode) then
|
||||||
|
StartPos:=InterfaceUsesNode.EndPos
|
||||||
StartPos:=-1;
|
else begin
|
||||||
if Found then begin
|
|
||||||
StartPos:=InterfaceUsesNode.EndPos;
|
|
||||||
end else begin
|
|
||||||
ImplementationUsesNode:=FindImplementationUsesNode;
|
ImplementationUsesNode:=FindImplementationUsesNode;
|
||||||
if not CheckUsesSection(ImplementationUsesNode,Found) then exit;
|
if CheckUsesSection(ImplementationUsesNode) then
|
||||||
if Found then
|
StartPos:=ImplementationUsesNode.EndPos
|
||||||
StartPos:=ImplementationUsesNode.EndPos;
|
else
|
||||||
|
StartPos:=-1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// find unit reference in source
|
// find unit reference in source
|
||||||
|
Loading…
Reference in New Issue
Block a user