IDE: codecontext: added string[]

git-svn-id: trunk@25528 -
This commit is contained in:
mattias 2010-05-20 09:04:13 +00:00
parent eb60223ce2
commit 0a5e197f49
3 changed files with 25 additions and 14 deletions

View File

@ -643,8 +643,6 @@ type
function FindExpressionTypeOfTerm(StartPos, EndPos: integer;
Params: TFindDeclarationParams; WithAsOperator: boolean): TExpressionType;
function FindEndOfExpression(StartPos: integer): integer;
function ConvertNodeToExpressionType(Node: TCodeTreeNode;
Params: TFindDeclarationParams): TExpressionType;
function ReadOperandTypeAtCursor(
Params: TFindDeclarationParams; MaxEndPos: integer = -1): TExpressionType;
function FindExpressionTypeOfPredefinedIdentifier(StartPos: integer;
@ -801,6 +799,8 @@ type
function BaseTypeOfNodeHasSubIdents(ANode: TCodeTreeNode): boolean;
function FindBaseTypeOfNode(Params: TFindDeclarationParams;
Node: TCodeTreeNode): TFindContext;
function ConvertNodeToExpressionType(Node: TCodeTreeNode;
Params: TFindDeclarationParams): TExpressionType;
function FindDeclarationAndOverload(const CursorPos: TCodeXYPosition;
out ListOfPCodeXYPosition: TFPList;

View File

@ -1760,6 +1760,7 @@ begin
else
exit;
end;
//DebugLn(['TIdentCompletionTool.CollectAllContexts add ',FoundContext.Node.DescAsString]);
AddCollectionContext(FoundContext.Tool,FoundContext.Node);
end;
@ -2208,7 +2209,7 @@ var
if not StartInSubContext then
Include(Params.Flags,fdfSearchInParentNodes);
CurrentIdentifierList.Context:=GatherContext;
//DebugLn('CheckContextIsParameter searching procedure ...');
//DebugLn('CheckContextIsParameter searching procedures, properties and variables ...');
GatherContext.Tool.FindIdentifierInContext(Params);
//DebugLn('CheckContextIsParameter END');
Ok:=true;

View File

@ -105,6 +105,7 @@ begin
if CodeContextFrm = nil then
CodeContextFrm := TCodeContextFrm.Create(nil);
CodeContextFrm.SetCodeContexts(CodeContexts);
CodeContextFrm.Visible := True;
Result := True;
finally
@ -294,24 +295,33 @@ procedure TCodeContextFrm.CreateHints(const CodeContexts: TCodeContextInfo);
function FindBaseType(Tool: TFindDeclarationTool; Node: TCodeTreeNode;
var s: string): boolean;
var
Context: TFindContext;
Expr: TExpressionType;
Params: TFindDeclarationParams;
begin
Result:=false;
Params:=TFindDeclarationParams.Create;
try
try
Context:=Tool.FindBaseTypeOfNode(Params,Node);
if Context.Node=nil then exit;
case Context.Node.Desc of
ctnProcedureType:
begin
s:=s+Context.Tool.ExtractProcHead(Context.Node,
[phpWithVarModifiers,phpWithParameterNames,phpWithDefaultValues,
phpWithResultType]);
Result:=true;
Expr:=Tool.ConvertNodeToExpressionType(Node,Params);
if (Expr.Desc=xtContext) and (Expr.Context.Node<>nil) then begin
case Expr.Context.Node.Desc of
ctnProcedureType:
begin
s:=s+Expr.Context.Tool.ExtractProcHead(Expr.Context.Node,
[phpWithVarModifiers,phpWithParameterNames,phpWithDefaultValues,
phpWithResultType]);
Result:=true;
end;
end;
end;
end else if Expr.Desc in (xtAllStringTypes+xtAllWideStringTypes-[xtShortString])
then begin
s:=s+'[1..high(PtrUInt)]';
Result:=true;
end else if Expr.Desc=xtShortString then begin
s:=s+'[0..255]';
Result:=true;
end else
debugln(['FindBaseType ',ExprTypeToString(Expr)]);
except
end;
finally