Skip to content

06 Propath

Gilles Querret edited this page Sep 11, 2024 · 2 revisions
  1. First, we'll add a propath entry pointing to a directory on disk. Open the project configuration file and add the following entry in the buildPath attribute section. Remember to escape backslashes in JSON files.

    {
      "path": "c:\\workshop\\dependency",
      "type": "propath"
    }
  2. Restart the language server ; an error will be thrown.

    The language server reports an error because the specified propath does not exist on disk. To resolve this issue, create the directory and restart the language server.

  3. Create c:\workshop\dependency\myInclude.i, and define a temp-table in it:

    define temp-table myTT no-undo
      field fld1 as int
      field fld2 as int
      field fld3 as char
      index myTT-PK is primary unique fld1.
    

    Code completion will now be available for the temp-table if you add the reference in src/test1.p:

    Due to a bug in the language server, code completion for file names in propath entries is not available. However, it works for file names in source directories. You can use F12 (or right-click and select "Go to Definition") while the caret is within the curly braces to open the include file.

  4. We will now add a Propath entry for a procedure library. The OpenEdge.Net.pl library is not included in the Propath by default. You can add it with the following line:

    {
      "path": "${DLC}/tty/netlib/openedge.net.pl",
      "type": "propath"
    }

    Restart the language server. Code completion will be available for class names:

    Note that accepting a class name will automatically add the USING statement if required. There are multiple enhancement requests regarding the style of USING statements, and addressing these is high on the priority list.

  5. Documentation (javadoc style) can be added to propath entries. Add the documentation attribute to the propath entry:

    {
      "path": "${DLC}/tty/openedge.core.pl",
      "type": "propath",
      "documentation": "C:\\workshop\\corelib.json"
    },
    {
      "path": "${DLC}/tty/netlib/openedge.net.pl",
      "type": "propath",
      "documentation": "C:\\workshop\\netlib.json"
    }
  6. Restart the language server, open src/test2.p, and copy & paste this code:

     using OpenEdge.Core.Collections.* from propath.
     using OpenEdge.Net.HTTP.*.
     using OpenEdge.Net.URI.
     using Progress.Json.ObjectModel.*.
    
     define variable oClient as IHttpClient no-undo.
     define variable oURI as URI no-undo.
     define variable oRequest as IHttpRequest no-undo. 
     define variable OResponse as IHttpResponse no-undo.
     define variable oList as IList no-undo.
    
     oURI = URI:Parse("http://example.com").
     oRequest = RequestBuilder:GET(oURI):request.
    
     oClient = ClientBuilder:Build():Client.
     oResponse = oClient:Execute(oRequest).
    
     if oResponse:StatusCode <> 200 then
         return error "Request Error: " + string(oResponse:StatusCode).
     else do:
         message string(oResponse:StatusCode) + " -- " + oResponse:StatusReason.
         output to "target/output.html".
         put unformatted oResponse:entity.
         output close.
         message "target/output.html written".
     end.
    
     // OpenEdge.Core
     oList = new List().
     oList:Add(1, oClient).
    
     quit.
    


Next chapter

Clone this wiki locally