Skip to content

Commit

Permalink
ui: show method visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
z7zmey committed Oct 25, 2017
1 parent 70802a6 commit 1bda221
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
14 changes: 8 additions & 6 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ func GetTree(w http.ResponseWriter, r *http.Request) {
}

type umlMethod struct {
NsName string
Name string
NsName string
Name string
Visibility string
}

type uml struct {
Expand Down Expand Up @@ -135,10 +136,10 @@ func GetUml(w http.ResponseWriter, r *http.Request) {

for _, astClass := range classes {
var cls = uml{
astClass.Name,
string(astClass.Extends),
[]umlMethod{},
[]string{},
astClass.Name,
string(astClass.Extends),
[]umlMethod{},
[]string{},
astClass.IsAbstract || astClass.IsInterface,
}

Expand All @@ -156,6 +157,7 @@ func GetUml(w http.ResponseWriter, r *http.Request) {
var umlMethod = umlMethod{
astMethod.ID,
astMethod.Name,
astMethod.Visibility,
}
cls.Methods = append(cls.Methods, umlMethod)
}
Expand Down
13 changes: 13 additions & 0 deletions php-worker/AstVisitor/GraphVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ public function enterNode(Node $node)
}

if ($node instanceof Node\Stmt\ClassMethod) {
$visibility = '';

if ($node->isPublic()) {
$visibility = '+';
}
if ($node->isProtected()) {
$visibility = '#';
}
if ($node->isPrivate()) {
$visibility = '-';
}

$data = [
'methods' => [
[
Expand All @@ -98,6 +110,7 @@ public function enterNode(Node $node)
'class' => (string)$node->parent->namespacedName,
'types' => $node->returnTypes,
'isAbstract' => $node->isAbstract() || $node->parent instanceof Node\Stmt\Interface_,
'visibility' => $visibility
]
]
];
Expand Down
18 changes: 9 additions & 9 deletions schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,17 @@ type AstFile struct {
}

type AstClass struct {
rdfType struct{} `quad:"@type > ast:class"`
Name string `json:"name" quad:"@id"`
StartLine int `json:"startLine" quad:"ast:start_line,optional"`
EndLine int `json:"endLine" quad:"ast:end_line,optional"`
File quad.IRI `json:"file" quad:"ast:file"`
Extends quad.IRI `json:"extends" quad:"ast:extends,optional"`
Implements []quad.IRI `json:"implements" quad:"ast:implements,optional"`
IsAbstract bool `json:"isAbstract" quad:"ast:is_abstract,optional"`
rdfType struct{} `quad:"@type > ast:class"`
Name string `json:"name" quad:"@id"`
StartLine int `json:"startLine" quad:"ast:start_line,optional"`
EndLine int `json:"endLine" quad:"ast:end_line,optional"`
File quad.IRI `json:"file" quad:"ast:file"`
Extends quad.IRI `json:"extends" quad:"ast:extends,optional"`
Implements []quad.IRI `json:"implements" quad:"ast:implements,optional"`
IsAbstract bool `json:"isAbstract" quad:"ast:is_abstract,optional"`
IsInterface bool `json:"isInterface" quad:"ast:is_interface,optional"`
}


type AstMethod struct {
rdfType struct{} `quad:"@type > ast:method"`
ID string `json:"id" quad:"@id"`
Expand All @@ -53,6 +52,7 @@ type AstMethod struct {
Calls []quad.IRI `json:"calls" quad:"ast:calls,optional"`
IsAbstract bool `json:"isAbstract" quad:"ast:is_abstract,optional"`
Implementations []quad.IRI `json:"implementations" quad:"ast:method_implementation,optional"`
Visibility string `json:"visibility" quad:"ast:method_visibility,optional"`
}

type AstProperty struct {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/shapes.uml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const uml = function (parent, bbox, node) {
.append("text")
.attr('data-method', '')
.text(function (d) {
return d.Name
return d.Visibility + ' ' + d.Name
})
.style("cursor", "pointer");

Expand Down

0 comments on commit 1bda221

Please sign in to comment.