forked from eclipse-wildwebdeveloper/wildwebdeveloper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSSLanguageClient.java
More file actions
67 lines (62 loc) · 2.95 KB
/
CSSLanguageClient.java
File metadata and controls
67 lines (62 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*******************************************************************************
* Copyright (c) 2022, 2026 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Angelo ZERR (Red Hat Inc.) - initial implementation
*******************************************************************************/
package org.eclipse.wildwebdeveloper.css;
import static org.eclipse.wildwebdeveloper.css.ui.preferences.CSSPreferenceServerConstants.isMatchCssSection;
import static org.eclipse.wildwebdeveloper.css.ui.preferences.less.LESSPreferenceServerConstants.isMatchLessSection;
import static org.eclipse.wildwebdeveloper.css.ui.preferences.scss.SCSSPreferenceServerConstants.isMatchScssSection;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.eclipse.lsp4e.client.DefaultLanguageClient;
import org.eclipse.lsp4j.ConfigurationItem;
import org.eclipse.lsp4j.ConfigurationParams;
import org.eclipse.wildwebdeveloper.css.ui.preferences.CSSPreferenceServerConstants;
import org.eclipse.wildwebdeveloper.css.ui.preferences.less.LESSPreferenceServerConstants;
import org.eclipse.wildwebdeveloper.css.ui.preferences.scss.SCSSPreferenceServerConstants;
import org.eclipse.wildwebdeveloper.ui.preferences.Settings;
/**
* CSS language client implementation.
*
*/
public class CSSLanguageClient extends DefaultLanguageClient {
@Override
public CompletableFuture<List<Object>> configuration(ConfigurationParams params) {
return CompletableFuture.supplyAsync(() -> {
// The CSS language server asks for a given uri, the settings for 'css',
// 'less', 'scss'
// See
// https://github.com/microsoft/vscode/blob/7bd27b4287b49e61a1cb49e18f370260144c8685/extensions/css-language-features/server/src/cssServer.ts#L156
List<Object> settings = new ArrayList<>();
for (ConfigurationItem item : params.getItems()) {
String section = item.getSection();
if (isMatchCssSection(section)) {
// 'css' section, returns the css settings
Settings cssSettings = CSSPreferenceServerConstants.getGlobalSettings();
settings.add(cssSettings.findSettings(section.split("[.]")));
} else if (isMatchLessSection(section)) {
// 'less' section, returns the less settings
Settings cssSettings = LESSPreferenceServerConstants.getGlobalSettings();
settings.add(cssSettings.findSettings(section.split("[.]")));
} else if (isMatchScssSection(section)) {
// 'scss' section, returns the scss settings
Settings cssSettings = SCSSPreferenceServerConstants.getGlobalSettings();
settings.add(cssSettings.findSettings(section.split("[.]")));
} else {
// Unkwown section
settings.add(null);
}
}
return settings;
});
}
}