-
Notifications
You must be signed in to change notification settings - Fork 456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide java project setting files by default. #776
Changes from 1 commit
33d26eb
60c5e2f
7cb7c9b
bb3c18c
c7c94a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,12 @@ | |
"description": "Specifies the severity of the message when the classpath is incomplete for a Java file", | ||
"scope": "window" | ||
}, | ||
"java.configuration.excludeProjectSettingFiles": { | ||
"type": "boolean", | ||
"default": true, | ||
"description": "Exclude the extension generated project setting files from file explorer.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. settings from the file explorer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to explain setting it to false won't remove the exclusions |
||
"scope": "window" | ||
}, | ||
"java.configuration.updateBuildConfiguration": { | ||
"type": [ | ||
"string" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. settings.ts |
||
|
||
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']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HIDDEN |
||
|
||
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. excludeProjectSettingsFiles |
||
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); | ||
} |
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'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hideProjectSettingsFiles