import { isJavaIdentifier , isKeyword } from "../utility" ; import { DataNode } from "../views/dataNode" ; import { ExplorerNode } from "../views/explorerNode" ; export function isMutable ( node ) { const packageExp = /java:(package|packageRoot)(?=.*?\b\+(source|resource)\b)(?=.*?\b\+uri\b)/ ; const resourceOrTypeExp = /java:(file|type|folder)(?=.*?\b\+uri\b)/ ; const contextValue = node . computeContextValue ( ) ; if ( ! contextValue ) { return false ; } return packageExp . test ( contextValue ) || resourceOrTypeExp . test ( contextValue ) ; } export function checkJavaQualifiedName ( value ) { if ( ! value || ! value . trim ( ) ) { return "Input cannot be empty." ; } for ( const part of value . split ( "." ) ) { if ( isKeyword ( part ) ) { return `Keyword '${ part }' cannot be used.` ; } if ( ! isJavaIdentifier ( part ) ) { return `Invalid Java qualified name.` ; } } return "" ; } export function getCmdNode ( selectedNodes , node ? ) { if ( node ) { return node ; } if ( selectedNodes . length > 0 ) { return selectedNodes [ 0 ] as DataNode ; } return undefined ; }