Skip to content

Commit f1d6ca7

Browse files
authored
feat: Process facets to property presentation hints (#655)
* Process facets on dbgp property. Translate some facets to DAP property presentation hint visibility, attributes... * Process the virtual facet. [skip actions]
1 parent b312081 commit f1d6ca7

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/phpDebug.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,11 +861,33 @@ class PhpDebugSession extends vscode.DebugSession {
861861
} else {
862862
evaluateName = property.name
863863
}
864+
let presentationHint: VSCodeDebugProtocol.VariablePresentationHint = {}
865+
if (property.facets?.length) {
866+
if (property.facets.includes('public')) {
867+
presentationHint.visibility = 'public'
868+
} else if (property.facets.includes('private')) {
869+
presentationHint.visibility = 'private'
870+
} else if (property.facets.includes('protected')) {
871+
presentationHint.visibility = 'protected'
872+
}
873+
if (property.facets.includes('readonly')) {
874+
presentationHint.attributes = presentationHint.attributes || []
875+
presentationHint.attributes.push('readOnly')
876+
}
877+
if (property.facets.includes('static')) {
878+
presentationHint.attributes = presentationHint.attributes || []
879+
presentationHint.attributes.push('static')
880+
}
881+
if (property.facets.includes('virtual')) {
882+
presentationHint.kind = 'virtual'
883+
}
884+
}
864885
const variable: VSCodeDebugProtocol.Variable = {
865886
name: property.name,
866887
value: displayValue,
867888
type: property.type,
868889
variablesReference,
890+
presentationHint,
869891
evaluateName,
870892
}
871893
return variable

src/xdebugConnection.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,8 @@ export abstract class BaseProperty {
482482
value: string
483483
/** children that were already included in the response */
484484
children: BaseProperty[]
485+
/** provided facets */
486+
facets: ('public' | 'private' | 'protected' | 'static' | 'readonly' | string)[]
485487

486488
constructor(propertyNode: Element) {
487489
if (propertyNode.hasAttribute('name')) {
@@ -495,6 +497,9 @@ export abstract class BaseProperty {
495497
} else if (propertyNode.getElementsByTagName('classname').length > 0) {
496498
this.class = decodeTag(propertyNode, 'classname')
497499
}
500+
if (propertyNode.hasAttribute('facet')) {
501+
this.facets = propertyNode.getAttribute('facet')!.split(' ')
502+
}
498503
this.hasChildren = !!parseInt(propertyNode.getAttribute('children')!)
499504
if (this.hasChildren) {
500505
this.numberOfChildren = parseInt(propertyNode.getAttribute('numchildren')!)

0 commit comments

Comments
 (0)