Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import * as path from 'path';
import * as os from 'os';
import * as fs from 'fs';
import { workspace, extensions, ExtensionContext, window, StatusBarAlignment, commands, ViewColumn, Uri, CancellationToken, TextDocumentContentProvider, WorkspaceConfiguration, languages, IndentAction, ProgressLocation, InputBoxOptions, Selection, Position, EventEmitter, OutputChannel, TextDocument } from 'vscode';
import { ExecuteCommandParams, ExecuteCommandRequest, LanguageClient, LanguageClientOptions, RevealOutputChannelOn, Position as LSPosition, Location as LSLocation, StreamInfo, VersionedTextDocumentIdentifier, ErrorHandler, Message, ErrorAction, CloseAction, InitializationFailedHandler, DidChangeConfigurationNotification } from 'vscode-languageclient';
import { workspace, extensions, ExtensionContext, window, StatusBarAlignment, commands, ViewColumn, Uri, CancellationToken, TextDocumentContentProvider, languages, IndentAction, ProgressLocation, InputBoxOptions, Selection, Position, EventEmitter, OutputChannel, TextDocument, RelativePattern } from 'vscode';
import { ExecuteCommandParams, ExecuteCommandRequest, LanguageClient, LanguageClientOptions, RevealOutputChannelOn, Position as LSPosition, Location as LSLocation, StreamInfo, ErrorHandler, Message, ErrorAction, CloseAction, DidChangeConfigurationNotification } from 'vscode-languageclient';
import { onExtensionChange, collectJavaExtensions } from './plugin';
import { prepareExecutable, awaitServerConnection } from './javaServerStarter';
import { getDocumentSymbolsCommand, getDocumentSymbolsProvider } from './documentSymbols';
Expand All @@ -22,7 +22,7 @@ import * as refactorAction from './refactorAction';
import * as pasteAction from './pasteAction';
import * as net from 'net';
import { getJavaConfiguration } from './utils';
import { onConfigurationChange, excludeProjectSettingsFiles, getKey, IS_WORKSPACE_JDK_ALLOWED } from './settings';
import { onConfigurationChange, excludeProjectSettingsFiles } from './settings';
import { logger, initializeLogFile } from './log';
import glob = require('glob');
import { SnippetCompletionProvider } from './snippetCompletionProvider';
Expand Down Expand Up @@ -172,14 +172,14 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
},
middleware: {
workspace: {
didChangeConfiguration: () => {
languageClient.sendNotification(DidChangeConfigurationNotification.type, {
settings: {
java: getJavaConfig(requirements.java_home),
}
});
onConfigurationChange(languageClient, context);
}
didChangeConfiguration: () => {
languageClient.sendNotification(DidChangeConfigurationNotification.type, {
settings: {
java: getJavaConfig(requirements.java_home),
}
});
onConfigurationChange(languageClient, context);
}
}
},
revealOutputChannelOn: RevealOutputChannelOn.Never,
Expand Down Expand Up @@ -444,7 +444,7 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
languageClient.start();
// Register commands here to make it available even when the language client fails

context.subscriptions.push(commands.registerCommand(Commands.OPEN_OUTPUT, () => languageClient.outputChannel.show(ViewColumn.Three)));
context.subscriptions.push(commands.registerCommand(Commands.OPEN_OUTPUT, () => languageClient.outputChannel.show(ViewColumn.Three)));

context.subscriptions.push(commands.registerCommand(Commands.OPEN_SERVER_LOG, (column: ViewColumn) => openServerLogFile(workspacePath, column)));

Expand Down Expand Up @@ -860,15 +860,17 @@ async function getTriggerFiles(): Promise<string[]> {
}
}

for (const javaFile of await workspace.findFiles("*.java", undefined, 1)) { // Find at most 1 java file
if (isPrefix(rootPath, javaFile.fsPath)) {
const javaFilesUnderRoot: Uri[] = await workspace.findFiles(new RelativePattern(rootFolder, "*.java"), undefined, 1);
for (const javaFile of javaFilesUnderRoot) {
if (isPrefix(rootPath, javaFile.fsPath)) {
openedJavaFiles.push(javaFile.toString());
return;
}
}

for (const javaFile of await workspace.findFiles("{src, test}/**/*.java", undefined, 1)) {
if (isPrefix(rootPath, javaFile.fsPath)) {
const javaFilesInCommonPlaces: Uri[] = await workspace.findFiles(new RelativePattern(rootFolder, "{src, test}/**/*.java"), undefined, 1);
for (const javaFile of javaFilesInCommonPlaces) {
if (isPrefix(rootPath, javaFile.fsPath)) {
openedJavaFiles.push(javaFile.toString());
return;
}
Expand Down