Skip to content

Commit

Permalink
Recognize custom file extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
snjeza committed Aug 1, 2024
1 parent ba61599 commit 0373204
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export async function activate(context: ExtensionContext): Promise<ExtensionAPI>
{ scheme: 'untitled', language: 'java' }
],
synchronize: {
configurationSection: ['java', 'editor.insertSpaces', 'editor.tabSize'],
configurationSection: ['java', 'editor.insertSpaces', 'editor.tabSize', "files.associations"],
},
initializationOptions: {
bundles: collectJavaExtensions(extensions.all),
Expand Down Expand Up @@ -1061,7 +1061,7 @@ async function getTriggerFiles(): Promise<string[]> {
function getJavaFilePathOfTextDocument(document: TextDocument): string | undefined {
if (document) {
const resource = document.uri;
if (resource.scheme === 'file' && resource.fsPath.endsWith('.java')) {
if (resource.scheme === 'file' && document.languageId === "java") {
return path.normalize(resource.fsPath);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/pasteAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export async function registerOrganizeImportsOnPasteCommand(): Promise<void> {
});

action.then((wasApplied) => {
const fileURI = editor.document.uri.toString();
if (wasApplied && fileURI.endsWith(".java")) {
if (wasApplied && editor.document.languageId === "java") {
const fileURI = editor.document.uri.toString();
const hasText: boolean = documentText !== null && /\S/.test(documentText);
if (hasText) {
// Organize imports silently to avoid surprising the user
Expand Down
2 changes: 2 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ export async function getJavaConfig(javaHome: string) {
const editorConfig = workspace.getConfiguration('editor');
javaConfig.format.insertSpaces = editorConfig.get('insertSpaces');
javaConfig.format.tabSize = editorConfig.get('tabSize');
const filesConfig = workspace.getConfiguration('files');
javaConfig.associations = filesConfig.get('associations');
const isInsider: boolean = version.includes("insider");
const androidSupport = javaConfig.jdt.ls.androidSupport.enabled;
switch (androidSupport) {
Expand Down

0 comments on commit 0373204

Please sign in to comment.