mirror of
https://github.com/moparisthebest/Simba
synced 2025-02-07 02:30:19 -05:00
Fixed a bug in code insight so indexed properties should work better.
This commit is contained in:
parent
1d001eb8d7
commit
3ed1f42aab
@ -662,14 +662,14 @@ end;
|
||||
|
||||
function TCodeInsight.FindVarBase(s: string; GetStruct: Boolean = False; Return: TVarBase = vbName): TDeclaration;
|
||||
|
||||
function PartOfWith(s: string; out Decl: TDeclaration; Return: TVarBase; CheckClass: Boolean): Boolean;
|
||||
function PartOfWith(s: string; out Decl: TDeclaration; Return: TVarBase; CheckClass: Boolean; var ArrayCount: Integer): Boolean;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result := False;
|
||||
for i := High(InWith) downto Low(InWith) do
|
||||
if CheckClass xor (i <> InClassFunction) then
|
||||
if TciStruct(InWith[i]).HasField(s, Decl, Return) then
|
||||
if TciStruct(InWith[i]).HasField(s, Decl, Return, ArrayCount) then
|
||||
begin
|
||||
Result := True;
|
||||
Break;
|
||||
@ -823,10 +823,10 @@ begin
|
||||
VarBase := vbType;
|
||||
|
||||
if (InStruct <> nil) then
|
||||
Found := InStruct.HasField(f, Result, VarBase)
|
||||
Found := InStruct.HasField(f, Result, VarBase, NeedArrayCount)
|
||||
else
|
||||
begin
|
||||
Found := CheckVar and PartOfWith(f, Result, VarBase, False);
|
||||
Found := CheckVar and PartOfWith(f, Result, VarBase, False, NeedArrayCount);
|
||||
if (not Found) and (i = Low(sa)) then
|
||||
begin
|
||||
Found :=
|
||||
@ -835,7 +835,7 @@ begin
|
||||
DoFindStruct(f, Result, VarBase, NeedArrayCount);
|
||||
end;
|
||||
if (not Found) and CheckVar then
|
||||
Found := PartOfWith(f, Result, VarBase, True);
|
||||
Found := PartOfWith(f, Result, VarBase, True, NeedArrayCount);
|
||||
end;
|
||||
|
||||
if Found and (Result is TciTypeKind) then
|
||||
@ -1065,6 +1065,38 @@ procedure TCodeInsight.Proposal_AddDeclaration(Item: TDeclaration; ItemList, Ins
|
||||
AddEnums(d, ItemList, InsertList);
|
||||
end;
|
||||
|
||||
function PropertyIndex(Item: TciClassProperty): string;
|
||||
var
|
||||
i: Integer;
|
||||
d: TDeclaration;
|
||||
a: TDeclarationArray;
|
||||
begin
|
||||
d := Item.Items.GetFirstItemOfClass(TciPropertyParameterList);
|
||||
Result := '';
|
||||
|
||||
if (d <> nil) then
|
||||
begin
|
||||
a := d.Items.GetItemsOfClass(TciIdentifier);
|
||||
for i := Low(a) to High(a) do
|
||||
begin
|
||||
if (Result <> '') then
|
||||
Result := Result + ', ';
|
||||
Result := Result + a[i].ShortText;
|
||||
end;
|
||||
|
||||
d := d.Items.GetFirstItemOfClass(TciTypeKind);
|
||||
if (d <> nil) then
|
||||
begin
|
||||
if (Result <> '') then
|
||||
Result := Result + ': ';
|
||||
Result := Result + d.ShortText;
|
||||
end;
|
||||
end;
|
||||
|
||||
if (Result <> '') then
|
||||
Result := '['+Result+']';
|
||||
end;
|
||||
|
||||
var
|
||||
i: Integer;
|
||||
FirstColumn, s, n: string;
|
||||
@ -1151,6 +1183,8 @@ begin
|
||||
Continue;
|
||||
{$ENDIF}*)
|
||||
s := FirstColumn + FormatMainName(n);
|
||||
if (Item is TciClassProperty) then
|
||||
s := s + FormatMainExtra(PropertyIndex(TciClassProperty(Item)));
|
||||
if (b[1] <> nil) then
|
||||
s := s + FormatMainExtra(' = ' + b[1].ShortText);
|
||||
if (b[2] <> nil) then
|
||||
|
@ -92,7 +92,8 @@ type
|
||||
private
|
||||
function GetShortText: string; override;
|
||||
public
|
||||
function HasField(Name: string; out Decl: TDeclaration; Return: TVarBase = vbName): Boolean;
|
||||
function HasField(Name: string; out Decl: TDeclaration; Return: TVarBase; var ArrayCount: Integer): Boolean; overload;
|
||||
function HasField(Name: string; out Decl: TDeclaration; Return: TVarBase = vbName): Boolean; overload;
|
||||
function GetDefault(Return: TVarBase = vbName): TDeclaration;
|
||||
end;
|
||||
|
||||
@ -185,6 +186,8 @@ type
|
||||
TciClassMethodHeading = class(TciProcedureDeclaration); //Record + Class
|
||||
TciClassProperty = class(TDeclaration); //Record + Class
|
||||
TciPropertyDefault = class(TDeclaration); //Record + Class
|
||||
TciIdentifier = class(TDeclaration); //Record + Class
|
||||
TciPropertyParameterList = class(TDeclaration); //Record + Class
|
||||
|
||||
TciSetType = class(TDeclaration); //Set
|
||||
TciOrdinalType = class(TDeclaration); //Set
|
||||
@ -263,6 +266,8 @@ type
|
||||
procedure PropertyName; override; //Record + Class
|
||||
procedure TypeId; override; //Record + Class
|
||||
procedure PropertyDefault; override; //Record + Class
|
||||
procedure Identifier; override; //Record + Class
|
||||
procedure PropertyParameterList; override; //Record + Class
|
||||
|
||||
procedure SetType; override; //Set
|
||||
procedure OrdinalType; override; //Set + Array Range
|
||||
@ -630,10 +635,11 @@ begin
|
||||
Result := fShortText;
|
||||
end;
|
||||
|
||||
function TciStruct.HasField(Name: string; out Decl: TDeclaration; Return: TVarBase = vbName): Boolean;
|
||||
function TciStruct.HasField(Name: string; out Decl: TDeclaration; Return: TVarBase; var ArrayCount: Integer): Boolean;
|
||||
var
|
||||
a, b: TDeclarationArray;
|
||||
i, ii: Integer;
|
||||
t: TDeclaration;
|
||||
begin
|
||||
Result := False;
|
||||
Name := PrepareString(Name);
|
||||
@ -665,6 +671,12 @@ begin
|
||||
if (PrepareString(b[ii].CleanText) = Name) then
|
||||
begin
|
||||
Result := True;
|
||||
|
||||
t := a[i].Items.GetFirstItemOfClass(TciPropertyParameterList);
|
||||
if (t <> nil) then
|
||||
//ArrayCount := ArrayCount + t.Items.Count; [a, b] Indices count as 1
|
||||
Inc(ArrayCount);
|
||||
|
||||
if (Return = vbType) then
|
||||
Decl := b[ii].Owner.Items.GetFirstItemOfClass(TciTypeKind)
|
||||
else
|
||||
@ -691,6 +703,13 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TciStruct.HasField(Name: string; out Decl: TDeclaration; Return: TVarBase = vbName): Boolean;
|
||||
var
|
||||
a: Integer;
|
||||
begin
|
||||
Result := HasField(Name, Decl, Return, a);
|
||||
end;
|
||||
|
||||
function TciStruct.GetDefault(Return: TVarBase = vbName): TDeclaration;
|
||||
var
|
||||
d: TDeclaration;
|
||||
@ -1662,7 +1681,7 @@ end;
|
||||
|
||||
procedure TCodeParser.TypeId;
|
||||
begin
|
||||
if (not InDeclaration(TciClassProperty)) then
|
||||
if (not InDeclarations([TciClassProperty, TciPropertyParameterList])) then
|
||||
begin
|
||||
inherited;
|
||||
Exit;
|
||||
@ -1686,6 +1705,32 @@ begin
|
||||
PopStack;
|
||||
end;
|
||||
|
||||
procedure TCodeParser.Identifier;
|
||||
begin
|
||||
if (not InDeclaration(TciPropertyParameterList)) then
|
||||
begin
|
||||
inherited;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
PushStack(TciIdentifier);
|
||||
inherited;
|
||||
PopStack;
|
||||
end;
|
||||
|
||||
procedure TCodeParser.PropertyParameterList;
|
||||
begin
|
||||
if (not InDeclaration(TciClassProperty)) then
|
||||
begin
|
||||
inherited;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
PushStack(TciPropertyParameterList);
|
||||
inherited;
|
||||
PopStack;
|
||||
end;
|
||||
|
||||
procedure TCodeParser.SetType;
|
||||
begin
|
||||
PushStack(TciSetType);
|
||||
|
Loading…
Reference in New Issue
Block a user