OpenLiberty / liberty-language-server

The Liberty Config Language Server provides language server features for Liberty server configuration files through any of the supported client IDEs.
Eclipse Public License 2.0
5 stars 11 forks source link

On Windows, server XML config files not detected even in specifically targeted directories #152

Closed scottkurz closed 1 year ago

scottkurz commented 1 year ago

RECREATE

  1. Install Liberty Tools Eclipse https://public.dhe.ibm.com/ibmdl/export/pub/software/openliberty/liberty-tools-eclipse/0.7.0/repository/
  2. Create a file src/main/liberty/config/configDropins/defaults/my.xml
  3. Open my.xml in the Generic Text Editor
  4. Try to do Ctrl+Space completion and notice it doesn't provide Liberty server XSD aware answers, and/or you get a CodeLens-style prompt

EXPLANATION

The LibertyUtils method

    public static boolean isConfigDirFile(String filePath) {
        return filePath.contains(LibertyConstants.WLP_USER_CONFIG_DIR) ||
                filePath.contains(LibertyConstants.SERVER_CONFIG_DROPINS_DEFAULTS) ||
                filePath.contains(LibertyConstants.SERVER_CONFIG_DROPINS_OVERRIDES);
    }

uses constants like: public static final String SERVER_CONFIG_DROPINS_DEFAULTS = File.separator + String.join(File.separator, "configDropins", "defaults") + File.separator;

However, the file path is coming via other lsp layers from a file type URI/URL. This uses forward-slash ('/') separators even on Windows. I don't have a definitive reference but looking in the debugger this seems to clearly be the issue.

So the backslash in the comparison string is causing the 'contains' test to return 'false'.

cherylking commented 1 year ago

@dshimo This can be closed right? The fix went in on PR 153.