From d4b9573bfbe1fc2660a7199fa19d7ce352911467 Mon Sep 17 00:00:00 2001 From: mattias Date: Sun, 1 Aug 2010 08:43:02 +0000 Subject: [PATCH] codetools: FindDeclaration: jump by default to next declaration git-svn-id: trunk@26961 - --- components/codetools/codetoolmanager.pas | 9 +++++---- components/codetools/codetoolscfgscript.pas | 9 +++++++++ .../codetools/examples/runcfgscript.lpi | 9 ++------- components/codetools/finddeclarationtool.pas | 19 ++++++++++--------- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/components/codetools/codetoolmanager.pas b/components/codetools/codetoolmanager.pas index 6cb23add7e..b099a2038d 100644 --- a/components/codetools/codetoolmanager.pas +++ b/components/codetools/codetoolmanager.pas @@ -393,7 +393,8 @@ type Identifier: PChar; out NewCode: TCodeBuffer; out NewX, NewY, NewTopLine: integer): boolean; - function FindSmartHint(Code: TCodeBuffer; X,Y: integer): string; + function FindSmartHint(Code: TCodeBuffer; X,Y: integer; + Flags: TFindSmartFlags = DefaultFindSmartHintFlags): string; function FindDeclarationInInterface(Code: TCodeBuffer; const Identifier: string; out NewCode: TCodeBuffer; out NewX, NewY, NewTopLine: integer): boolean; @@ -1857,8 +1858,8 @@ begin {$ENDIF} end; -function TCodeToolManager.FindSmartHint(Code: TCodeBuffer; X, Y: integer - ): string; +function TCodeToolManager.FindSmartHint(Code: TCodeBuffer; X, Y: integer; + Flags: TFindSmartFlags): string; var CursorPos: TCodeXYPosition; begin @@ -1874,7 +1875,7 @@ begin DebugLn('TCodeToolManager.FindSmartHint B ',dbgs(FCurCodeTool.Scanner<>nil)); {$ENDIF} try - Result:=FCurCodeTool.FindSmartHint(CursorPos); + Result:=FCurCodeTool.FindSmartHint(CursorPos,Flags); except on e: Exception do HandleException(e); end; diff --git a/components/codetools/codetoolscfgscript.pas b/components/codetools/codetoolscfgscript.pas index 0705fb521d..981dcd8831 100644 --- a/components/codetools/codetoolscfgscript.pas +++ b/components/codetools/codetoolscfgscript.pas @@ -21,7 +21,16 @@ Author: Mattias Gaertner Abstract: + TCTConfigScriptEngine implements an interpreter for simple parscal like + programs. + Working: + if, then, else, begin..end, ;, (), not, and, or, xor, =, <>, >, <, <=, >=, + :=, defined(), variable, + constants: decimal, hex, octal, binary, string, #decimal + ToDo: + +=, string(), integer(), int64(), shl, shr, div, mod, *, +, - + +, - as unary operator } unit CodeToolsCfgScript; diff --git a/components/codetools/examples/runcfgscript.lpi b/components/codetools/examples/runcfgscript.lpi index 4fd2585924..d24ba9dfb3 100644 --- a/components/codetools/examples/runcfgscript.lpi +++ b/components/codetools/examples/runcfgscript.lpi @@ -1,7 +1,7 @@ - + @@ -42,12 +42,7 @@ - - - - - - + diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index 470b562315..7f3925d5eb 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -548,7 +548,8 @@ type ); const - DefaultFindSmartFlags = [fsfIncludeDirective,fsfFindMainDeclaration]; + DefaultFindSmartFlags = [fsfIncludeDirective]; + DefaultFindSmartHintFlags = DefaultFindSmartFlags+[fsfFindMainDeclaration]; type //---------------------------------------------------------------------------- @@ -792,7 +793,8 @@ type function SearchUnitInUnitLinks(const TheUnitName: string): string; function SearchUnitInUnitSet(const TheUnitName: string): string; - function FindSmartHint(const CursorPos: TCodeXYPosition): string; + function FindSmartHint(const CursorPos: TCodeXYPosition; + Flags: TFindSmartFlags = DefaultFindSmartHintFlags): string; function BaseTypeOfNodeHasSubIdents(ANode: TCodeTreeNode): boolean; function FindBaseTypeOfNode(Params: TFindDeclarationParams; @@ -1454,9 +1456,9 @@ begin // raise exception CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true); end; - {$IFDEF CTDEBUG} + { $IFDEF CTDEBUG} DebugLn('TFindDeclarationTool.FindDeclaration D CursorNode=',NodeDescriptionAsString(CursorNode.Desc),' HasChilds=',dbgs(CursorNode.FirstChild<>nil)); - {$ENDIF} + { $ENDIF} if (not IsDirtySrcValid) and (CursorNode.Desc in [ctnUsesSection,ctnUseUnit]) then begin // in uses section @@ -2110,8 +2112,8 @@ begin Result:=DirectoryCache.FindUnitInUnitSet(TheUnitName); end; -function TFindDeclarationTool.FindSmartHint(const CursorPos: TCodeXYPosition - ): string; +function TFindDeclarationTool.FindSmartHint(const CursorPos: TCodeXYPosition; + Flags: TFindSmartFlags): string; var NewTool: TFindDeclarationTool; NewNode, IdentNode, TypeNode, ANode: TCodeTreeNode; @@ -2124,10 +2126,9 @@ var NodeStr: String; begin Result:=''; - if not FindDeclaration(CursorPos,DefaultFindSmartFlags, - NewTool,NewNode,NewPos,NewTopLine) then + if not FindDeclaration(CursorPos,Flags,NewTool,NewNode,NewPos,NewTopLine) then begin - // identifier not found or already at declaration + // identifier not found exit; end;