mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-26 05:00:25 +02:00
codetools: identifier completion: show macros for IFDEF
git-svn-id: trunk@34094 -
This commit is contained in:
parent
5fd93058b5
commit
a461a202af
@ -25,6 +25,7 @@
|
|||||||
Dialog to view and search the whole list.
|
Dialog to view and search the whole list.
|
||||||
|
|
||||||
ToDo:
|
ToDo:
|
||||||
|
-put exact match at start
|
||||||
-quickfix for identifier not found
|
-quickfix for identifier not found
|
||||||
-use identifier: check package version
|
-use identifier: check package version
|
||||||
-clean up old entries
|
-clean up old entries
|
||||||
|
@ -48,9 +48,9 @@ uses
|
|||||||
MemCheck,
|
MemCheck,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Classes, SysUtils, FileProcs, CodeTree, CodeAtom, CodeCache, CustomCodeTool,
|
Classes, SysUtils, FileProcs, CodeTree, CodeAtom, CodeCache, CustomCodeTool,
|
||||||
CodeToolsStrConsts, KeywordFuncLists, BasicCodeTools, LinkScanner,
|
CodeToolsStrConsts, KeywordFuncLists, BasicCodeTools, LinkScanner, AVL_Tree,
|
||||||
AVL_Tree, CodeToolMemManager, DefineTemplates,
|
CodeToolMemManager, DefineTemplates, SourceChanger, FindDeclarationTool,
|
||||||
SourceChanger, FindDeclarationTool, PascalReaderTool, PascalParserTool;
|
PascalReaderTool, PascalParserTool, CodeToolsStructs, ExprEval;
|
||||||
|
|
||||||
type
|
type
|
||||||
TIdentCompletionTool = class;
|
TIdentCompletionTool = class;
|
||||||
@ -1948,11 +1948,37 @@ function TIdentCompletionTool.IsInCompilerDirective(CursorPos: TCodeXYPosition
|
|||||||
CurrentIdentifierList.Add(NewItem);
|
CurrentIdentifierList.Add(NewItem);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure AddMacros;
|
||||||
|
var
|
||||||
|
Macros: TStringToStringTree;
|
||||||
|
StrItem: PStringToStringTreeItem;
|
||||||
|
|
||||||
|
procedure Add(e: TExpressionEvaluator);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
for i:=0 to e.Count-1 do
|
||||||
|
Macros[e.Names(i)]:=e.Values(i);
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Macros:=TStringToStringTree.Create(false);
|
||||||
|
try
|
||||||
|
Add(Scanner.InitialValues);
|
||||||
|
Add(Scanner.Values);
|
||||||
|
for StrItem in Macros do
|
||||||
|
Key(StrItem^.Name);
|
||||||
|
finally
|
||||||
|
Macros.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
Line: String;
|
Line: String;
|
||||||
p: Integer;
|
p: Integer;
|
||||||
EndPos: Integer;
|
EndPos: Integer;
|
||||||
InnerStart: Integer;
|
InnerStart: Integer;
|
||||||
|
Directive: String;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
Line:=CursorPos.Code.GetLine(CursorPos.Y-1);
|
Line:=CursorPos.Code.GetLine(CursorPos.Y-1);
|
||||||
@ -1965,10 +1991,15 @@ begin
|
|||||||
// in a directive
|
// in a directive
|
||||||
Result:=true;
|
Result:=true;
|
||||||
InnerStart:=p;
|
InnerStart:=p;
|
||||||
if Line[InnerStart]='{' then inc(InnerStart,2)
|
if Line[InnerStart]='{' then
|
||||||
else inc(InnerStart,3);
|
inc(InnerStart,2)
|
||||||
|
else
|
||||||
|
inc(InnerStart,3);
|
||||||
//debugln(['TIdentCompletionTool.IsInCompilerDirective InnerStart=',InnerStart,' X=',CursorPos.X]);
|
//debugln(['TIdentCompletionTool.IsInCompilerDirective InnerStart=',InnerStart,' X=',CursorPos.X]);
|
||||||
if InnerStart=CursorPos.X then begin
|
if (InnerStart=CursorPos.X)
|
||||||
|
or ((CursorPos.X>=InnerStart) and (InnerStart<=length(Line))
|
||||||
|
and (CursorPos.X<=InnerStart+GetIdentLen(@Line[InnerStart])))
|
||||||
|
then begin
|
||||||
Key('ALIGN');
|
Key('ALIGN');
|
||||||
Key('ALIGNASSERTIONS');
|
Key('ALIGNASSERTIONS');
|
||||||
Key('ASMMODE');
|
Key('ASMMODE');
|
||||||
@ -2047,6 +2078,16 @@ begin
|
|||||||
Key('WARNING');
|
Key('WARNING');
|
||||||
Key('WARNINGS');
|
Key('WARNINGS');
|
||||||
Key('WRITABLECONST');
|
Key('WRITABLECONST');
|
||||||
|
end else if InnerStart<=length(Line) then begin
|
||||||
|
Directive:=lowercase(GetIdentifier(@Line[InnerStart]));
|
||||||
|
if (Directive='ifdef')
|
||||||
|
or (Directive='ifndef')
|
||||||
|
or (Directive='if')
|
||||||
|
or (Directive='elseif')
|
||||||
|
or (Directive='ifc')
|
||||||
|
then begin
|
||||||
|
AddMacros;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user