@@ -10,6 +10,7 @@ import { Commands } from "../../extension.bundle";
1010import { ExtensionName } from "../constants" ;
1111import { NodeKind } from "../java/nodeData" ;
1212import { DataNode } from "../views/dataNode" ;
13+ import { resourceRoots } from "../views/packageRootNode" ;
1314import { checkJavaQualifiedName } from "./utility" ;
1415
1516export async function newJavaClass ( node ?: DataNode ) : Promise < void > {
@@ -35,7 +36,7 @@ export async function newJavaClass(node?: DataNode): Promise<void> {
3536 // User canceled
3637 return ;
3738 } else if ( packageFsPath . length === 0 ) {
38- return newUntiledJavaFile ( ) ;
39+ return newUntitledJavaFile ( ) ;
3940 }
4041
4142 const className : string | undefined = await window . showInputBox ( {
@@ -67,7 +68,7 @@ export async function newJavaClass(node?: DataNode): Promise<void> {
6768 workspace . applyEdit ( workspaceEdit ) ;
6869}
6970
70- async function newUntiledJavaFile ( ) : Promise < void > {
71+ async function newUntitledJavaFile ( ) : Promise < void > {
7172 await commands . executeCommand ( "workbench.action.files.newUntitledFile" ) ;
7273 const textEditor : TextEditor | undefined = window . activeTextEditor ;
7374 if ( ! textEditor ) {
@@ -147,7 +148,7 @@ async function getPackageFsPath(node: DataNode): Promise<string | undefined> {
147148 if ( node . nodeData . kind === NodeKind . Project ) {
148149 const childrenNodes : DataNode [ ] = await node . getChildren ( ) as DataNode [ ] ;
149150 const packageRoots : any [ ] = childrenNodes . filter ( ( child ) => {
150- return child . nodeData . kind === NodeKind . PackageRoot ;
151+ return child . nodeData . kind === NodeKind . PackageRoot && ! resourceRoots . includes ( child . name ) ;
151152 } ) ;
152153 if ( packageRoots . length < 1 ) {
153154 // This might happen for an invisible project with "_" as its root
0 commit comments