Skip to content

Commit cffba7e

Browse files
yaohaizhfbricon
authored andcommitted
Hide java project setting files by default. (#776)
Signed-off-by: Yaohai Zheng <[email protected]>
1 parent ac332c6 commit cffba7e

File tree

7 files changed

+160
-57
lines changed

7 files changed

+160
-57
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Change Log
22

3-
## 0.38.0 (January 30th, 2019)
3+
## 0.38.0 (January 31st, 2019)
4+
* enhancement - new dialog asking to hide java project settings files on startup. See [#776](https://github.com/redhat-developer/vscode-java/pull/776).
45
* bug fix - pick up gradle properties updates when doing full build. See [#758](https://github.com/redhat-developer/vscode-java/issues/758).
56
* bug fix - fixed inactive autocompletion after inserting a snippet in some cases. See [#768](https://github.com/redhat-developer/vscode-java/issues/768).
67

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ The following settings are supported:
8080
* `java.import.gradle.enabled` : Enable/disable the Gradle importer.
8181
* `java.import.maven.enabled` : Enable/disable the Maven importer.
8282
* `java.autobuild.enabled` : Enable/disable the 'auto build'.
83+
* `java.maxConcurrentBuilds`: Set max simultaneous project builds.
8384
* `java.completion.favoriteStaticMembers` : Defines a list of static members or types with static members.
8485
* `java.completion.importOrder` : Defines the sorting order of import statements.
8586
* `java.progressReports.enabled` : [Experimental] Enable/disable progress reports from background processes on the server.
@@ -91,8 +92,8 @@ The following settings are supported:
9192
* `java.completion.guessMethodArguments` : When set to true, method arguments are guessed when a method is selected from as list of code assist proposals.
9293
* `java.completion.enabled` : Enable/disable code completion support.
9394

94-
*New in 0.36.0:*
95-
* `java.maxConcurrentBuilds`: Set max simultaneous project builds.
95+
*New in 0.38.0:*
96+
* `java.configuration.checkProjectSettingsExclusions`: Checks if the extension-generated project settings files (`.project`, `.classpath`, `.factorypath`, `.settings/`) should be excluded from the file explorer. Defaults to `true`.
9697

9798

9899
Troubleshooting

package-lock.json

Lines changed: 34 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@
8989
"description": "Specifies the severity of the message when the classpath is incomplete for a Java file",
9090
"scope": "window"
9191
},
92+
"java.configuration.checkProjectSettingsExclusions": {
93+
"type": "boolean",
94+
"default": true,
95+
"description": "Checks if the extension-generated project settings files (.project, .classpath, .factorypath, .settings/) should be excluded from the file explorer.",
96+
"scope": "window"
97+
},
9298
"java.configuration.updateBuildConfiguration": {
9399
"type": [
94100
"string"

src/extension.ts

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ SourceAttachmentRequest, SourceAttachmentResult, SourceAttachmentAttribute } fro
1414
import { ExtensionAPI } from './extension.api';
1515
import * as buildpath from './buildpath';
1616
import * as net from 'net';
17+
import { getJavaConfiguration } from './utils';
18+
import { onConfigurationChange, excludeProjectSettingsFiles } from './settings';
1719

18-
let oldConfig;
1920
let lastStatus;
2021
let languageClient: LanguageClient;
2122
let jdtEventEmitter = new EventEmitter<Uri>();
@@ -83,7 +84,6 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
8384
item.command = Commands.OPEN_OUTPUT;
8485
let progressBar = window.createStatusBarItem(StatusBarAlignment.Left, Number.MIN_VALUE+1);
8586

86-
oldConfig = getJavaConfiguration();
8787
let serverOptions;
8888
let port = process.env['SERVER_PORT'];
8989
if (!port) {
@@ -300,6 +300,7 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
300300
}
301301
};
302302
workspace.registerTextDocumentContentProvider('jdt', provider);
303+
excludeProjectSettingsFiles();
303304
});
304305

305306
let cleanWorkspaceExists = fs.existsSync( path.join(workspacePath, cleanWorkspaceFileName));
@@ -434,34 +435,6 @@ function isJavaConfigFile(path: String) {
434435
return path.endsWith('pom.xml') || path.endsWith('.gradle');
435436
}
436437

437-
function onConfigurationChange() {
438-
return workspace.onDidChangeConfiguration(params => {
439-
let newConfig = getJavaConfiguration();
440-
if (hasJavaConfigChanged(oldConfig, newConfig)) {
441-
let msg = 'Java Language Server configuration changed, please restart VS Code.';
442-
let action = 'Restart Now';
443-
let restartId = Commands.RELOAD_WINDOW;
444-
oldConfig = newConfig;
445-
window.showWarningMessage(msg, action).then((selection) => {
446-
if (action === selection) {
447-
commands.executeCommand(restartId);
448-
}
449-
});
450-
}
451-
});
452-
}
453-
454-
function hasJavaConfigChanged(oldConfig, newConfig) {
455-
return hasConfigKeyChanged('home', oldConfig, newConfig)
456-
|| hasConfigKeyChanged('jdt.ls.vmargs', oldConfig, newConfig)
457-
|| hasConfigKeyChanged('progressReports.enabled', oldConfig, newConfig);
458-
}
459-
460-
function hasConfigKeyChanged(key, oldConfig, newConfig) {
461-
return oldConfig.get(key) !== newConfig.get(key);
462-
}
463-
464-
465438
function getTempWorkspace() {
466439
return path.resolve(os.tmpdir(), 'vscodesws_' + makeRandomHexString(5));
467440
}
@@ -476,9 +449,6 @@ function makeRandomHexString(length) {
476449
return result;
477450
}
478451

479-
function getJavaConfiguration(): WorkspaceConfiguration {
480-
return workspace.getConfiguration('java');
481-
}
482452

483453
async function cleanWorkspace(workspacePath) {
484454
const doIt = 'Restart and delete';
@@ -745,4 +715,4 @@ function isPrefix(parentPath: string, childPath: string): boolean {
745715
}
746716
const relative = path.relative(parentPath, childPath);
747717
return !!relative && !relative.startsWith('..') && !path.isAbsolute(relative);
748-
}
718+
}

0 commit comments

Comments
 (0)