/** * Selected nodes in <code>context</code> under <code>selection</code> or null if no valid * selection. * * @param context The context in which the proposal is applied. * @return Selected nodes or null if no valid selection. * @throws CoreException if the analyzer cannot be created */ public static ASTNode[] getValidSelectedNodes(IInvocationContext context) throws CoreException { Selection selection= Selection.createFromStartLength(context.getSelectionOffset(), context.getSelectionLength()); SurroundWithAnalyzer analyzer= new SurroundWithAnalyzer(context.getCompilationUnit(), selection, false); context.getASTRoot().accept(analyzer); if (!analyzer.getStatus().isOK() || !analyzer.hasSelectedNodes()) { return null; } else { return analyzer.getValidSelectedNodes(); } }