private ASTSubroutineArgNode getActualArgFromCallStmt( ASTCallStmtNode callStmt, Token desiredParName, int desiredParIndex) { for (int i = 0; i < callStmt.getArgList().size(); i++) { ASTSubroutineArgNode argument = callStmt.getArgList().get(i); if (argument.getName() == null || desiredParName == null) { if (i == desiredParIndex) return argument; } else { String argumentName = PhotranVPG.canonicalizeIdentifier(argument.getName().getText()); String parameterName = PhotranVPG.canonicalizeIdentifier(desiredParName.getText()); if (argumentName.equals(parameterName)) return argument; } } return null; }
protected static Token findEnclosingToken(IFortranAST ast, final ITextSelection selection) { Token prevToken = null; for (Token token : new IterableWrapper<Token>(ast)) { if (OffsetLength.contains( token.getFileOffset(), token.getLength(), selection.getOffset(), selection.getLength())) { String tokenText = token.getText(); // If we get whitespace, that means we want the previous token (cursor was put AFTER // the identifier we want to rename if (tokenText.length() == 1 && Character.isWhitespace(tokenText.charAt(0))) { return prevToken; } else return token; } prevToken = token; } return null; }
protected static String describeToken(Token token) { return "\"" + token.getText() + "\" " + describeTokenPos(token); // $NON-NLS-1$ //$NON-NLS-2$ }