mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 20:40:40 +02:00
codetools: fixed find used unit with ampersands
This commit is contained in:
parent
d95cdc433a
commit
ab03974ccf
@ -205,6 +205,7 @@ function TrimCodeSpace(const ACode: string): string;
|
||||
function CodeIsOnlySpace(const ACode: string; FromPos, ToPos: integer): boolean;
|
||||
function StringToPascalConst(const s: string): string;
|
||||
function UnicodeSpacesToASCII(const s: string): string;
|
||||
function RemoveAmpersands(const s: string): string;
|
||||
|
||||
// string constants
|
||||
function SplitStringConstant(const StringConstant: string;
|
||||
@ -5768,6 +5769,15 @@ begin
|
||||
until false;
|
||||
end;
|
||||
|
||||
function RemoveAmpersands(const s: string): string;
|
||||
var
|
||||
i: SizeInt;
|
||||
begin
|
||||
Result:=s;
|
||||
for i:=length(Result) downto 1 do
|
||||
if Result[i]='&' then Delete(Result,i,1);
|
||||
end;
|
||||
|
||||
function SplitStringConstant(const StringConstant: string;
|
||||
FirstLineLength, OtherLineLengths, Indent: integer;
|
||||
const aLineBreak: string): string;
|
||||
|
@ -1813,7 +1813,7 @@ begin
|
||||
if Result='' then begin
|
||||
// search in unit set
|
||||
{$IFDEF ShowTriedUnits}
|
||||
DebugLn(['TCTDirectoryCache.FindUnitSourceInCompletePath unit ',AUnitName,' not found in SrcPath="',SrcPath,'" Directory="',Directory,'" searchin in unitset ...']);
|
||||
DebugLn(['TCTDirectoryCache.FindUnitSourceInCompletePath unit ',AUnitName,' not found in SrcPath="',SrcPath,'" Directory="',Directory,'" searching in unitset ...']);
|
||||
{$ENDIF}
|
||||
Result:=FindUnitInUnitSet(AUnitName,FPCSrcSearchRequiresPPU);
|
||||
{$IFDEF ShowTriedUnits}
|
||||
|
@ -3262,27 +3262,13 @@ begin
|
||||
RaiseException(20171214184519,'TFindDeclarationTool.FindUnitSource Invalid Data');
|
||||
if (Scanner.OnLoadSource=nil) then
|
||||
RaiseException(20171214184527,'TFindDeclarationTool.FindUnitSource Invalid Data');
|
||||
// check project source name first
|
||||
if (Tree<>nil) and (Tree.Root<>nil) then begin
|
||||
Node:=Tree.Root.FirstChild;
|
||||
if (Node<>nil) and
|
||||
(Node.Parent.Desc in [ctnProgram, ctnLibrary,ctnPackage]) and
|
||||
(Node.Desc=ctnSrcName) then begin
|
||||
curSrc:= ExtractIdentifierWithPoints(Node.StartPos,false);
|
||||
if (CompareDottedIdentifiers(PChar(curSrc),PChar(AnUnitName))=0)
|
||||
and (Length(curSrc)=Length(AnUnitName)) then
|
||||
Result:=TCodeBuffer(Scanner.OnLoadSource(Self,Scanner.MainFilename,true));
|
||||
end;
|
||||
end;
|
||||
|
||||
if Result=nil then begin // original code, only units
|
||||
NewUnitName:=AnUnitName;
|
||||
NewInFilename:=AnUnitInFilename;
|
||||
NewUnitName:=RemoveAmpersands(AnUnitName);
|
||||
NewInFilename:=AnUnitInFilename;
|
||||
|
||||
AFilename:=DirectoryCache.FindUnitSourceInCompletePath(
|
||||
NewUnitName,NewInFilename,false,false,AddedNameSpace);
|
||||
Result:=TCodeBuffer(Scanner.OnLoadSource(Self,AFilename,true));
|
||||
end;
|
||||
AFilename:=DirectoryCache.FindUnitSourceInCompletePath(
|
||||
NewUnitName,NewInFilename,false,false,AddedNameSpace);
|
||||
Result:=TCodeBuffer(Scanner.OnLoadSource(Self,AFilename,true));
|
||||
|
||||
if (Result=nil) and Assigned(OnFindUsedUnit) then begin
|
||||
// no unit found
|
||||
|
Loading…
Reference in New Issue
Block a user