Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #397 from apiaryio/klokane/fix-386
Browse files Browse the repository at this point in the history
no sourcemap for references Fix #386
  • Loading branch information
pksunkara authored Sep 29, 2016
2 parents 483fc99 + 295f957 commit 0dee552
Show file tree
Hide file tree
Showing 23 changed files with 952 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Master

* Add missing sourcemaps for named type references
[#386](https://github.com/apiaryio/drafter/issues/386)

* Warn user on "action" with non-absolute path
[#350](https://github.com/apiaryio/drafter/issues/350)

Expand Down
2 changes: 1 addition & 1 deletion ext/snowcrash
11 changes: 11 additions & 0 deletions features/fixtures/ast.sourcemap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1098,3 +1098,14 @@ warnings:
-
index: 992
length: 45
-
code: 4
message: "invalid value format for 'number' type. please check mson specification for valid format"
location:
-
index: 200
length: 102
-
code: 4
message: "invalid value format for 'number' type. please check mson specification for valid format"
location: []
28 changes: 27 additions & 1 deletion features/fixtures/refract.sourcemap.json
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,19 @@
"content": "<resource name>"
}
},
"attributes": {
"sourceMap": [
{
"element": "sourceMap",
"content": [
[
173,
20
]
]
}
]
},
"content": [
{
"element": "member",
Expand Down Expand Up @@ -1768,7 +1781,20 @@
"element": "dataStructure",
"content": [
{
"element": "<data structure name>"
"element": "<data structure name>",
"attributes": {
"sourceMap": [
{
"element": "sourceMap",
"content": [
[
1518,
35
]
]
}
]
}
}
]
},
Expand Down
32 changes: 32 additions & 0 deletions features/fixtures/refract.sourcemap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ content:
- 104
- 43
content: "<resource name>"
attributes:
sourceMap:
-
element: "sourceMap"
content:
-
- 173
- 20
content:
-
element: "member"
Expand Down Expand Up @@ -1142,6 +1150,14 @@ content:
content:
-
element: "<data structure name>"
attributes:
sourceMap:
-
element: "sourceMap"
content:
-
- 1518
- 35
-
element: "asset"
meta:
Expand Down Expand Up @@ -1250,3 +1266,19 @@ content:
- 992
- 45
content: "the 'headers' section at this level is deprecated and will be removed in a future, use respective payload header section(s) instead"
-
element: "annotation"
meta:
classes:
- "warning"
attributes:
code: 4
sourceMap:
-
element: "sourceMap"
content:
-
- 200
- 102
content: "invalid value format for 'number' type. please check mson specification for valid format"

3 changes: 3 additions & 0 deletions src/RefractDataStructure.cc
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ namespace drafter {
}

SetElementType(element, value.node->valueDefinition.typeDefinition);
AttachSourceMap(element, MakeNodeInfo(value.node, value.sourceMap));

NodeInfoCollection<mson::TypeSections> typeSections(MAKE_NODE_INFO(value, sections));

Expand Down Expand Up @@ -1096,6 +1097,8 @@ namespace drafter {
element->meta[SerializeKey::Id] = PrimitiveToRefract(MakeNodeInfo(ds.node->name.symbol.literal, sourceMap));
}

AttachSourceMap(element, MakeNodeInfo(ds.node, ds.sourceMap));

// there is no source map for attributes
if (refract::IElement* attributes = MsonTypeAttributesToRefract(ds.node->typeDefinition.attributes)) {
element->attributes[SerializeKey::TypeAttributes] = attributes;
Expand Down
13 changes: 13 additions & 0 deletions test/fixtures/api/action-attributes.sourcemap.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@
"content": [
{
"element": "object",
"attributes": {
"sourceMap": [
{
"element": "sourceMap",
"content": [
[
73,
11
]
]
}
]
},
"content": [
{
"element": "member",
Expand Down
13 changes: 13 additions & 0 deletions test/fixtures/api/action-request-attributes.sourcemap.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@
"content": [
{
"element": "object",
"attributes": {
"sourceMap": [
{
"element": "sourceMap",
"content": [
[
71,
11
]
]
}
]
},
"content": [
{
"element": "member",
Expand Down
13 changes: 13 additions & 0 deletions test/fixtures/api/asset.sourcemap.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,19 @@
"content": [
{
"element": "object",
"attributes": {
"sourceMap": [
{
"element": "sourceMap",
"content": [
[
111,
11
]
]
}
]
},
"content": [
{
"element": "member",
Expand Down
28 changes: 27 additions & 1 deletion test/fixtures/api/attributes-references.sourcemap.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,19 @@
"content": [
{
"element": "object",
"attributes": {
"sourceMap": [
{
"element": "sourceMap",
"content": [
[
111,
11
]
]
}
]
},
"content": [
{
"element": "member",
Expand All @@ -231,7 +244,20 @@
"content": "user"
},
"value": {
"element": "User"
"element": "User",
"attributes": {
"sourceMap": [
{
"element": "sourceMap",
"content": [
[
132,
12
]
]
}
]
}
}
}
}
Expand Down
30 changes: 28 additions & 2 deletions test/fixtures/api/data-structure.sourcemap.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,20 @@
"content": "id"
},
"value": {
"element": "number"
"element": "number",
"attributes": {
"sourceMap": [
{
"element": "sourceMap",
"content": [
[
50,
12
]
]
}
]
}
}
}
},
Expand Down Expand Up @@ -108,7 +121,20 @@
"content": "username"
},
"value": {
"element": "string"
"element": "string",
"attributes": {
"sourceMap": [
{
"element": "sourceMap",
"content": [
[
64,
32
]
]
}
]
}
}
}
}
Expand Down
21 changes: 21 additions & 0 deletions test/fixtures/api/issue-386.apib
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# GET /

+ Response 200
+ Attributes
+ a (A)

+ Response 201
+ Attributes (A)

+ Response 202
+ Attributes
+ (A)

+ Response 203
+ Attributes (array)
+ (A)


## Data Structures
### A
description
Loading

0 comments on commit 0dee552

Please sign in to comment.