edu.cmu.cs.crystal.util
Class Utilities

java.lang.Object
  extended by edu.cmu.cs.crystal.util.Utilities

public class Utilities
extends Object

Assorted utility methods

Author:
David Dickey, Nels Beckman

Constructor Summary
Utilities()
           
 
Method Summary
static String ASTNodeToString(ASTNode node)
          Takes an ASTNode and creates a more useful textual representation of it.
static MethodDeclaration getMethodDeclaration(ASTNode node)
          Finds the method declaration that this node is within.
static boolean isVoidType(ITypeBinding type)
          Is the given type the "void" type?
static String methodDeclarationToString(MethodDeclaration md)
           
static String ModifierToString(int modifier)
          Converts a modifier flag to a String representation of the modifers.
static
<T> T
nyi()
          Not Yet Implemented.
static
<T> T
nyi(String err_msg)
          Not Yet Implemented.
static String resolveBinaryType(IType context, String binaryType)
          For resolving binary types.
static String resolveType(IType context, String simpleName)
          To be used instead of IType.resolveType(String).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utilities

public Utilities()
Method Detail

resolveBinaryType

public static String resolveBinaryType(IType context,
                                       String binaryType)
                                throws JavaModelException
For resolving binary types. Those are of the form QString; and Ljava.lang.String;.

Throws:
JavaModelException

resolveType

public static String resolveType(IType context,
                                 String simpleName)
                          throws JavaModelException
To be used instead of IType.resolveType(String). The former returns a String[][], which is about the most useless thing in the world. Apparently, the idea is that resolveType could match to multiple things, so the first dimension is the matches. The second is really stupid, it's the qualified names. Also, IType.resolveType has issues with elemental types, and this method properly handles those as well.

Returns:
the first hit from context.resolveType(simpleName) as a fully qualified name, or simpleName if it was an elemental type, or null if the type could not be resolved.
Throws:
JavaModelException

ASTNodeToString

public static String ASTNodeToString(ASTNode node)
Takes an ASTNode and creates a more useful textual representation of it.


isVoidType

public static boolean isVoidType(ITypeBinding type)
Is the given type the "void" type?


ModifierToString

public static String ModifierToString(int modifier)
Converts a modifier flag to a String representation of the modifers.

Parameters:
modifier - the modifier flag
Returns:
the textual representation of the modifiers

getMethodDeclaration

public static MethodDeclaration getMethodDeclaration(ASTNode node)
Finds the method declaration that this node is within. If the node does not exist below a method declaration then null is returned.

Parameters:
node - the node whose method we wish to find
Returns:
the method declaration or null if not within one

methodDeclarationToString

public static String methodDeclarationToString(MethodDeclaration md)

nyi

public static <T> T nyi()
Not Yet Implemented. Throws a runtime exception, and is of any type.


nyi

public static <T> T nyi(String err_msg)
Not Yet Implemented. Throws a runtime exception with the given error message.