3.1.0 • Published 5 years ago

xrefparser v3.1.0

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

OpenEdge XREF parser in TypeScript

This is a parser/searcher library for OpenEdge xref files.

Initialization

Searching the sources which contain creates and deletes of in 'Klantbes' table is as easy as:

import { Parser, Searcher } from 'xrefparser';

const parser = new Parser();
const xrefdata = parser.parseDir('c:/usr/xref', 'D:\\wintmp\\build492943069\\devmain\\');

const searcher = new Searcher(xrefdata);

const sources = searcher
                .getTableReferences('Klantbes', true, undefined, true)
                .map(table => table.sourcefile);

console.log(sources);

Parser class

When instantiated there's basically one relevant method; parseDir

parseDir

parseDir(dirname: string, sourcebasedir?: string): XrefFile[]

dirname is the root directory where all the .xref files are located. sourcebasedir is the optional parameter stating what the root directory of the sources when they were compiled. This is substracted from the sourcefile properties.

Searcher class

The only constructor takes XrefFile[] as input.

add

add(xreffiles: Xreffile[]);

This method add/merges the xreffiles into the existing Xreffile[]'s.

getDatabaseNames

getDatabaseNames(sources?: string[]): string[]

Returns an array of database names found in sources. If sources is undefined, all the database names of all sources are returned.

getDatabaseReferences

getDatabaseReferences(databaseName: string): XrefFile[]

Returns an array with all the XrefFile contains references to the databaseName

getFieldReferences

getFieldReferences(fieldname: string, tablename?: string, hasUpdates?: boolean): XrefFile[]

Looks for occurences of fieldname, optionally in table tablename. The optional hasUpdates parameter gives the possibility the search for sources which update a certain field (or not). If tablename or hasUpdates are not to be taken into consideration, omit them or pass undefined.

getTableReferences

getTableReferences(tablename: string, hasCreates?: boolean, hasUpdates?: boolean, hasDeletes?: boolean): Xreffile[]

Looks for uses of tablename in the all the Xreffile objects and returns XrefFile[]. Use map as in the example to turn it into an array of source names (or whatever you want). If for the has* parameters undefined is used, the particular action is not searched for. This contrary to hasCreated = false where sources are returned that do not create the particular table.

Performance

Above case takes on a Dell XPS15 9560 around 8s to parse all the xref files and 3ms to search for create/delete references in the 'Klantbes' table. There are around 3850 xref files which are combined 350MB on disk.

Release notes

The release notes can be found at github/releasenotes.md

Example Xreffile

The Parser turns in the .xref files into an array of Xreffile objects. Beneath an example which is pretty self explanatory:

{
  "xreffile": "C:/devoe/sandbox/src/xref_out/xref/CustomerBE.cls.xref",
  "sourcefile": "xref/CustomerBE.cls",
  "cpInternal": "UTF-8",
  "cpStream": "UTF-8",
  "includes": [
    "xref/findfirstcustomer.i"
  ],
  "tablenames": [
    "Customer"
  ],
  "classes": [],
  "invokes": [
    "xref.BaseClass:Cleanup",
    "xref.BusinessEntity:BusinessEntity",
    "xref.CustomerBE:Cleanup"
  ],
  "annotations": [
    "todo(version=12.x, message=refactor for efficiency)",
    "linecheck(lineno=44)",
    "linecheck(lineno=46)"
  ],
  "tables": [
    {
      "name": "Customer",
      "database": "sports2000",
      "isCreated": false,
      "isDeleted": false,
      "isUpdated": true,
      "fields": [
        {
          "name": "CustNum",
          "isUpdated": false
        },
        {
          "name": "CreditLimit",
          "isUpdated": true
        },
        {
          "name": "Name",
          "isUpdated": false
        }
      ]
    }
  ],
  "class": {
    "name": "xref.CustomerBE",
    "inherits": "xref.BusinessEntity",
    "implements": [
      "xref.IDisposable"
    ]
  }
}
3.1.0

5 years ago

3.0.4

6 years ago

3.0.3

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.3.5

6 years ago

0.3.4

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago