mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-02 10:59:25 +01:00
codetools: clean up
git-svn-id: trunk@48655 -
This commit is contained in:
parent
5182b88700
commit
69917cf580
@ -49,7 +49,7 @@ uses
|
||||
PPUCodeTools, LFMTrees, DirectivesTree, CodeCompletionTemplater,
|
||||
PascalParserTool, CodeToolsConfig, CustomCodeTool, FindDeclarationTool,
|
||||
IdentCompletionTool, StdCodeTools, ResourceCodeTool, CodeToolsStructs,
|
||||
CTUnitGraph, CodeTemplatesTool, ExtractProcTool;
|
||||
CTUnitGraph, ExtractProcTool;
|
||||
|
||||
type
|
||||
TCodeToolManager = class;
|
||||
@ -640,14 +640,6 @@ type
|
||||
ProcName: string = '' // default: Assign
|
||||
): boolean;
|
||||
|
||||
// code templates
|
||||
function InsertCodeTemplate(Code: TCodeBuffer;
|
||||
SelectionStart, SelectionEnd: TPoint;
|
||||
TopLine: integer;
|
||||
CodeTemplate: TCodeToolTemplate;
|
||||
var NewCode: TCodeBuffer;
|
||||
var NewX, NewY, NewTopLine: integer): boolean;
|
||||
|
||||
// source name e.g. 'unit AUnitName;'
|
||||
function GetSourceName(Code: TCodeBuffer; SearchMainCode: boolean): string;
|
||||
function GetCachedSourceName(Code: TCodeBuffer): string;
|
||||
@ -4696,39 +4688,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCodeToolManager.InsertCodeTemplate(Code: TCodeBuffer;
|
||||
SelectionStart, SelectionEnd: TPoint; TopLine: integer;
|
||||
CodeTemplate: TCodeToolTemplate; var NewCode: TCodeBuffer; var NewX, NewY,
|
||||
NewTopLine: integer): boolean;
|
||||
var
|
||||
CursorPos: TCodeXYPosition;
|
||||
EndPos: TCodeXYPosition;
|
||||
NewPos: TCodeXYPosition;
|
||||
begin
|
||||
{$IFDEF CTDEBUG}
|
||||
DebugLn('TCodeToolManager.InsertCodeTemplate A ',Code.Filename);
|
||||
{$ENDIF}
|
||||
Result:=false;
|
||||
if not InitCurCodeTool(Code) then exit;
|
||||
CursorPos.X:=SelectionStart.X;
|
||||
CursorPos.Y:=SelectionStart.Y;
|
||||
CursorPos.Code:=Code;
|
||||
EndPos.X:=SelectionEnd.X;
|
||||
EndPos.Y:=SelectionEnd.Y;
|
||||
EndPos.Code:=Code;
|
||||
try
|
||||
Result:=FCurCodeTool.InsertCodeTemplate(CursorPos,EndPos,TopLine,
|
||||
CodeTemplate,NewPos,NewTopLine,SourceChangeCache);
|
||||
if Result then begin
|
||||
NewX:=NewPos.X;
|
||||
NewY:=NewPos.Y;
|
||||
NewCode:=NewPos.Code;
|
||||
end;
|
||||
except
|
||||
on e: Exception do Result:=HandleException(e);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCodeToolManager.GetSourceName(Code: TCodeBuffer;
|
||||
SearchMainCode: boolean): string;
|
||||
begin
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<License Value="GPL-2
|
||||
"/>
|
||||
<Version Major="1" Release="1"/>
|
||||
<Files Count="62">
|
||||
<Files Count="61">
|
||||
<Item1>
|
||||
<Filename Value="Makefile"/>
|
||||
<Type Value="Text"/>
|
||||
@ -69,210 +69,206 @@
|
||||
<UnitName Value="CodeIndex"/>
|
||||
</Item11>
|
||||
<Item12>
|
||||
<Filename Value="codetemplatestool.pas"/>
|
||||
<UnitName Value="CodeTemplatesTool"/>
|
||||
</Item12>
|
||||
<Item13>
|
||||
<Filename Value="codetoolmanager.pas"/>
|
||||
<UnitName Value="CodeToolManager"/>
|
||||
</Item13>
|
||||
<Item14>
|
||||
</Item12>
|
||||
<Item13>
|
||||
<Filename Value="codetoolmemmanager.pas"/>
|
||||
<UnitName Value="CodeToolMemManager"/>
|
||||
</Item14>
|
||||
<Item15>
|
||||
</Item13>
|
||||
<Item14>
|
||||
<Filename Value="codetools.inc"/>
|
||||
<Type Value="Include"/>
|
||||
</Item15>
|
||||
<Item16>
|
||||
</Item14>
|
||||
<Item15>
|
||||
<Filename Value="codetoolsconfig.pas"/>
|
||||
<UnitName Value="CodeToolsConfig"/>
|
||||
</Item16>
|
||||
<Item17>
|
||||
</Item15>
|
||||
<Item16>
|
||||
<Filename Value="codetoolsstrconsts.pas"/>
|
||||
<UnitName Value="CodeToolsStrConsts"/>
|
||||
</Item17>
|
||||
<Item18>
|
||||
</Item16>
|
||||
<Item17>
|
||||
<Filename Value="codetoolsstructs.pas"/>
|
||||
<UnitName Value="CodeToolsStructs"/>
|
||||
</Item18>
|
||||
<Item19>
|
||||
</Item17>
|
||||
<Item18>
|
||||
<Filename Value="codetree.pas"/>
|
||||
<UnitName Value="CodeTree"/>
|
||||
</Item19>
|
||||
<Item20>
|
||||
</Item18>
|
||||
<Item19>
|
||||
<Filename Value="customcodetool.pas"/>
|
||||
<UnitName Value="CustomCodeTool"/>
|
||||
</Item20>
|
||||
<Item21>
|
||||
</Item19>
|
||||
<Item20>
|
||||
<Filename Value="definetemplates.pas"/>
|
||||
<UnitName Value="DefineTemplates"/>
|
||||
</Item21>
|
||||
<Item22>
|
||||
</Item20>
|
||||
<Item21>
|
||||
<Filename Value="directivestree.pas"/>
|
||||
<UnitName Value="DirectivesTree"/>
|
||||
</Item22>
|
||||
<Item23>
|
||||
</Item21>
|
||||
<Item22>
|
||||
<Filename Value="directorycacher.pas"/>
|
||||
<UnitName Value="DirectoryCacher"/>
|
||||
</Item23>
|
||||
<Item24>
|
||||
</Item22>
|
||||
<Item23>
|
||||
<Filename Value="eventcodetool.pas"/>
|
||||
<UnitName Value="EventCodeTool"/>
|
||||
</Item24>
|
||||
<Item25>
|
||||
</Item23>
|
||||
<Item24>
|
||||
<Filename Value="expreval.pas"/>
|
||||
<UnitName Value="ExprEval"/>
|
||||
</Item25>
|
||||
<Item26>
|
||||
</Item24>
|
||||
<Item25>
|
||||
<Filename Value="extractproctool.pas"/>
|
||||
<UnitName Value="ExtractProcTool"/>
|
||||
</Item26>
|
||||
<Item27>
|
||||
</Item25>
|
||||
<Item26>
|
||||
<Filename Value="fileprocs.pas"/>
|
||||
<UnitName Value="FileProcs"/>
|
||||
</Item27>
|
||||
<Item28>
|
||||
</Item26>
|
||||
<Item27>
|
||||
<Filename Value="finddeclarationcache.pas"/>
|
||||
<UnitName Value="FindDeclarationCache"/>
|
||||
</Item28>
|
||||
<Item29>
|
||||
</Item27>
|
||||
<Item28>
|
||||
<Filename Value="finddeclarationtool.pas"/>
|
||||
<UnitName Value="FindDeclarationTool"/>
|
||||
</Item29>
|
||||
<Item30>
|
||||
</Item28>
|
||||
<Item29>
|
||||
<Filename Value="findoverloads.pas"/>
|
||||
<UnitName Value="FindOverloads"/>
|
||||
</Item30>
|
||||
<Item31>
|
||||
</Item29>
|
||||
<Item30>
|
||||
<Filename Value="fpc.errore.msg"/>
|
||||
<Type Value="Text"/>
|
||||
</Item31>
|
||||
<Item32>
|
||||
</Item30>
|
||||
<Item31>
|
||||
<Filename Value="h2pastool.pas"/>
|
||||
<UnitName Value="H2PasTool"/>
|
||||
</Item32>
|
||||
<Item33>
|
||||
</Item31>
|
||||
<Item32>
|
||||
<Filename Value="identcompletiontool.pas"/>
|
||||
<UnitName Value="IdentCompletionTool"/>
|
||||
</Item33>
|
||||
<Item34>
|
||||
</Item32>
|
||||
<Item33>
|
||||
<Filename Value="keywordfunclists.pas"/>
|
||||
<UnitName Value="KeywordFuncLists"/>
|
||||
</Item34>
|
||||
<Item35>
|
||||
</Item33>
|
||||
<Item34>
|
||||
<Filename Value="lfmtrees.pas"/>
|
||||
<UnitName Value="LFMTrees"/>
|
||||
</Item35>
|
||||
<Item36>
|
||||
</Item34>
|
||||
<Item35>
|
||||
<Filename Value="linkscanner.pas"/>
|
||||
<UnitName Value="LinkScanner"/>
|
||||
</Item36>
|
||||
<Item37>
|
||||
</Item35>
|
||||
<Item36>
|
||||
<Filename Value="memcheck.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="MemCheck"/>
|
||||
</Item37>
|
||||
<Item38>
|
||||
</Item36>
|
||||
<Item37>
|
||||
<Filename Value="memcheck_laz.inc"/>
|
||||
<Type Value="Include"/>
|
||||
</Item38>
|
||||
<Item39>
|
||||
</Item37>
|
||||
<Item38>
|
||||
<Filename Value="methodjumptool.pas"/>
|
||||
<UnitName Value="MethodJumpTool"/>
|
||||
</Item39>
|
||||
<Item40>
|
||||
</Item38>
|
||||
<Item39>
|
||||
<Filename Value="multikeywordlisttool.pas"/>
|
||||
<UnitName Value="MultiKeyWordListTool"/>
|
||||
</Item40>
|
||||
<Item41>
|
||||
</Item39>
|
||||
<Item40>
|
||||
<Filename Value="nonpascalcodetools.pas"/>
|
||||
<UnitName Value="NonPascalCodeTools"/>
|
||||
</Item41>
|
||||
<Item42>
|
||||
</Item40>
|
||||
<Item41>
|
||||
<Filename Value="pascalparsertool.pas"/>
|
||||
<UnitName Value="PascalParserTool"/>
|
||||
</Item42>
|
||||
<Item43>
|
||||
</Item41>
|
||||
<Item42>
|
||||
<Filename Value="pascalreadertool.pas"/>
|
||||
<UnitName Value="PascalReaderTool"/>
|
||||
</Item43>
|
||||
<Item44>
|
||||
</Item42>
|
||||
<Item43>
|
||||
<Filename Value="ppucodetools.pas"/>
|
||||
<UnitName Value="PPUCodeTools"/>
|
||||
</Item44>
|
||||
<Item45>
|
||||
</Item43>
|
||||
<Item44>
|
||||
<Filename Value="ppugraph.pas"/>
|
||||
<UnitName Value="PPUGraph"/>
|
||||
</Item45>
|
||||
<Item46>
|
||||
</Item44>
|
||||
<Item45>
|
||||
<Filename Value="ppuparser.pas"/>
|
||||
<UnitName Value="PPUParser"/>
|
||||
</Item46>
|
||||
<Item47>
|
||||
</Item45>
|
||||
<Item46>
|
||||
<Filename Value="resourcecodetool.pas"/>
|
||||
<UnitName Value="ResourceCodeTool"/>
|
||||
</Item47>
|
||||
<Item48>
|
||||
</Item46>
|
||||
<Item47>
|
||||
<Filename Value="sourcechanger.pas"/>
|
||||
<UnitName Value="SourceChanger"/>
|
||||
</Item48>
|
||||
<Item49>
|
||||
</Item47>
|
||||
<Item48>
|
||||
<Filename Value="sourcelog.pas"/>
|
||||
<UnitName Value="SourceLog"/>
|
||||
</Item49>
|
||||
<Item50>
|
||||
</Item48>
|
||||
<Item49>
|
||||
<Filename Value="stdcodetools.pas"/>
|
||||
<UnitName Value="StdCodeTools"/>
|
||||
</Item50>
|
||||
<Item51>
|
||||
</Item49>
|
||||
<Item50>
|
||||
<Filename Value="otheridentifiertree.pas"/>
|
||||
<UnitName Value="OtherIdentifierTree"/>
|
||||
</Item51>
|
||||
<Item52>
|
||||
</Item50>
|
||||
<Item51>
|
||||
<Filename Value="fpcsrcrules.inc"/>
|
||||
<Type Value="Include"/>
|
||||
</Item52>
|
||||
<Item53>
|
||||
</Item51>
|
||||
<Item52>
|
||||
<Filename Value="codetoolscfgscript.pas"/>
|
||||
<UnitName Value="CodeToolsCfgScript"/>
|
||||
</Item53>
|
||||
<Item54>
|
||||
</Item52>
|
||||
<Item53>
|
||||
<Filename Value="ctxmlfixfragment.pas"/>
|
||||
<UnitName Value="CTXMLFixFragment"/>
|
||||
</Item54>
|
||||
<Item55>
|
||||
</Item53>
|
||||
<Item54>
|
||||
<Filename Value="ctunitgraph.pas"/>
|
||||
<UnitName Value="CTUnitGraph"/>
|
||||
</Item55>
|
||||
<Item56>
|
||||
</Item54>
|
||||
<Item55>
|
||||
<Filename Value="changedeclarationtool.pas"/>
|
||||
<UnitName Value="ChangeDeclarationTool"/>
|
||||
</Item56>
|
||||
<Item57>
|
||||
</Item55>
|
||||
<Item56>
|
||||
<Filename Value="codetoolsfpcmsgs.pas"/>
|
||||
<UnitName Value="CodeToolsFPCMsgs"/>
|
||||
</Item57>
|
||||
<Item58>
|
||||
</Item56>
|
||||
<Item57>
|
||||
<Filename Value="unitdictionary.pas"/>
|
||||
<UnitName Value="UnitDictionary"/>
|
||||
</Item58>
|
||||
<Item59>
|
||||
</Item57>
|
||||
<Item58>
|
||||
<Filename Value="ctloadlaz.pas"/>
|
||||
<UnitName Value="ctloadlaz"/>
|
||||
</Item59>
|
||||
<Item60>
|
||||
</Item58>
|
||||
<Item59>
|
||||
<Filename Value="ctunitgroupgraph.pas"/>
|
||||
<UnitName Value="CTUnitGroupGraph"/>
|
||||
</Item60>
|
||||
<Item61>
|
||||
</Item59>
|
||||
<Item60>
|
||||
<Filename Value="codecompletiontemplater.pas"/>
|
||||
<UnitName Value="CodeCompletionTemplater"/>
|
||||
</Item61>
|
||||
<Item62>
|
||||
</Item60>
|
||||
<Item61>
|
||||
<Filename Value="codetoolgdbtracer.pas"/>
|
||||
<UnitName Value="CodetoolGDBTracer"/>
|
||||
</Item62>
|
||||
</Item61>
|
||||
</Files>
|
||||
<LazDoc Paths="docs"/>
|
||||
<i18n>
|
||||
|
||||
@ -8,13 +8,13 @@ interface
|
||||
|
||||
uses
|
||||
BasicCodeTools, CacheCodeTools, CCodeParserTool, CodeAtom, CodeBeautifier,
|
||||
CodeCache, CodeCompletionTool, CodeGraph, CodeIndex, CodeTemplatesTool,
|
||||
CodeToolManager, CodeToolMemManager, CodeToolsConfig, CodeToolsStrConsts,
|
||||
CodeToolsStructs, CodeTree, CustomCodeTool, DefineTemplates, DirectivesTree,
|
||||
DirectoryCacher, EventCodeTool, ExprEval, ExtractProcTool, FileProcs,
|
||||
FindDeclarationCache, FindDeclarationTool, FindOverloads, H2PasTool,
|
||||
IdentCompletionTool, KeywordFuncLists, LFMTrees, LinkScanner,
|
||||
MethodJumpTool, MultiKeyWordListTool, NonPascalCodeTools, PascalParserTool,
|
||||
CodeCache, CodeCompletionTool, CodeGraph, CodeIndex, CodeToolManager,
|
||||
CodeToolMemManager, CodeToolsConfig, CodeToolsStrConsts, CodeToolsStructs,
|
||||
CodeTree, CustomCodeTool, DefineTemplates, DirectivesTree, DirectoryCacher,
|
||||
EventCodeTool, ExprEval, ExtractProcTool, FileProcs, FindDeclarationCache,
|
||||
FindDeclarationTool, FindOverloads, H2PasTool, IdentCompletionTool,
|
||||
KeywordFuncLists, LFMTrees, LinkScanner, MethodJumpTool,
|
||||
MultiKeyWordListTool, NonPascalCodeTools, PascalParserTool,
|
||||
PascalReaderTool, PPUCodeTools, PPUGraph, PPUParser, ResourceCodeTool,
|
||||
SourceChanger, SourceLog, StdCodeTools, OtherIdentifierTree,
|
||||
CodeToolsCfgScript, CTXMLFixFragment, CTUnitGraph, ChangeDeclarationTool,
|
||||
|
||||
@ -41,7 +41,7 @@ uses
|
||||
MemCheck,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, FileProcs, CodeTree, PascalParserTool,
|
||||
StdCodeTools, CodeTemplatesTool, KeywordFuncLists, BasicCodeTools,
|
||||
StdCodeTools, KeywordFuncLists, BasicCodeTools,
|
||||
LinkScanner, CodeCache, AVL_Tree;
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ type
|
||||
|
||||
{ TMethodJumpingCodeTool }
|
||||
|
||||
TMethodJumpingCodeTool = class(TCodeTemplatesTool)
|
||||
TMethodJumpingCodeTool = class(TStandardCodeTool)
|
||||
protected
|
||||
procedure RemoveCorrespondingProcNodes(Tree1, Tree2: TAVLTree;
|
||||
KeepTree1: boolean);
|
||||
|
||||
@ -121,6 +121,8 @@ type
|
||||
Attr: TProcHeadAttributes): string;
|
||||
function ExtractProcHead(ProcNode: TCodeTreeNode;
|
||||
Attr: TProcHeadAttributes): string;
|
||||
function ExtractProcedureHeader(CursorPos: TCodeXYPosition;
|
||||
Attributes: TProcHeadAttributes; var ProcHead: string): boolean;
|
||||
function ExtractClassNameOfProcNode(ProcNode: TCodeTreeNode;
|
||||
AddParentClasses: boolean = true): string;
|
||||
function ProcNodeHasSpecifier(ProcNode: TCodeTreeNode;
|
||||
@ -653,6 +655,24 @@ begin
|
||||
Result:=Result+';';
|
||||
end;
|
||||
|
||||
function TPascalReaderTool.ExtractProcedureHeader(CursorPos: TCodeXYPosition;
|
||||
Attributes: TProcHeadAttributes; var ProcHead: string): boolean;
|
||||
var
|
||||
CleanCursorPos: integer;
|
||||
ANode: TCodeTreeNode;
|
||||
begin
|
||||
Result:=false;
|
||||
ProcHead:='';
|
||||
BuildTreeAndGetCleanPos(trTillCursor,lsrEnd,CursorPos,CleanCursorPos,
|
||||
[btSetIgnoreErrorPos,btCursorPosOutAllowed]);
|
||||
ANode:=FindDeepestNodeAtPos(CleanCursorPos,True);
|
||||
while (ANode<>nil) and (ANode.Desc<>ctnProcedure) do
|
||||
ANode:=ANode.Parent;
|
||||
if ANode=nil then exit;
|
||||
ProcHead:=ExtractProcHead(ANode,Attributes);
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
function TPascalReaderTool.ExtractClassName(Node: TCodeTreeNode;
|
||||
InUpperCase: boolean; WithParents: boolean): string;
|
||||
var
|
||||
|
||||
Loading…
Reference in New Issue
Block a user