@@ -10,6 +10,7 @@ import { Commands } from "../../extension.bundle";
10
10
import { ExtensionName } from "../constants" ;
11
11
import { NodeKind } from "../java/nodeData" ;
12
12
import { DataNode } from "../views/dataNode" ;
13
+ import { resourceRoots } from "../views/packageRootNode" ;
13
14
import { checkJavaQualifiedName } from "./utility" ;
14
15
15
16
export async function newJavaClass ( node ?: DataNode ) : Promise < void > {
@@ -35,7 +36,7 @@ export async function newJavaClass(node?: DataNode): Promise<void> {
35
36
// User canceled
36
37
return ;
37
38
} else if ( packageFsPath . length === 0 ) {
38
- return newUntiledJavaFile ( ) ;
39
+ return newUntitledJavaFile ( ) ;
39
40
}
40
41
41
42
const className : string | undefined = await window . showInputBox ( {
@@ -67,7 +68,7 @@ export async function newJavaClass(node?: DataNode): Promise<void> {
67
68
workspace . applyEdit ( workspaceEdit ) ;
68
69
}
69
70
70
- async function newUntiledJavaFile ( ) : Promise < void > {
71
+ async function newUntitledJavaFile ( ) : Promise < void > {
71
72
await commands . executeCommand ( "workbench.action.files.newUntitledFile" ) ;
72
73
const textEditor : TextEditor | undefined = window . activeTextEditor ;
73
74
if ( ! textEditor ) {
@@ -147,7 +148,7 @@ async function getPackageFsPath(node: DataNode): Promise<string | undefined> {
147
148
if ( node . nodeData . kind === NodeKind . Project ) {
148
149
const childrenNodes : DataNode [ ] = await node . getChildren ( ) as DataNode [ ] ;
149
150
const packageRoots : any [ ] = childrenNodes . filter ( ( child ) => {
150
- return child . nodeData . kind === NodeKind . PackageRoot ;
151
+ return child . nodeData . kind === NodeKind . PackageRoot && ! resourceRoots . includes ( child . name ) ;
151
152
} ) ;
152
153
if ( packageRoots . length < 1 ) {
153
154
// This might happen for an invisible project with "_" as its root
0 commit comments