From 8be5eb30eec0f8b554afd38dc05b0d4208559d7f Mon Sep 17 00:00:00 2001 From: Roman Anasal Date: Thu, 11 Feb 2021 16:12:40 +0100 Subject: [PATCH 1/4] Fix return type of parser.getMemberContext With multiple matches but with none of them having isMethod getMemberContext would return the whole array instead of a single value or undefined causing errors in the calling code paths --- lib/services/php-file-parser.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/services/php-file-parser.coffee b/lib/services/php-file-parser.coffee index 8514375..a859818 100644 --- a/lib/services/php-file-parser.coffee +++ b/lib/services/php-file-parser.coffee @@ -710,8 +710,10 @@ module.exports = if value instanceof Array for val in value if val.isMethod - value = val + return val break + # return undefined if we didn't find a matching element + return return value From bc3f17cdecf3e292d369639515c38ddbe690ff39 Mon Sep 17 00:00:00 2001 From: Roman Anasal Date: Thu, 11 Feb 2021 21:25:57 +0100 Subject: [PATCH 2/4] Fix selectors for functions and method calls Changes made to the language-php syntax package rendered the used selectors broken. With this the selectors now match as intended again. --- lib/goto/function-provider.coffee | 4 ++-- lib/tooltip/function-provider.coffee | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/goto/function-provider.coffee b/lib/goto/function-provider.coffee index 2762076..03215ec 100644 --- a/lib/goto/function-provider.coffee +++ b/lib/goto/function-provider.coffee @@ -5,8 +5,8 @@ AbstractProvider = require './abstract-provider' module.exports = class FunctionProvider extends AbstractProvider - hoverEventSelectors: '.syntax--function-call' - clickEventSelectors: '.syntax--function-call' + hoverEventSelectors: '.syntax--function-call .syntax--function, .syntax--method-call .syntax--function' + clickEventSelectors: '.syntax--function-call .syntax--function, .syntax--method-call .syntax--function' gotoRegex: /(?:(?:[a-zA-Z0-9_]*)\s*(?:\(.*\))?\s*(?:->|::)\s*)+([a-zA-Z0-9_]*)/ ###* diff --git a/lib/tooltip/function-provider.coffee b/lib/tooltip/function-provider.coffee index d6aa89e..9ec7238 100644 --- a/lib/tooltip/function-provider.coffee +++ b/lib/tooltip/function-provider.coffee @@ -6,7 +6,7 @@ AbstractProvider = require './abstract-provider' module.exports = class FunctionProvider extends AbstractProvider - hoverEventSelectors: '.syntax--function-call' + hoverEventSelectors: '.syntax--function-call .syntax--function, .syntax--method-call .syntax--function' ###* * Retrieves a tooltip for the word given. From 1a3d51b7ce68711f1644d762ded3f061a2fe9828 Mon Sep 17 00:00:00 2001 From: Roman Anasal Date: Thu, 11 Feb 2021 21:37:03 +0100 Subject: [PATCH 3/4] Fix selectors for type hint classes Changes made to the language-php syntax package rendered the used selectors broken. With this the selectors now match as intended again. --- lib/goto/class-provider.coffee | 4 ++-- lib/tooltip/class-provider.coffee | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/goto/class-provider.coffee b/lib/goto/class-provider.coffee index f5d9aa2..00d5add 100644 --- a/lib/goto/class-provider.coffee +++ b/lib/goto/class-provider.coffee @@ -3,8 +3,8 @@ AbstractProvider = require './abstract-provider' module.exports = class ClassProvider extends AbstractProvider - hoverEventSelectors: '.syntax--entity.syntax--inherited-class, .syntax--support.syntax--namespace, .syntax--support.syntax--class, .syntax--comment-clickable .syntax--region' - clickEventSelectors: '.syntax--entity.syntax--inherited-class, .syntax--support.syntax--namespace, .syntax--support.syntax--class' + hoverEventSelectors: '.syntax--entity.syntax--inherited-class, .syntax--support.syntax--namespace, .syntax--support.syntax--class, .syntax--typehinted .syntax--type, .syntax--comment-clickable .syntax--region' + clickEventSelectors: '.syntax--entity.syntax--inherited-class, .syntax--support.syntax--namespace, .syntax--support.syntax--class, .syntax--typehinted .syntax--type' gotoRegex: /^\\?[A-Z][A-za-z0-9_]*(\\[A-Z][A-Za-z0-9_])*$/ ###* diff --git a/lib/tooltip/class-provider.coffee b/lib/tooltip/class-provider.coffee index 10a99f2..435efa7 100644 --- a/lib/tooltip/class-provider.coffee +++ b/lib/tooltip/class-provider.coffee @@ -6,7 +6,7 @@ AbstractProvider = require './abstract-provider' module.exports = class ClassProvider extends AbstractProvider - hoverEventSelectors: '.syntax--entity.syntax--inherited-class, .syntax--support.syntax--namespace, .syntax--support.syntax--class, .syntax--comment-clickable .syntax--region' + hoverEventSelectors: '.syntax--entity.syntax--inherited-class, .syntax--support.syntax--namespace, .syntax--support.syntax--class, .syntax--typehinted .syntax--type, .syntax--comment-clickable .syntax--region' ###* * Retrieves a tooltip for the word given. From 29549db5bc262955542f4f8479ac972aae0d9960 Mon Sep 17 00:00:00 2001 From: Roman Anasal Date: Thu, 11 Feb 2021 22:11:47 +0100 Subject: [PATCH 4/4] Fix selectors for class constants and distinguish from class methods Selectors were not matching class constants correctly. Also constants would be treated the same as methods although not having a declaringStructure but declaringClass instead. See also previous commits --- lib/goto/function-provider.coffee | 2 +- lib/goto/property-provider.coffee | 6 +++--- lib/services/php-file-parser.coffee | 2 +- lib/tooltip/property-provider.coffee | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/goto/function-provider.coffee b/lib/goto/function-provider.coffee index 03215ec..339984b 100644 --- a/lib/goto/function-provider.coffee +++ b/lib/goto/function-provider.coffee @@ -7,7 +7,7 @@ module.exports = class FunctionProvider extends AbstractProvider hoverEventSelectors: '.syntax--function-call .syntax--function, .syntax--method-call .syntax--function' clickEventSelectors: '.syntax--function-call .syntax--function, .syntax--method-call .syntax--function' - gotoRegex: /(?:(?:[a-zA-Z0-9_]*)\s*(?:\(.*\))?\s*(?:->|::)\s*)+([a-zA-Z0-9_]*)/ + gotoRegex: /(?:(?:[a-zA-Z0-9_]*)\s*(?:\(.*\))?\s*(?:->|::)\s*)+([a-zA-Z0-9_]*)\(/ ###* * Goto the class from the term given. diff --git a/lib/goto/property-provider.coffee b/lib/goto/property-provider.coffee index ccfbe66..b627b90 100644 --- a/lib/goto/property-provider.coffee +++ b/lib/goto/property-provider.coffee @@ -5,8 +5,8 @@ AbstractProvider = require './abstract-provider' module.exports = class PropertyProvider extends AbstractProvider - hoverEventSelectors: '.syntax--property' - clickEventSelectors: '.syntax--property' + hoverEventSelectors: '.syntax--property, .syntax--class.syntax--operator + .syntax--constant' + clickEventSelectors: '.syntax--property, .syntax--class.syntax--operator + .syntax--constant' gotoRegex: /^(\$\w+)?((->|::)\w+)+/ ###* @@ -34,7 +34,7 @@ class PropertyProvider extends AbstractProvider if not value return - atom.workspace.open(value.declaringStructure.filename, { + atom.workspace.open((value.declaringStructure || value.declaringClass).filename, { searchAllPanes: true }) diff --git a/lib/services/php-file-parser.coffee b/lib/services/php-file-parser.coffee index a859818..92a91d4 100644 --- a/lib/services/php-file-parser.coffee +++ b/lib/services/php-file-parser.coffee @@ -709,7 +709,7 @@ module.exports = # If there are multiple matches, just select the first method. if value instanceof Array for val in value - if val.isMethod + if val.isMethod || val.isStatic return val break # return undefined if we didn't find a matching element diff --git a/lib/tooltip/property-provider.coffee b/lib/tooltip/property-provider.coffee index 9c3226c..acd8dd4 100644 --- a/lib/tooltip/property-provider.coffee +++ b/lib/tooltip/property-provider.coffee @@ -5,7 +5,7 @@ AbstractProvider = require './abstract-provider' module.exports = class PropertyProvider extends AbstractProvider - hoverEventSelectors: '.syntax--property' + hoverEventSelectors: '.syntax--property, .syntax--class.syntax--operator + .syntax--constant' ###* * Retrieves a tooltip for the word given.