Skip to content

Commit

Permalink
viewing *some* files
Browse files Browse the repository at this point in the history
  • Loading branch information
marcellourbani committed Oct 24, 2018
1 parent efa7675 commit 7a4799b
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 14 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# ABAP remote filesystem for visual studio code

Ideally one day this will allow you to edit your ABAP code directly in Visual studio code
Very early stages, for now it only displays a list of packages
Very early stages, for now it only displays some packages and a handful of object types, no local objects,subroutines in object lists...

Even things that do work need a big refactor
![image](https://user-images.githubusercontent.com/2453277/47466602-dd99dc00-d7e9-11e8-97ed-28e23dfd8f90.png)
syntax highlighting added manually with the [ABAP language extension](https://marketplace.visualstudio.com/items?itemName=larshp.vscode-abap),picture was too lame without it :)

## Features

Expand Down
21 changes: 21 additions & 0 deletions src/abap/AbapFunctionGroup.ts
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`
})
}
}
8 changes: 8 additions & 0 deletions src/abap/AbapFunctionModule.ts
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" })
}
}
2 changes: 1 addition & 1 deletion src/abap/AbapObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class AbapObject {
}

getUri(base: Uri): Uri {
return base.with({ path: this.path })
return base.with({ path: this.path + "/source/main" })
}
namespace(): string {
return this.name.match(/^\//)
Expand Down
21 changes: 14 additions & 7 deletions src/abap/AbapObjectFactory.ts
Original file line number Diff line number Diff line change
@@ -1,16 +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":
return new AbapPackage(
node.OBJECT_TYPE,
node.OBJECT_NAME,
node.OBJECT_URI
)
default:
return new AbapObject(node.OBJECT_TYPE, node.OBJECT_NAME, node.OBJECT_URI)
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)
}
1 change: 1 addition & 0 deletions src/abap/AbapPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export class AbapPackage extends AbapObject {
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`
})
}
Expand Down
8 changes: 8 additions & 0 deletions src/abap/AbapSimpleObject.ts
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 })
}
}
3 changes: 2 additions & 1 deletion src/adt/AdtConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export class AdtConnection {
},
method,
headers: {
"x-csrf-token": this._csrftoken
"x-csrf-token": this._csrftoken,
Accept: "*/*"
}
} as request.Options //workaround for compiler bug
}
Expand Down
7 changes: 4 additions & 3 deletions src/adt/AdtNode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FileStat, FileType, Uri } from "vscode"

export class AdtNode implements FileStat {
type: FileType
ctime: number
Expand All @@ -24,9 +25,9 @@ export class AdtNode implements FileStat {
const sep = this.uri.path.match(/\/$/) || childname.match(/^\//) ? "" : "/"
return this.uri.path + sep + childname
}
setContents(body: Buffer): void {
this.body = body
this.size = body.length
setContents(body: string): void {
this.body = Buffer.from(body)
this.size = this.body.length
this.fetched = true
}
}
5 changes: 4 additions & 1 deletion src/adt/AdtPathManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export class AdtPathManager {
const url = server.actualUri(vsUrl)

return server.connectionP
.then(conn => conn.request(url, "POST"))
.then(conn => conn.request(url, this.getMethod(url)))
.then(response => this.parse(vsUrl, response, server, cached))
}
getMethod(uri: Uri): string {
return uri.path.match(/\/nodestructure/i) ? "POST" : "GET"
}
}

0 comments on commit 7a4799b

Please sign in to comment.