-
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
33d26eb
Hide java project setting files by default.
yaohaizh 60c5e2f
Improve UX for changing settings.
yaohaizh 7cb7c9b
Resolve review feedback.
bb3c18c
Merge branch 'master' of https://github.com/redhat-developer/vscode-j…
yaohaizh c7c94a5
Refine change behavior.
yaohaizh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,69 @@ | ||
'use strict'; | ||
|
||
import { window, Uri, workspace, WorkspaceConfiguration, commands, ConfigurationTarget } from 'vscode'; | ||
import { LanguageClient } from 'vscode-languageclient'; | ||
import { Commands } from './commands'; | ||
import { getJavaConfiguration } from './utils'; | ||
|
||
|
||
const DEFAULT_HIDDEN_FILES: string[] = ['**/.classpath', '**/.project', '**/.settings']; | ||
|
||
let oldConfig: WorkspaceConfiguration = getJavaConfiguration(); | ||
|
||
export function onConfigurationChange() { | ||
return workspace.onDidChangeConfiguration(params => { | ||
if (!params.affectsConfiguration('java')) { | ||
return; | ||
} | ||
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 excludeProjectSettingsFiles(workspaceUri: Uri) { | ||
const excudedConfig = getJavaConfiguration().get('configuration.excludeProjectSettingsFiles'); | ||
if (excudedConfig) { | ||
const config = workspace.getConfiguration('files', workspaceUri); | ||
const excludedValue: Object = config.get('exclude'); | ||
const needExcludeFiles: Object = {}; | ||
|
||
let needUpdate = false; | ||
for (const hiddenFiles of DEFAULT_HIDDEN_FILES) { | ||
if (!excludedValue.hasOwnProperty(hiddenFiles)) { | ||
needExcludeFiles[hiddenFiles] = true; | ||
needUpdate = true; | ||
} | ||
} | ||
if (needUpdate) { | ||
window.showInformationMessage('Do you want to exclude the VSCode Java project settings files(.classpath, .project. .settings) from the file explorer.', 'Always', 'Workspace', 'Never').then((result) => { | ||
if (result === 'Always') { | ||
config.update('exclude', needExcludeFiles, ConfigurationTarget.Global); | ||
} if (result === 'Workspace') { | ||
config.update('exclude', needExcludeFiles, ConfigurationTarget.Workspace); | ||
} else if (result === 'Never') { | ||
getJavaConfiguration().update('configuration.excludeProjectSettingsFiles', false, ConfigurationTarget.Global); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
|
||
function hasJavaConfigChanged(oldConfig: WorkspaceConfiguration, newConfig: WorkspaceConfiguration) { | ||
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'); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
settings.ts