codetools: FindDeclaration: jump by default to next declaration

git-svn-id: trunk@26961 -
This commit is contained in:
mattias 2010-08-01 08:43:02 +00:00
parent fd5e2ac392
commit d4b9573bfb
4 changed files with 26 additions and 20 deletions

View File

@ -393,7 +393,8 @@ type
Identifier: PChar; Identifier: PChar;
out NewCode: TCodeBuffer; out NewCode: TCodeBuffer;
out NewX, NewY, NewTopLine: integer): boolean; 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; function FindDeclarationInInterface(Code: TCodeBuffer;
const Identifier: string; out NewCode: TCodeBuffer; const Identifier: string; out NewCode: TCodeBuffer;
out NewX, NewY, NewTopLine: integer): boolean; out NewX, NewY, NewTopLine: integer): boolean;
@ -1857,8 +1858,8 @@ begin
{$ENDIF} {$ENDIF}
end; end;
function TCodeToolManager.FindSmartHint(Code: TCodeBuffer; X, Y: integer function TCodeToolManager.FindSmartHint(Code: TCodeBuffer; X, Y: integer;
): string; Flags: TFindSmartFlags): string;
var var
CursorPos: TCodeXYPosition; CursorPos: TCodeXYPosition;
begin begin
@ -1874,7 +1875,7 @@ begin
DebugLn('TCodeToolManager.FindSmartHint B ',dbgs(FCurCodeTool.Scanner<>nil)); DebugLn('TCodeToolManager.FindSmartHint B ',dbgs(FCurCodeTool.Scanner<>nil));
{$ENDIF} {$ENDIF}
try try
Result:=FCurCodeTool.FindSmartHint(CursorPos); Result:=FCurCodeTool.FindSmartHint(CursorPos,Flags);
except except
on e: Exception do HandleException(e); on e: Exception do HandleException(e);
end; end;

View File

@ -21,7 +21,16 @@
Author: Mattias Gaertner Author: Mattias Gaertner
Abstract: 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; unit CodeToolsCfgScript;

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<Version Value="8"/> <Version Value="7"/>
<General> <General>
<Flags> <Flags>
<MainUnitHasUsesSectionForAllUnits Value="False"/> <MainUnitHasUsesSectionForAllUnits Value="False"/>
@ -42,12 +42,7 @@
</Units> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>
<Version Value="9"/> <Version Value="8"/>
<Parsing>
<SyntaxOptions>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Other> <Other>
<CompilerPath Value="$(CompPath)"/> <CompilerPath Value="$(CompPath)"/>
</Other> </Other>

View File

@ -548,7 +548,8 @@ type
); );
const const
DefaultFindSmartFlags = [fsfIncludeDirective,fsfFindMainDeclaration]; DefaultFindSmartFlags = [fsfIncludeDirective];
DefaultFindSmartHintFlags = DefaultFindSmartFlags+[fsfFindMainDeclaration];
type type
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -792,7 +793,8 @@ type
function SearchUnitInUnitLinks(const TheUnitName: string): string; function SearchUnitInUnitLinks(const TheUnitName: string): string;
function SearchUnitInUnitSet(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 BaseTypeOfNodeHasSubIdents(ANode: TCodeTreeNode): boolean;
function FindBaseTypeOfNode(Params: TFindDeclarationParams; function FindBaseTypeOfNode(Params: TFindDeclarationParams;
@ -1454,9 +1456,9 @@ begin
// raise exception // raise exception
CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true); CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true);
end; end;
{$IFDEF CTDEBUG} { $IFDEF CTDEBUG}
DebugLn('TFindDeclarationTool.FindDeclaration D CursorNode=',NodeDescriptionAsString(CursorNode.Desc),' HasChilds=',dbgs(CursorNode.FirstChild<>nil)); DebugLn('TFindDeclarationTool.FindDeclaration D CursorNode=',NodeDescriptionAsString(CursorNode.Desc),' HasChilds=',dbgs(CursorNode.FirstChild<>nil));
{$ENDIF} { $ENDIF}
if (not IsDirtySrcValid) if (not IsDirtySrcValid)
and (CursorNode.Desc in [ctnUsesSection,ctnUseUnit]) then begin and (CursorNode.Desc in [ctnUsesSection,ctnUseUnit]) then begin
// in uses section // in uses section
@ -2110,8 +2112,8 @@ begin
Result:=DirectoryCache.FindUnitInUnitSet(TheUnitName); Result:=DirectoryCache.FindUnitInUnitSet(TheUnitName);
end; end;
function TFindDeclarationTool.FindSmartHint(const CursorPos: TCodeXYPosition function TFindDeclarationTool.FindSmartHint(const CursorPos: TCodeXYPosition;
): string; Flags: TFindSmartFlags): string;
var var
NewTool: TFindDeclarationTool; NewTool: TFindDeclarationTool;
NewNode, IdentNode, TypeNode, ANode: TCodeTreeNode; NewNode, IdentNode, TypeNode, ANode: TCodeTreeNode;
@ -2124,10 +2126,9 @@ var
NodeStr: String; NodeStr: String;
begin begin
Result:=''; Result:='';
if not FindDeclaration(CursorPos,DefaultFindSmartFlags, if not FindDeclaration(CursorPos,Flags,NewTool,NewNode,NewPos,NewTopLine) then
NewTool,NewNode,NewPos,NewTopLine) then
begin begin
// identifier not found or already at declaration // identifier not found
exit; exit;
end; end;