-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Several features: package contents, basic support for function groups…
…, programs, classes
- Loading branch information
Showing
17 changed files
with
362 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { AbapObject } from "./AbapObject" | ||
import { Uri } from "vscode" | ||
|
||
export class AbapFunctionGroup extends AbapObject { | ||
isLeaf() { | ||
return false | ||
} | ||
getUri(base: Uri): Uri { | ||
const ptype = encodeURIComponent(this.type) | ||
const pname = encodeURIComponent(this.name) | ||
const techname = encodeURIComponent( | ||
this.namespace() === "" | ||
? "SAPL" + this.name | ||
: `/${this.namespace()}/SAPL${this.nameinns}` | ||
) | ||
return base.with({ | ||
path: "/sap/bc/adt/repository/nodestructure", | ||
query: `parent_name=${pname}&parent_tech_name=${techname}&parent_type=${ptype}&withShortDescriptions=true` | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { AbapObject } from "./AbapObject" | ||
import { Uri } from "vscode" | ||
|
||
export class AbapFunctionModule extends AbapObject { | ||
getUri(base: Uri): Uri { | ||
return base.with({ path: this.path + "/source/main" }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Uri } from "vscode" | ||
|
||
export interface AbapObjectPart { | ||
type: string | ||
name: string | ||
parent: AbapObject | ||
} | ||
|
||
export class AbapObject { | ||
type: string | ||
name: string | ||
path: string | ||
|
||
constructor(type: string, name: string, path: string) { | ||
this.name = name | ||
this.type = type | ||
this.path = path | ||
} | ||
|
||
isLeaf() { | ||
return true | ||
} | ||
|
||
getUri(base: Uri): Uri { | ||
return base.with({ path: this.path + "/source/main" }) | ||
} | ||
namespace(): string { | ||
return this.name.match(/^\//) | ||
? this.name.replace(/^\/([^\/]*)\/.*/, "$1") | ||
: "" | ||
} | ||
nameinns(): string { | ||
return this.name.replace(/^\/[^\/]*\/(.*)/, "$1") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ObjectNode } from "../adt/AdtParser" | ||
import { AbapObject } from "./AbapObject" | ||
import { AbapPackage } from "./AbapPackage" | ||
import { AbapFunctionGroup } from "./AbapFunctionGroup" | ||
import { AbapSimpleObject } from "./AbapSimpleObject" | ||
|
||
export function fromObjectNode(node: ObjectNode): AbapObject { | ||
let objtype = AbapObject | ||
switch (node.OBJECT_TYPE) { | ||
case "DEVC/K": | ||
objtype = AbapPackage | ||
break | ||
case "FUGR/F": | ||
objtype = AbapFunctionGroup | ||
break | ||
case "TABL/DT": | ||
case "DOMA/DT": | ||
case "DTEL/DE": | ||
objtype = AbapSimpleObject | ||
break | ||
} | ||
return new objtype(node.OBJECT_TYPE, node.OBJECT_NAME, node.OBJECT_URI) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { AbapObject } from "./AbapObject" | ||
import { Uri } from "vscode" | ||
|
||
export class AbapPackage extends AbapObject { | ||
isLeaf() { | ||
return false | ||
} | ||
getUri(base: Uri): Uri { | ||
const ptype = encodeURIComponent(this.type) | ||
const pname = encodeURIComponent(this.name) | ||
return base.with({ | ||
path: "/sap/bc/adt/repository/nodestructure", | ||
query: `parent_name=${pname}&parent_tech_name=${pname}&parent_type=${ptype}&withShortDescriptions=true` | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { AbapObject } from "./AbapObject" | ||
import { Uri } from "vscode" | ||
|
||
export class AbapSimpleObject extends AbapObject { | ||
getUri(base: Uri): Uri { | ||
return base.with({ path: this.path }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,33 @@ | ||
import { FileStat, FileType } from "vscode" | ||
import { AdtFile } from "./AdtFile" | ||
import { ObjectNode } from "./AdtParser" | ||
|
||
export type AdtDirItem = AdtFile | AdtNode | ||
import { FileStat, FileType, Uri } from "vscode" | ||
|
||
export class AdtNode implements FileStat { | ||
static fromTreeContent(fromTreeContent: ObjectNode[]): AdtNode { | ||
const node = new AdtNode("") | ||
return node | ||
} | ||
type: FileType = FileType.Directory | ||
name: string | ||
type: FileType | ||
ctime: number | ||
mtime: number | ||
size: number = 0 | ||
entries: Map<string, AdtDirItem> | ||
constructor( | ||
name: string, | ||
ctime: number = Date.now(), | ||
mtime: number = Date.now() | ||
) { | ||
this.name = name | ||
this.ctime = ctime | ||
this.mtime = mtime | ||
entries: Map<string, AdtNode> | ||
uri: Uri | ||
fetched: boolean | ||
body: Buffer | undefined | ||
needRefresh(): any { | ||
return !this.fetched | ||
} | ||
constructor(path: Uri, isDirectory: boolean, fetched: boolean) { | ||
this.ctime = Date.now() | ||
this.mtime = Date.now() | ||
this.entries = new Map() | ||
this.uri = path | ||
this.type = isDirectory ? FileType.Directory : FileType.File | ||
this.fetched = fetched | ||
} | ||
|
||
childPath(childname: string): string { | ||
const sep = this.uri.path.match(/\/$/) || childname.match(/^\//) ? "" : "/" | ||
return this.uri.path + sep + childname | ||
} | ||
setChildrenFromTreeContent(children: ObjectNode[]): AdtNode { | ||
this.entries.clear() | ||
children.forEach(objnode => { | ||
this.entries.set( | ||
objnode.OBJECT_NAME, | ||
objnode.EXPANDABLE | ||
? new AdtNode(objnode.OBJECT_NAME) | ||
: new AdtFile(objnode.OBJECT_NAME) | ||
) | ||
}) | ||
return this | ||
setContents(body: string): void { | ||
this.body = Buffer.from(body) | ||
this.size = this.body.length | ||
this.fetched = true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.