-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hide java project setting files by default.
Signed-off-by: Yaohai Zheng <[email protected]>
- Loading branch information
Showing
4 changed files
with
74 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
|
||
import { window, Uri, workspace, WorkspaceConfiguration, commands } from 'vscode'; | ||
import { LanguageClient } from 'vscode-languageclient'; | ||
import { Commands } from './commands'; | ||
import { getJavaConfiguration } from './utils'; | ||
|
||
|
||
const DEFAULT_HIIDEN_FILES: string[] = ['**/.classpath', '**/.project', '**/.settings']; | ||
|
||
let oldConfig = getJavaConfiguration(); | ||
|
||
export function onConfigurationChange() { | ||
return workspace.onDidChangeConfiguration(params => { | ||
let newConfig = getJavaConfiguration(); | ||
if (hasJavaConfigChanged(oldConfig, newConfig)) { | ||
let msg = 'Java Language Server configuration changed, please restart VS Code.'; | ||
let action = 'Restart Now'; | ||
let restartId = Commands.RELOAD_WINDOW; | ||
oldConfig = newConfig; | ||
window.showWarningMessage(msg, action).then((selection) => { | ||
if (action === selection) { | ||
commands.executeCommand(restartId); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
export function excludeProjectSettingFiles(workspaceUri: Uri) { | ||
if (getJavaConfiguration().get<Boolean>('configuration.excludeProjectSettingFiles')) { | ||
const config = workspace.getConfiguration('files', workspaceUri); | ||
const excludeValue: Object = config.get('exclude'); | ||
|
||
for (const hiddenFiles of DEFAULT_HIIDEN_FILES) { | ||
if (!excludeValue.hasOwnProperty(hiddenFiles)) { | ||
excludeValue[hiddenFiles] = true; | ||
} | ||
|
||
} | ||
config.update('exclude', excludeValue); | ||
} | ||
} | ||
|
||
function hasJavaConfigChanged(oldConfig, newConfig) { | ||
return hasConfigKeyChanged('home', oldConfig, newConfig) | ||
|| hasConfigKeyChanged('jdt.ls.vmargs', oldConfig, newConfig) | ||
|| hasConfigKeyChanged('progressReports.enabled', oldConfig, newConfig); | ||
} | ||
|
||
function hasConfigKeyChanged(key, oldConfig, newConfig) { | ||
return oldConfig.get(key) !== newConfig.get(key); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
import { workspace, WorkspaceConfiguration } from 'vscode'; | ||
|
||
export function getJavaConfiguration(): WorkspaceConfiguration { | ||
return workspace.getConfiguration('java'); | ||
} |