diff --git a/Source/codetools/simba.ide_codetools_insight.pas b/Source/codetools/simba.ide_codetools_insight.pas index 6a30f08c0..d196d31c9 100644 --- a/Source/codetools/simba.ide_codetools_insight.pas +++ b/Source/codetools/simba.ide_codetools_insight.pas @@ -139,7 +139,10 @@ function TCodeinsight.DoFindInclude(Sender: TmwBasePasLex; var FileName: String; Include := CodetoolsIncludes.Get(Sender); if (Include <> nil) then + begin + FScriptParser.Root.Items.Add(TDeclaration_IncludeDirective.Create(FScriptParser, Include.FileName)); FIncludeParsers.Add(Include); + end; end; function TCodeinsight.DoFindPlugin(Sender: TmwBasePasLex; var FileName: String): Boolean; diff --git a/Source/codetools/simba.ide_codetools_parser.pas b/Source/codetools/simba.ide_codetools_parser.pas index f6a3dbc70..bbe1ea8af 100644 --- a/Source/codetools/simba.ide_codetools_parser.pas +++ b/Source/codetools/simba.ide_codetools_parser.pas @@ -160,6 +160,12 @@ TDeclaration_Keyword = class(TDeclaration) end; TDeclaration_Anchor = class(TDeclaration); + TDeclaration_IncludeDirective = class(TDeclaration) + public + FileName: String; + + constructor Create(AParser: TCodeParser; AFileName: String); reintroduce; + end; TDeclaration_WithStatement = class(TDeclaration); TDeclaration_WithVariableList = class(TDeclaration); @@ -364,6 +370,10 @@ TCodeParser = class(TmwSimplePasPar) function GetCaretPos: Integer; procedure SetCaretPos(const Value: Integer); + function PushStack(const AClass: TDeclarationClass): TDeclaration; inline; + function PushStub(const AClass: TDeclarationClass): TDeclaration; inline; + procedure PopStack; inline; + procedure EmptyVarStub(const VarStub: TDeclaration_VarStub; const VarClass: TDeclaration_VarClass); procedure EmptyParamStub(const ParamStub: TDeclaration_ParamStub); @@ -372,10 +382,6 @@ TCodeParser = class(TmwSimplePasPar) function InDeclaration(const AClassType1, AClassType2, AClassType3: TDeclarationClass): Boolean; overload; function InDeclaration(const AClassType1, AClassType2, AClassType3, AClassType4: TDeclarationClass): Boolean; overload; - function PushStack(const AClass: TDeclarationClass): TDeclaration; inline; - function PushStub(const AClass: TDeclarationClass): TDeclaration; inline; - procedure PopStack; inline; - procedure ParseFile; override; procedure OnLibraryDirect(Sender: TmwBasePasLex); override; //Plugins procedure OnIncludeDirect(Sender: TmwBasePasLex); override; //Includes @@ -438,6 +444,7 @@ TCodeParser = class(TmwSimplePasPar) procedure EnumeratedTypeItem; override; //Enum Element procedure QualifiedIdentifier; override; //Enum Element Name public + property Root: TDeclaration read FRoot; property Plugins: TStringList read FPlugins; property FileName: String read GetFileName; @@ -577,6 +584,13 @@ constructor TDeclaration_Keyword.Create(Keyword: String); isKeyword := True; end; +constructor TDeclaration_IncludeDirective.Create(AParser: TCodeParser; AFileName: String); +begin + inherited Create(AParser, nil, AParser.Lexer.TokenPos, AParser.Lexer.TokenPos + AParser.Lexer.TokenLen); + + FileName := AFileName; +end; + constructor TDeclaration_Type.Create(AParser: TCodeParser; AOwner: TDeclaration; AStart: Integer; AEnd: Integer); begin inherited Create(AParser, AOwner, AStart, AEnd); diff --git a/Source/simba.ide_showdeclaration.pas b/Source/simba.ide_showdeclaration.pas index 0c3bf89fa..27664f7b0 100644 --- a/Source/simba.ide_showdeclaration.pas +++ b/Source/simba.ide_showdeclaration.pas @@ -33,6 +33,13 @@ procedure FindAndShowDeclaration(Script, ScriptFileName: String; CaretPos: Integ Codeinsight.SetScript(Script, ScriptFileName, CaretPos); Codeinsight.Run(); + Decl := Codeinsight.ScriptParser.Items.GetByPosition(CaretPos); + if (Decl is TDeclaration_IncludeDirective) then + begin + SimbaScriptTabsForm.Open(TDeclaration_IncludeDirective(Decl).FileName); + Exit; + end; + Decl := Codeinsight.ParseExpression(What, []); if (Decl <> nil) then begin