I'm still stuck on this problem. I can get the full proc head using 
CodeTool.ExtractProcHead but I can't get the name/type parameter pairs in a 
list (unless I do something stupid like parse the string from ExtractProcHead). 
I need to return the parameters in discrete pairs in text that matches the 
format of the header. I know ExtractProcHead finds this information but it's 
lost in the function before it returns.


function ExtractContext(CurContext: TCodeContextInfoItem; var ParamPairs: 
TStringList): String;
  var
    Code: String;
    CurExprType: TExpressionType;
    CodeNode, ChildNode: TCodeTreeNode;
    CodeTool: TFindDeclarationTool;
    ParamList: TCodeTreeNode;
  begin
    CurExprType:=CurContext.Expr;
    Code:=ExpressionTypeDescNames[CurExprType.Desc];
    if CurExprType.Context.Node<>nil then
      begin
        CodeNode:=CurExprType.Context.Node;
        CodeTool:=CurExprType.Context.Tool;
        case CodeNode.Desc of
          ctnProcedure:
            begin
              Code:=CodeTool.ExtractProcHead(CodeNode,
                  
[phpWithVarModifiers,phpWithParameterNames,phpWithDefaultValues,
                   phpWithResultType]);

              // TODO: get param name/type pairs
              ParamList:=CodeTool.GetProcParamList(CodeNode);
              if ParamList <> nil then
                begin
                  ChildNode:=ParamList.FirstChild;
                  while ChildNode<>nil do
                    begin
                      Code += ChildNode.DescAsString+' ';
                      ChildNode:=ChildNode.NextBrother;
                    end;
                end;
            end;
        end;
      end;
    Result := Code;
  end;


Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to