Switch language level to JSX Harmony? Related to inability to find usages in .js files?

Answered

I'm in an old .js file (previous developers) and PHPStorm 10 has a yellow drop-down at the top that says "Switch language level to JSX Harmony", but I'm not finding much info on this except some old posts that it's not really supported anymore.

We're not using JSX Harmony at all that I'm aware of, and I'm not sure if this is related but PHPStorm is not able to find function definitions or usages even in the same file if the function is defined inside of an object.

Example file: bob.js

Bob.General = {
    getAgentName : function(agentID) {
        // do database thing
        return fetchedAgentName;
    },

    getAgentID : function(agentName) {
        // do database thing
        return fetchedAgentID;
    }
}

If I hover over the function call (Bob.General.getAgentName(agentID)) a yellow pop-up says "Unresolved function or method getAgentName()"; if I Ctrl+click it, a red pop-up says "Cannot find declaration to go to"; if I right-click it and select Find Usages, a red pop-up says "Cannot search for usages. Position an element to find usages for , and try again" (the "find usages for ," is empty before the comma, and I'm not even sure what that "Position an element" error even means). This is even if the function is defined in the same file as it's used.

If I do a right-click 'Find in Path' from the top-level Project folder, the function comes up and shows me both which file/line the function is defined and files/lines where it's called everywhere. If I go to the function definition and hover over it, it says "Unnecessary label getAgentName". If I Ctrl+click it, it says "No usages found in Project Files". If I right-click Find Usages, it pops up a green box at the bottom right in the Find tab that says "No usages found in Project Files".

What is going on? PHPStorm 10 is pretty useless with Javascript functions at this point, but it was fine from what I remember in PHPStorm 8. Did I forget to configure something (I imported settings from 8 and it obliterated most of them)?

2 comments
Comment actions Permalink

Bob.General.getAgentID() is correctly resolved to me using similar code; prompts to switch to a different
language level mean that PHPStorm has found some constructions in your code that look like JSX.
Please try invalidating caches - do your problems persist? if yes, please provide a sample project that shows them up

0
Comment actions Permalink

Alright, I discovered a line of old-school PHP (<?= whatever ?>) in the code, I didn't notice right away because there's so many red lines on the right-side bar from what PHPStorm is extraneous commas after function blocks even though they work fine, maybe that's just caused by the PHP code in there, but yah, whoever coded this went against like every standard.

0

Please sign in to leave a comment.