/** * Call back method that must be called when the given <code> * FormalParameterDeclaration</code> will become the next <i>traverse * candidate</i>. * * @param pFormalParameterDeclaration The <code>FormalParameterDeclaration * </code> object that will become the * next <i>traverse candidate</i>. */ public void performAction( FormalParameterDeclaration pFormalParameterDeclaration) { // Nothing to do. }
/** * Call back method that must be called as soon as the given <code> * FormalParameterDeclaration</code> object has been traversed. * * @param pFormalParameterDeclaration The <code>FormalParameterDeclaration * </code> object that has just been * traversed. */ public void actionPerformed( FormalParameterDeclaration pFormalParameterDeclaration) { // Nothing to do. }
/** * Replaces a certain parameter declaration by a new one stated as string. * * @param pOldParameterDeclaration The parameter declaration that should be * replaced. * @param pNewParameterDeclaration The new parameter declaration. * * @ if the stated old parameter doesn't * exist or if parsing the new parameter * declaration fails. * __TEST__ */ public void replaceFormalParameter( FormalParameterDeclaration pOldParameterDeclaration, String pNewParameterDeclaration) { // Because it's not clear if the stated new formal parameter states a // standard parameter or a VarArg parameter simulate a parameter list // containing just one parameter. StringBuilder sb = new StringBuilder(); sb.Append('(').Append(pNewParameterDeclaration).Append(')'); List<String> errorMessages = new List<String>(); AST2FormalParameterDeclaration newParamDecl = null; try { AST2FormalParameterList paramList = getUnmarshaller().unmarshalAST2FormalParameterList( sb.ToString(), errorMessages); // TODO After implementation of adding JSOMs to JSOMs: // Check if error messages have been emitted by the parser. if (paramList != null) { paramList.resolveFormalParameterDeclarations(); if (paramList.mParams != null && paramList.mParams.Count == 1) { newParamDecl = paramList.mParams[0]; } } } catch (JSourceUnmarshallerException jsue) { // TODO After implementation of adding JSOMs to JSOMs: // Replace message by an internationalized message. throw new JSourceObjectizerException( "Parsing the formal parameter '" + pNewParameterDeclaration + "' failed.", jsue); } if (newParamDecl != null) { List<FormalParameterDeclaration> formalParamDecls = getFormalParameterDeclarations(); int offset = -1; if (formalParamDecls != null) { offset = mParams.IndexOf((AST2FormalParameterDeclaration)pOldParameterDeclaration); } if (offset >= 0) { AST2FormalParameterDeclaration oldParamDecl = mParams[offset]; mParams[offset] = newParamDecl; getTreeNode().SetChild(offset, newParamDecl.getTreeNode()); ITree oldParamDeclTree = oldParamDecl.getTreeNode(); getTokenRewriteStream().Replace( oldParamDeclTree.TokenStartIndex, oldParamDeclTree.TokenStopIndex, pNewParameterDeclaration); } else { // TODO After implementation of adding JSOMs to JSOMs: // Replace message by an internationalized message. throw new JSourceObjectizerException( "The old parameter '" + pOldParameterDeclaration.getMarshaller().ToString() + "' passed as argument doesn't belong to the " + "parameter list."); } } else { // TODO After implementation of adding JSOMs to JSOMs: // Replace message by an internationalized message. throw new JSourceObjectizerException( "Unmarshalling the new formal parameter '" + pNewParameterDeclaration + "' failed."); } }