mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 15:59:15 +02:00
codetools: move Find*UsesSection to TPascalParserTool, issue #28285
git-svn-id: trunk@49342 -
This commit is contained in:
parent
fc378e05ef
commit
2f643bd4d4
@ -1308,7 +1308,7 @@ begin
|
|||||||
Indent:=Beauty.GetLineIndent(Src,InFrontOfNode.StartPos);
|
Indent:=Beauty.GetLineIndent(Src,InFrontOfNode.StartPos);
|
||||||
InsertPos:=FindLineEndOrCodeInFrontOfPosition(InFrontOfNode.StartPos);
|
InsertPos:=FindLineEndOrCodeInFrontOfPosition(InFrontOfNode.StartPos);
|
||||||
end else begin
|
end else begin
|
||||||
Node:=FindMainUsesSection(false);
|
Node:=FindMainUsesNode(false);
|
||||||
if Node<>nil then begin
|
if Node<>nil then begin
|
||||||
// insert behind uses section
|
// insert behind uses section
|
||||||
Indent:=Beauty.GetLineIndent(Src,Node.StartPos);
|
Indent:=Beauty.GetLineIndent(Src,Node.StartPos);
|
||||||
@ -7917,7 +7917,7 @@ begin
|
|||||||
Result:=true;
|
Result:=true;
|
||||||
if (fNewMainUsesSectionUnits=nil) then exit;
|
if (fNewMainUsesSectionUnits=nil) then exit;
|
||||||
//DebugLn(['TCodeCompletionCodeTool.InsertAllNewUnitsToMainUsesSection ']);
|
//DebugLn(['TCodeCompletionCodeTool.InsertAllNewUnitsToMainUsesSection ']);
|
||||||
UsesNode:=FindMainUsesSection;
|
UsesNode:=FindMainUsesNode;
|
||||||
|
|
||||||
// remove units, that are already in the uses section
|
// remove units, that are already in the uses section
|
||||||
CurSourceName:=GetSourceName(false);
|
CurSourceName:=GetSourceName(false);
|
||||||
|
@ -1059,7 +1059,7 @@ begin
|
|||||||
exit(true);
|
exit(true);
|
||||||
end;
|
end;
|
||||||
// search in used units
|
// search in used units
|
||||||
UsesNode:=FindMainUsesSection;
|
UsesNode:=FindMainUsesNode;
|
||||||
if UsesNode=nil then begin
|
if UsesNode=nil then begin
|
||||||
debugln(['TEventsCodeTool.FindClassOfInstance no main uses section found']);
|
debugln(['TEventsCodeTool.FindClassOfInstance no main uses section found']);
|
||||||
if ExceptionOnNotFound then RaiseClassNotFound;
|
if ExceptionOnNotFound then RaiseClassNotFound;
|
||||||
|
@ -768,8 +768,8 @@ type
|
|||||||
): TCodeTreeNode; // search for type, const, var, proc, prop
|
): TCodeTreeNode; // search for type, const, var, proc, prop
|
||||||
|
|
||||||
function FindInitializationSection: TCodeTreeNode; deprecated; // use FindInitializationNode
|
function FindInitializationSection: TCodeTreeNode; deprecated; // use FindInitializationNode
|
||||||
function FindMainUsesSection(UseContainsSection: boolean = false): TCodeTreeNode;
|
function FindMainUsesSection(UseContainsSection: boolean = false): TCodeTreeNode; deprecated; // use FindMainUsesNode
|
||||||
function FindImplementationUsesSection: TCodeTreeNode;
|
function FindImplementationUsesSection: TCodeTreeNode; deprecated; // use FindImplementationUsesNode
|
||||||
function FindNameInUsesSection(UsesNode: TCodeTreeNode;
|
function FindNameInUsesSection(UsesNode: TCodeTreeNode;
|
||||||
const AUnitName: string): TCodeTreeNode;
|
const AUnitName: string): TCodeTreeNode;
|
||||||
function FindUnitInUsesSection(UsesNode: TCodeTreeNode;
|
function FindUnitInUsesSection(UsesNode: TCodeTreeNode;
|
||||||
@ -1719,7 +1719,7 @@ begin
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
if Identifier='' then exit;
|
if Identifier='' then exit;
|
||||||
BuildTree(lsrMainUsesSectionEnd);
|
BuildTree(lsrMainUsesSectionEnd);
|
||||||
UsesNode:=FindMainUsesSection;
|
UsesNode:=FindMainUsesNode;
|
||||||
if UsesNode=nil then exit;
|
if UsesNode=nil then exit;
|
||||||
|
|
||||||
Params:=TFindDeclarationParams.Create;
|
Params:=TFindDeclarationParams.Create;
|
||||||
@ -1957,34 +1957,12 @@ end;
|
|||||||
function TFindDeclarationTool.FindMainUsesSection(UseContainsSection: boolean
|
function TFindDeclarationTool.FindMainUsesSection(UseContainsSection: boolean
|
||||||
): TCodeTreeNode;
|
): TCodeTreeNode;
|
||||||
begin
|
begin
|
||||||
Result:=Tree.Root;
|
Result := FindMainUsesNode(UseContainsSection);
|
||||||
if Result=nil then exit;
|
|
||||||
if UseContainsSection then begin
|
|
||||||
if Result.Desc<>ctnPackage then exit(nil);
|
|
||||||
Result:=Result.FirstChild;
|
|
||||||
while (Result<>nil) and (Result.Desc<>ctnContainsSection) do
|
|
||||||
Result:=Result.NextBrother;
|
|
||||||
end else begin
|
|
||||||
if Result.Desc=ctnUnit then begin
|
|
||||||
Result:=Result.NextBrother;
|
|
||||||
if Result=nil then exit;
|
|
||||||
end;
|
|
||||||
Result:=Result.FirstChild;
|
|
||||||
if (Result=nil) then exit;
|
|
||||||
if (Result.Desc<>ctnUsesSection) then Result:=nil;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFindDeclarationTool.FindImplementationUsesSection: TCodeTreeNode;
|
function TFindDeclarationTool.FindImplementationUsesSection: TCodeTreeNode;
|
||||||
begin
|
begin
|
||||||
Result:=Tree.Root;
|
Result := FindImplementationUsesNode;
|
||||||
if Result=nil then exit;
|
|
||||||
while (Result<>nil) and (Result.Desc<>ctnImplementation) do
|
|
||||||
Result:=Result.NextBrother;
|
|
||||||
if Result=nil then exit;
|
|
||||||
Result:=Result.FirstChild;
|
|
||||||
if (Result=nil) then exit;
|
|
||||||
if (Result.Desc<>ctnUsesSection) then Result:=nil;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFindDeclarationTool.FindNameInUsesSection(UsesNode: TCodeTreeNode;
|
function TFindDeclarationTool.FindNameInUsesSection(UsesNode: TCodeTreeNode;
|
||||||
@ -2084,13 +2062,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// check if already there
|
// check if already there
|
||||||
UsesNode:=FindMainUsesSection;
|
UsesNode:=FindMainUsesNode;
|
||||||
if (UsesNode<>nil) and (FindNameInUsesSection(UsesNode,Result)<>nil)
|
if (UsesNode<>nil) and (FindNameInUsesSection(UsesNode,Result)<>nil)
|
||||||
then begin
|
then begin
|
||||||
Result:='';
|
Result:='';
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
UsesNode:=FindImplementationUsesSection;
|
UsesNode:=FindImplementationUsesNode;
|
||||||
if (UsesNode<>nil) and (FindNameInUsesSection(UsesNode,Result)<>nil)
|
if (UsesNode<>nil) and (FindNameInUsesSection(UsesNode,Result)<>nil)
|
||||||
then begin
|
then begin
|
||||||
Result:='';
|
Result:='';
|
||||||
@ -2230,12 +2208,12 @@ begin
|
|||||||
//debugln(['TFindDeclarationTool.FindUnitFileInAllUsesSections Self=',ExtractFilename(MainFilename),' Search=',ExtractFilename(AFilename)]);
|
//debugln(['TFindDeclarationTool.FindUnitFileInAllUsesSections Self=',ExtractFilename(MainFilename),' Search=',ExtractFilename(AFilename)]);
|
||||||
if AFilename='' then exit;
|
if AFilename='' then exit;
|
||||||
if CheckMain then begin
|
if CheckMain then begin
|
||||||
Result:=FindUnitFileInUsesSection(FindMainUsesSection,AFilename);
|
Result:=FindUnitFileInUsesSection(FindMainUsesNode,AFilename);
|
||||||
//debugln(['TFindDeclarationTool.FindUnitFileInAllUsesSections Self=',ExtractFilename(MainFilename),' Search=',ExtractFilename(AFilename),' used in main uses=',Result<>nil]);
|
//debugln(['TFindDeclarationTool.FindUnitFileInAllUsesSections Self=',ExtractFilename(MainFilename),' Search=',ExtractFilename(AFilename),' used in main uses=',Result<>nil]);
|
||||||
if Result<>nil then exit;
|
if Result<>nil then exit;
|
||||||
end;
|
end;
|
||||||
if CheckImplementation then
|
if CheckImplementation then
|
||||||
Result:=FindUnitFileInUsesSection(FindImplementationUsesSection,AFilename);
|
Result:=FindUnitFileInUsesSection(FindImplementationUsesNode,AFilename);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFindDeclarationTool.FindUnitSource(const AnUnitName,
|
function TFindDeclarationTool.FindUnitSource(const AnUnitName,
|
||||||
@ -5168,14 +5146,14 @@ begin
|
|||||||
try
|
try
|
||||||
BuildTree(lsrEnd);
|
BuildTree(lsrEnd);
|
||||||
|
|
||||||
InterfaceUsesNode:=FindMainUsesSection;
|
InterfaceUsesNode:=FindMainUsesNode;
|
||||||
if not CheckUsesSection(InterfaceUsesNode,Found) then exit;
|
if not CheckUsesSection(InterfaceUsesNode,Found) then exit;
|
||||||
|
|
||||||
StartPos:=-1;
|
StartPos:=-1;
|
||||||
if Found then begin
|
if Found then begin
|
||||||
StartPos:=InterfaceUsesNode.EndPos;
|
StartPos:=InterfaceUsesNode.EndPos;
|
||||||
end else begin
|
end else begin
|
||||||
ImplementationUsesNode:=FindImplementationUsesSection;
|
ImplementationUsesNode:=FindImplementationUsesNode;
|
||||||
if not CheckUsesSection(ImplementationUsesNode,Found) then exit;
|
if not CheckUsesSection(ImplementationUsesNode,Found) then exit;
|
||||||
if Found then
|
if Found then
|
||||||
StartPos:=ImplementationUsesNode.EndPos;
|
StartPos:=ImplementationUsesNode.EndPos;
|
||||||
|
@ -1698,14 +1698,14 @@ begin
|
|||||||
debugln(['TCodyIdentifiersDlg.AddToUsesSection "',NewUnitName,'" is hidden used unit']);
|
debugln(['TCodyIdentifiersDlg.AddToUsesSection "',NewUnitName,'" is hidden used unit']);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
UsesNode:=CurTool.FindMainUsesSection;
|
UsesNode:=CurTool.FindMainUsesNode;
|
||||||
if (UsesNode<>nil) and (CurTool.FindNameInUsesSection(UsesNode,NewUnitName)<>nil)
|
if (UsesNode<>nil) and (CurTool.FindNameInUsesSection(UsesNode,NewUnitName)<>nil)
|
||||||
then begin
|
then begin
|
||||||
debugln(['TCodyIdentifiersDlg.AddToUsesSection "',NewUnitName,'" is already used in main uses section']);
|
debugln(['TCodyIdentifiersDlg.AddToUsesSection "',NewUnitName,'" is already used in main uses section']);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if CurInImplementation then begin
|
if CurInImplementation then begin
|
||||||
UsesNode:=CurTool.FindImplementationUsesSection;
|
UsesNode:=CurTool.FindImplementationUsesNode;
|
||||||
if (UsesNode<>nil) and (CurTool.FindNameInUsesSection(UsesNode,NewUnitName)<>nil)
|
if (UsesNode<>nil) and (CurTool.FindNameInUsesSection(UsesNode,NewUnitName)<>nil)
|
||||||
then begin
|
then begin
|
||||||
debugln(['TCodyIdentifiersDlg.AddToUsesSection "',NewUnitName,'" is already used in implementation uses section']);
|
debugln(['TCodyIdentifiersDlg.AddToUsesSection "',NewUnitName,'" is already used in implementation uses section']);
|
||||||
|
@ -267,7 +267,9 @@ type
|
|||||||
// sections / scan range
|
// sections / scan range
|
||||||
function FindRootNode(Desc: TCodeTreeNodeDesc): TCodeTreeNode;
|
function FindRootNode(Desc: TCodeTreeNodeDesc): TCodeTreeNode;
|
||||||
function FindInterfaceNode: TCodeTreeNode;
|
function FindInterfaceNode: TCodeTreeNode;
|
||||||
|
function FindMainUsesNode(UseContainsSection: boolean = false): TCodeTreeNode;
|
||||||
function FindImplementationNode: TCodeTreeNode;
|
function FindImplementationNode: TCodeTreeNode;
|
||||||
|
function FindImplementationUsesNode: TCodeTreeNode;
|
||||||
function FindInitializationNode: TCodeTreeNode;
|
function FindInitializationNode: TCodeTreeNode;
|
||||||
function FindFinalizationNode: TCodeTreeNode;
|
function FindFinalizationNode: TCodeTreeNode;
|
||||||
function FindMainBeginEndNode: TCodeTreeNode;
|
function FindMainBeginEndNode: TCodeTreeNode;
|
||||||
@ -5866,6 +5868,18 @@ begin
|
|||||||
Result:=FindRootNode(ctnImplementation);
|
Result:=FindRootNode(ctnImplementation);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TPascalParserTool.FindImplementationUsesNode: TCodeTreeNode;
|
||||||
|
begin
|
||||||
|
Result:=Tree.Root;
|
||||||
|
if Result=nil then exit;
|
||||||
|
while (Result<>nil) and (Result.Desc<>ctnImplementation) do
|
||||||
|
Result:=Result.NextBrother;
|
||||||
|
if Result=nil then exit;
|
||||||
|
Result:=Result.FirstChild;
|
||||||
|
if (Result=nil) then exit;
|
||||||
|
if (Result.Desc<>ctnUsesSection) then Result:=nil;
|
||||||
|
end;
|
||||||
|
|
||||||
function TPascalParserTool.FindInitializationNode: TCodeTreeNode;
|
function TPascalParserTool.FindInitializationNode: TCodeTreeNode;
|
||||||
begin
|
begin
|
||||||
Result:=FindRootNode(ctnInitialization);
|
Result:=FindRootNode(ctnInitialization);
|
||||||
@ -5891,6 +5905,27 @@ begin
|
|||||||
if Result.Desc<>ctnBeginBlock then Result:=nil;
|
if Result.Desc<>ctnBeginBlock then Result:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TPascalParserTool.FindMainUsesNode(UseContainsSection: boolean
|
||||||
|
): TCodeTreeNode;
|
||||||
|
begin
|
||||||
|
Result:=Tree.Root;
|
||||||
|
if Result=nil then exit;
|
||||||
|
if UseContainsSection then begin
|
||||||
|
if Result.Desc<>ctnPackage then exit(nil);
|
||||||
|
Result:=Result.FirstChild;
|
||||||
|
while (Result<>nil) and (Result.Desc<>ctnContainsSection) do
|
||||||
|
Result:=Result.NextBrother;
|
||||||
|
end else begin
|
||||||
|
if Result.Desc=ctnUnit then begin
|
||||||
|
Result:=Result.NextBrother;
|
||||||
|
if Result=nil then exit;
|
||||||
|
end;
|
||||||
|
Result:=Result.FirstChild;
|
||||||
|
if (Result=nil) then exit;
|
||||||
|
if (Result.Desc<>ctnUsesSection) then Result:=nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TPascalParserTool.FindFirstSectionChild: TCodeTreeNode;
|
function TPascalParserTool.FindFirstSectionChild: TCodeTreeNode;
|
||||||
begin
|
begin
|
||||||
Result:=Tree.Root;
|
Result:=Tree.Root;
|
||||||
|
@ -603,8 +603,8 @@ begin
|
|||||||
// first collect all units
|
// first collect all units
|
||||||
if not FindUsedUnitNames(ExistingUnits) then exit;
|
if not FindUsedUnitNames(ExistingUnits) then exit;
|
||||||
// then change uses sections
|
// then change uses sections
|
||||||
Replace(FindMainUsesSection);
|
Replace(FindMainUsesNode);
|
||||||
Replace(FindImplementationUsesSection);
|
Replace(FindImplementationUsesNode);
|
||||||
finally
|
finally
|
||||||
ExistingUnits.Free;
|
ExistingUnits.Free;
|
||||||
end;
|
end;
|
||||||
@ -950,7 +950,7 @@ begin
|
|||||||
if UsesSection=usMain then begin
|
if UsesSection=usMain then begin
|
||||||
// quick check using only the main uses section
|
// quick check using only the main uses section
|
||||||
BuildTree(lsrMainUsesSectionEnd);
|
BuildTree(lsrMainUsesSectionEnd);
|
||||||
UsesNode:=FindMainUsesSection;
|
UsesNode:=FindMainUsesNode;
|
||||||
if (UsesNode<>nil)
|
if (UsesNode<>nil)
|
||||||
and (FindUnitInUsesSection(UsesNode,NewUnitName,Junk,Junk)) then
|
and (FindUnitInUsesSection(UsesNode,NewUnitName,Junk,Junk)) then
|
||||||
exit(true); // unit already in main uses section
|
exit(true); // unit already in main uses section
|
||||||
@ -965,8 +965,8 @@ begin
|
|||||||
Beauty:=SourceChangeCache.BeautifyCodeOptions;
|
Beauty:=SourceChangeCache.BeautifyCodeOptions;
|
||||||
SourceChangeCache.BeginUpdate;
|
SourceChangeCache.BeginUpdate;
|
||||||
try
|
try
|
||||||
UsesNode:=FindMainUsesSection;
|
UsesNode:=FindMainUsesNode;
|
||||||
OtherUsesNode:=FindImplementationUsesSection;
|
OtherUsesNode:=FindImplementationUsesNode;
|
||||||
if UsesSection=usImplementation then begin
|
if UsesSection=usImplementation then begin
|
||||||
SectionNode:=UsesNode;
|
SectionNode:=UsesNode;
|
||||||
UsesNode:=OtherUsesNode;
|
UsesNode:=OtherUsesNode;
|
||||||
@ -1062,8 +1062,8 @@ begin
|
|||||||
else
|
else
|
||||||
BuildTree(lsrImplementationUsesSectionEnd);
|
BuildTree(lsrImplementationUsesSectionEnd);
|
||||||
case UsesSection Of
|
case UsesSection Of
|
||||||
usMain: UsesNode:=FindMainUsesSection;
|
usMain: UsesNode:=FindMainUsesNode;
|
||||||
usImplementation: UsesNode:=FindImplementationUsesSection;
|
usImplementation: UsesNode:=FindImplementationUsesNode;
|
||||||
end;
|
end;
|
||||||
Result:=UnitExistsInUsesSection(UsesNode,AnUnitName);
|
Result:=UnitExistsInUsesSection(UsesNode,AnUnitName);
|
||||||
end;
|
end;
|
||||||
@ -1284,8 +1284,8 @@ begin
|
|||||||
ImplementationUsesSection:=nil;
|
ImplementationUsesSection:=nil;
|
||||||
// find the uses sections
|
// find the uses sections
|
||||||
BuildTree(lsrImplementationUsesSectionEnd);
|
BuildTree(lsrImplementationUsesSectionEnd);
|
||||||
MainUsesNode:=FindMainUsesSection;
|
MainUsesNode:=FindMainUsesNode;
|
||||||
ImplementatioUsesNode:=FindImplementationUsesSection;
|
ImplementatioUsesNode:=FindImplementationUsesNode;
|
||||||
// create lists
|
// create lists
|
||||||
try
|
try
|
||||||
MainUsesSection:=UsesSectionToUnitNames(MainUsesNode);
|
MainUsesSection:=UsesSectionToUnitNames(MainUsesNode);
|
||||||
@ -1333,8 +1333,8 @@ begin
|
|||||||
// find the uses sections
|
// find the uses sections
|
||||||
List:=TStringToStringTree.Create(false);
|
List:=TStringToStringTree.Create(false);
|
||||||
BuildTree(lsrImplementationUsesSectionEnd);
|
BuildTree(lsrImplementationUsesSectionEnd);
|
||||||
Collect(FindMainUsesSection,'Main');
|
Collect(FindMainUsesNode,'Main');
|
||||||
Collect(FindImplementationUsesSection,'Implementation');
|
Collect(FindImplementationUsesNode,'Implementation');
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1346,7 +1346,7 @@ begin
|
|||||||
MainUsesSection:=nil;
|
MainUsesSection:=nil;
|
||||||
// find the uses sections
|
// find the uses sections
|
||||||
BuildTree(lsrMainUsesSectionEnd);
|
BuildTree(lsrMainUsesSectionEnd);
|
||||||
MainUsesNode:=FindMainUsesSection;
|
MainUsesNode:=FindMainUsesNode;
|
||||||
// create lists
|
// create lists
|
||||||
try
|
try
|
||||||
MainUsesSection:=UsesSectionToFilenames(MainUsesNode);
|
MainUsesSection:=UsesSectionToFilenames(MainUsesNode);
|
||||||
@ -1366,8 +1366,8 @@ begin
|
|||||||
ImplementationUsesSection:=nil;
|
ImplementationUsesSection:=nil;
|
||||||
// find the uses sections
|
// find the uses sections
|
||||||
BuildTree(lsrImplementationUsesSectionEnd);
|
BuildTree(lsrImplementationUsesSectionEnd);
|
||||||
MainUsesNode:=FindMainUsesSection;
|
MainUsesNode:=FindMainUsesNode;
|
||||||
ImplementatioUsesNode:=FindImplementationUsesSection;
|
ImplementatioUsesNode:=FindImplementationUsesNode;
|
||||||
// create lists
|
// create lists
|
||||||
try
|
try
|
||||||
MainUsesSection:=UsesSectionToFilenames(MainUsesNode);
|
MainUsesSection:=UsesSectionToFilenames(MainUsesNode);
|
||||||
@ -1408,7 +1408,7 @@ begin
|
|||||||
NormalUnits:=nil;
|
NormalUnits:=nil;
|
||||||
// find the uses sections
|
// find the uses sections
|
||||||
BuildTree(lsrMainUsesSectionEnd);
|
BuildTree(lsrMainUsesSectionEnd);
|
||||||
UsesNode:=FindMainUsesSection(UseContainsSection);
|
UsesNode:=FindMainUsesNode(UseContainsSection);
|
||||||
if UsesNode=nil then exit;
|
if UsesNode=nil then exit;
|
||||||
FoundInUnits:=TStringList.Create;
|
FoundInUnits:=TStringList.Create;
|
||||||
MissingInUnits:=TStringList.Create;
|
MissingInUnits:=TStringList.Create;
|
||||||
@ -1558,9 +1558,9 @@ begin
|
|||||||
if FixCase then
|
if FixCase then
|
||||||
SourceChangeCache.MainScanner:=Scanner;
|
SourceChangeCache.MainScanner:=Scanner;
|
||||||
try
|
try
|
||||||
if not CheckUsesSection(FindMainUsesSection(true)) then exit;
|
if not CheckUsesSection(FindMainUsesNode(true)) then exit;
|
||||||
if SearchImplementation
|
if SearchImplementation
|
||||||
and not CheckUsesSection(FindImplementationUsesSection) then exit;
|
and not CheckUsesSection(FindImplementationUsesNode) then exit;
|
||||||
except
|
except
|
||||||
FreeAndNil(MissingUnits);
|
FreeAndNil(MissingUnits);
|
||||||
raise;
|
raise;
|
||||||
@ -1664,8 +1664,8 @@ begin
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
BuildTree(lsrInitializationStart);
|
BuildTree(lsrInitializationStart);
|
||||||
SourceChangeCache.MainScanner:=Scanner;
|
SourceChangeCache.MainScanner:=Scanner;
|
||||||
if not CommentUnitsInUsesSection(MissingUnits, SourceChangeCache, FindMainUsesSection) then exit;
|
if not CommentUnitsInUsesSection(MissingUnits, SourceChangeCache, FindMainUsesNode) then exit;
|
||||||
if not CommentUnitsInUsesSection(MissingUnits, SourceChangeCache, FindImplementationUsesSection) then exit;
|
if not CommentUnitsInUsesSection(MissingUnits, SourceChangeCache, FindImplementationUsesNode) then exit;
|
||||||
if not SourceChangeCache.Apply then exit;
|
if not SourceChangeCache.Apply then exit;
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
@ -1886,8 +1886,8 @@ begin
|
|||||||
BuildTree(lsrEnd);
|
BuildTree(lsrEnd);
|
||||||
Identifiers:=nil;
|
Identifiers:=nil;
|
||||||
try
|
try
|
||||||
CheckUsesSection(FindMainUsesSection,false);
|
CheckUsesSection(FindMainUsesNode,false);
|
||||||
CheckUsesSection(FindImplementationUsesSection,true);
|
CheckUsesSection(FindImplementationUsesNode,true);
|
||||||
finally
|
finally
|
||||||
Identifiers.Free;
|
Identifiers.Free;
|
||||||
end;
|
end;
|
||||||
@ -2415,7 +2415,7 @@ var
|
|||||||
fdfIgnoreOverloadedProcs];
|
fdfIgnoreOverloadedProcs];
|
||||||
Params.ContextNode:=FindInterfaceNode;
|
Params.ContextNode:=FindInterfaceNode;
|
||||||
if Params.ContextNode=nil then
|
if Params.ContextNode=nil then
|
||||||
Params.ContextNode:=FindMainUsesSection;
|
Params.ContextNode:=FindMainUsesNode;
|
||||||
Params.SetIdentifier(StartTool,Identifier,nil);
|
Params.SetIdentifier(StartTool,Identifier,nil);
|
||||||
try
|
try
|
||||||
Params.Save(OldInput);
|
Params.Save(OldInput);
|
||||||
@ -6361,7 +6361,7 @@ begin
|
|||||||
Indent:=Beauty.GetLineIndent(Src,ANode.StartPos);
|
Indent:=Beauty.GetLineIndent(Src,ANode.StartPos);
|
||||||
InsertPos:=ANode.StartPos;
|
InsertPos:=ANode.StartPos;
|
||||||
end else begin
|
end else begin
|
||||||
ANode:=FindMainUsesSection;
|
ANode:=FindMainUsesNode;
|
||||||
if ANode<>nil then begin
|
if ANode<>nil then begin
|
||||||
Indent:=Beauty.GetLineIndent(Src,ANode.StartPos);
|
Indent:=Beauty.GetLineIndent(Src,ANode.StartPos);
|
||||||
InsertPos:=ANode.StartPos;
|
InsertPos:=ANode.StartPos;
|
||||||
|
@ -4325,7 +4325,7 @@ var
|
|||||||
if (InsertPos<1) then begin
|
if (InsertPos<1) then begin
|
||||||
if DefaultTypeSectionPos<1 then begin
|
if DefaultTypeSectionPos<1 then begin
|
||||||
// start a type section at the beginning
|
// start a type section at the beginning
|
||||||
Node:=Tool.FindMainUsesSection(false);
|
Node:=Tool.FindMainUsesNode(false);
|
||||||
if Node<>nil then begin
|
if Node<>nil then begin
|
||||||
if Node.NextBrother<>nil then
|
if Node.NextBrother<>nil then
|
||||||
Node:=Node.NextBrother;
|
Node:=Node.NextBrother;
|
||||||
|
@ -361,7 +361,7 @@ var
|
|||||||
with fCTLink do begin
|
with fCTLink do begin
|
||||||
ResetMainScanner;
|
ResetMainScanner;
|
||||||
ParseToUsesSectionEnd;
|
ParseToUsesSectionEnd;
|
||||||
// Calls either FindMainUsesSection or FindImplementationUsesSection
|
// Calls either FindMainUsesNode or FindImplementationUsesNode
|
||||||
UsesNode:=UsesSectionNode;
|
UsesNode:=UsesSectionNode;
|
||||||
Assert(Assigned(UsesNode),
|
Assert(Assigned(UsesNode),
|
||||||
'UsesNode should be assigned in AddDelphiAndLCLSections->MoveToDelphi');
|
'UsesNode should be assigned in AddDelphiAndLCLSections->MoveToDelphi');
|
||||||
@ -511,7 +511,7 @@ var
|
|||||||
begin
|
begin
|
||||||
s:=ExtractFileExt(fOwnerTool.fFilename);
|
s:=ExtractFileExt(fOwnerTool.fFilename);
|
||||||
IsPackage := (s='.dpk') or (s='.lpk');
|
IsPackage := (s='.dpk') or (s='.lpk');
|
||||||
Result:=fCTLink.CodeTool.FindMainUsesSection(IsPackage);
|
Result:=fCTLink.CodeTool.FindMainUsesNode(IsPackage);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainUsedUnits.ParseToUsesSectionEnd;
|
procedure TMainUsedUnits.ParseToUsesSectionEnd;
|
||||||
@ -539,7 +539,7 @@ end;
|
|||||||
|
|
||||||
function TImplUsedUnits.UsesSectionNode: TCodeTreeNode;
|
function TImplUsedUnits.UsesSectionNode: TCodeTreeNode;
|
||||||
begin
|
begin
|
||||||
Result:=fCTLink.CodeTool.FindImplementationUsesSection;
|
Result:=fCTLink.CodeTool.FindImplementationUsesNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TImplUsedUnits.ParseToUsesSectionEnd;
|
procedure TImplUsedUnits.ParseToUsesSectionEnd;
|
||||||
@ -690,10 +690,10 @@ begin
|
|||||||
CodeTool.BuildTree(lsrInitializationStart);
|
CodeTool.BuildTree(lsrInitializationStart);
|
||||||
if fMainUsedUnits.fUnitsToComment.Count > 0 then
|
if fMainUsedUnits.fUnitsToComment.Count > 0 then
|
||||||
if not CodeTool.CommentUnitsInUsesSection(fMainUsedUnits.fUnitsToComment,
|
if not CodeTool.CommentUnitsInUsesSection(fMainUsedUnits.fUnitsToComment,
|
||||||
SrcCache, CodeTool.FindMainUsesSection) then exit;
|
SrcCache, CodeTool.FindMainUsesNode) then exit;
|
||||||
if fImplUsedUnits.fUnitsToComment.Count > 0 then
|
if fImplUsedUnits.fUnitsToComment.Count > 0 then
|
||||||
if not CodeTool.CommentUnitsInUsesSection(fImplUsedUnits.fUnitsToComment,
|
if not CodeTool.CommentUnitsInUsesSection(fImplUsedUnits.fUnitsToComment,
|
||||||
SrcCache, CodeTool.FindImplementationUsesSection) then exit;
|
SrcCache, CodeTool.FindImplementationUsesNode) then exit;
|
||||||
if not SrcCache.Apply then exit;
|
if not SrcCache.Apply then exit;
|
||||||
end;
|
end;
|
||||||
// Add more units meant for only LCL.
|
// Add more units meant for only LCL.
|
||||||
|
@ -9590,14 +9590,14 @@ begin
|
|||||||
jmpInterface: Node := Tool.FindInterfaceNode;
|
jmpInterface: Node := Tool.FindInterfaceNode;
|
||||||
jmpInterfaceUses:
|
jmpInterfaceUses:
|
||||||
begin
|
begin
|
||||||
Node := Tool.FindMainUsesSection;
|
Node := Tool.FindMainUsesNode;
|
||||||
if Node = nil then//if the uses section is missing, jump to interface
|
if Node = nil then//if the uses section is missing, jump to interface
|
||||||
Node := Tool.FindInterfaceNode;
|
Node := Tool.FindInterfaceNode;
|
||||||
end;
|
end;
|
||||||
jmpImplementation: Node := Tool.FindImplementationNode;
|
jmpImplementation: Node := Tool.FindImplementationNode;
|
||||||
jmpImplementationUses:
|
jmpImplementationUses:
|
||||||
begin
|
begin
|
||||||
Node := Tool.FindImplementationUsesSection;
|
Node := Tool.FindImplementationUsesNode;
|
||||||
if Node = nil then//if the uses section is missing, jump to implementation
|
if Node = nil then//if the uses section is missing, jump to implementation
|
||||||
Node := Tool.FindImplementationNode;
|
Node := Tool.FindImplementationNode;
|
||||||
end;
|
end;
|
||||||
|
@ -401,7 +401,7 @@ begin
|
|||||||
CodeToolBoss.Explore(ACode,Tool,false);
|
CodeToolBoss.Explore(ACode,Tool,false);
|
||||||
if Tool=nil then exit;
|
if Tool=nil then exit;
|
||||||
// collect implementation use unit nodes
|
// collect implementation use unit nodes
|
||||||
ImplUsesNode := Tool.FindImplementationUsesSection;
|
ImplUsesNode := Tool.FindImplementationUsesNode;
|
||||||
if Assigned(ImplUsesNode) then
|
if Assigned(ImplUsesNode) then
|
||||||
for i := 0 to FImplUsedUnits.Count - 1 do
|
for i := 0 to FImplUsedUnits.Count - 1 do
|
||||||
FImplUsedUnits.Objects[i] := ImplUsesNode;
|
FImplUsedUnits.Objects[i] := ImplUsesNode;
|
||||||
|
@ -2415,9 +2415,9 @@ var
|
|||||||
if LoadCodeBuffer(Code,OldFilename,[lbfUpdateFromDisk,lbfCheckIfText],false)<>mrOk
|
if LoadCodeBuffer(Code,OldFilename,[lbfUpdateFromDisk,lbfCheckIfText],false)<>mrOk
|
||||||
then exit;
|
then exit;
|
||||||
CodeToolBoss.Explore(Code,Tool,false);
|
CodeToolBoss.Explore(Code,Tool,false);
|
||||||
if not CheckUsesSection(Tool,Tool.FindMainUsesSection,NewFilename) then
|
if not CheckUsesSection(Tool,Tool.FindMainUsesNode,NewFilename) then
|
||||||
Result:=false;
|
Result:=false;
|
||||||
if not CheckUsesSection(Tool,Tool.FindImplementationUsesSection,NewFilename) then
|
if not CheckUsesSection(Tool,Tool.FindImplementationUsesNode,NewFilename) then
|
||||||
Result:=false;
|
Result:=false;
|
||||||
end;
|
end;
|
||||||
if not Result then begin
|
if not Result then begin
|
||||||
|
@ -227,15 +227,15 @@ begin
|
|||||||
lsrInterfaceStart:
|
lsrInterfaceStart:
|
||||||
AssertEquals('interface start scanned',true,Tool.FindInterfaceNode<>nil);
|
AssertEquals('interface start scanned',true,Tool.FindInterfaceNode<>nil);
|
||||||
lsrMainUsesSectionStart:
|
lsrMainUsesSectionStart:
|
||||||
AssertEquals('main uses section start scanned',true,Tool.FindMainUsesSection<>nil);
|
AssertEquals('main uses section start scanned',true,Tool.FindMainUsesNode<>nil);
|
||||||
lsrMainUsesSectionEnd:
|
lsrMainUsesSectionEnd:
|
||||||
AssertEquals('main uses section end scanned',true,Tool.FindMainUsesSection.FirstChild<>nil);
|
AssertEquals('main uses section end scanned',true,Tool.FindMainUsesNode.FirstChild<>nil);
|
||||||
lsrImplementationStart:
|
lsrImplementationStart:
|
||||||
AssertEquals('implementation start scanned',true,Tool.FindImplementationNode<>nil);
|
AssertEquals('implementation start scanned',true,Tool.FindImplementationNode<>nil);
|
||||||
lsrImplementationUsesSectionStart:
|
lsrImplementationUsesSectionStart:
|
||||||
AssertEquals('implementation uses section start scanned',true,Tool.FindImplementationUsesSection<>nil);
|
AssertEquals('implementation uses section start scanned',true,Tool.FindImplementationUsesNode<>nil);
|
||||||
lsrImplementationUsesSectionEnd:
|
lsrImplementationUsesSectionEnd:
|
||||||
AssertEquals('implementation uses section end scanned',true,Tool.FindImplementationUsesSection.FirstChild<>nil);
|
AssertEquals('implementation uses section end scanned',true,Tool.FindImplementationUsesNode.FirstChild<>nil);
|
||||||
lsrInitializationStart:
|
lsrInitializationStart:
|
||||||
AssertEquals('initialization section start scanned',true,Tool.FindInitializationNode<>nil);
|
AssertEquals('initialization section start scanned',true,Tool.FindInitializationNode<>nil);
|
||||||
lsrFinalizationStart:
|
lsrFinalizationStart:
|
||||||
|
Loading…
Reference in New Issue
Block a user