IDE, CodeTools: support {scopedenums on} in "case ofall" code template

git-svn-id: trunk@53039 -
This commit is contained in:
ondrej 2016-09-26 18:14:15 +00:00
parent 8b5f7616e7
commit c0cc369d3d
3 changed files with 18 additions and 7 deletions

View File

@ -487,7 +487,7 @@ type
out ListOfPCodeXYPosition: TFPList;
SkipAbstractsInStartClass: boolean = false): boolean;
function GetValuesOfCaseVariable(Code: TCodeBuffer; X,Y: integer;
List: TStrings): boolean;
List: TStrings; WithTypeDefIfScoped: boolean): boolean;
function GatherOverloads(Code: TCodeBuffer; X,Y: integer;
out Graph: TDeclarationOverloadsGraph): boolean;
@ -2406,7 +2406,7 @@ begin
end;
function TCodeToolManager.GetValuesOfCaseVariable(Code: TCodeBuffer; X,
Y: integer; List: TStrings): boolean;
Y: integer; List: TStrings; WithTypeDefIfScoped: boolean): boolean;
var
CursorPos: TCodeXYPosition;
begin
@ -2419,7 +2419,7 @@ begin
CursorPos.Y:=Y;
CursorPos.Code:=Code;
try
Result:=FCurCodeTool.GetValuesOfCaseVariable(CursorPos,List);
Result:=FCurCodeTool.GetValuesOfCaseVariable(CursorPos,List,WithTypeDefIfScoped);
except
on e: Exception do Result:=HandleException(e);
end;

View File

@ -432,7 +432,7 @@ type
out ListOfPCodeXYPosition: TFPList;
SkipAbstractsInStartClass: boolean = false): boolean;
function GetValuesOfCaseVariable(const CursorPos: TCodeXYPosition;
List: TStrings): boolean;
List: TStrings; WithTypeDefIfScoped: boolean): boolean;
property Beautifier: TBeautifyCodeOptions read FBeautifier write FBeautifier;
procedure CalcMemSize(Stats: TCTMemStats); override;
@ -3400,7 +3400,8 @@ begin
end;
function TIdentCompletionTool.GetValuesOfCaseVariable(
const CursorPos: TCodeXYPosition; List: TStrings): boolean;
const CursorPos: TCodeXYPosition; List: TStrings; WithTypeDefIfScoped: boolean
): boolean;
var
CleanCursorPos: integer;
CursorNode: TCodeTreeNode;
@ -3410,6 +3411,7 @@ var
ExprType: TExpressionType;
Node: TCodeTreeNode;
Tool: TFindDeclarationTool;
EnumPrefix: string;
begin
Result:=false;
ActivateGlobalWriteLock;
@ -3467,9 +3469,18 @@ begin
ctnEnumerationType:
begin
if WithTypeDefIfScoped
and (Tool.Scanner.GetDirectiveValueAt(sdScopedEnums, Node.StartPos) = '1') then
begin
Tool.MoveCursorToCleanPos(Node.Parent.StartPos);
Tool.ReadNextAtom;
EnumPrefix := Tool.GetAtom+'.';
end else
EnumPrefix := '';
Node:=Node.FirstChild;
while Node<>nil do begin
List.Add(GetIdentifier(@Tool.Src[Node.StartPos]));
List.Add(EnumPrefix+GetIdentifier(@Tool.Src[Node.StartPos]));
Node:=Node.NextBrother;
end;
end;

View File

@ -511,7 +511,7 @@ begin
end;
if not CodeToolBoss.GetValuesOfCaseVariable(
SrcEdit.CodeToolsBuffer as TCodeBuffer,
CaretXY.X,CaretXY.Y,List) then
CaretXY.X,CaretXY.Y,List,True) then
begin
Result:=false;
ErrorMsg:=CodeToolBoss.ErrorMessage;