ada.editor/src/org/netbeans/modules/ada/editor/CodeUtils.java
branchrelease68
changeset 16367 d2820c029d3a
parent 15779 367c7fdb5d23
     1.1 --- a/ada.editor/src/org/netbeans/modules/ada/editor/CodeUtils.java	Wed Sep 23 02:06:44 2009 +0200
     1.2 +++ b/ada.editor/src/org/netbeans/modules/ada/editor/CodeUtils.java	Sun Aug 22 23:37:11 2010 +0200
     1.3 @@ -43,14 +43,16 @@
     1.4  import org.netbeans.modules.ada.editor.ast.nodes.FormalParameter;
     1.5  import org.netbeans.modules.ada.editor.ast.nodes.Identifier;
     1.6  import org.netbeans.modules.ada.editor.ast.nodes.MethodDeclaration;
     1.7 +import org.netbeans.modules.ada.editor.ast.nodes.MethodInvocation;
     1.8 +import org.netbeans.modules.ada.editor.ast.nodes.NameBase;
     1.9  import org.netbeans.modules.ada.editor.ast.nodes.PackageBody;
    1.10  import org.netbeans.modules.ada.editor.ast.nodes.PackageName;
    1.11  import org.netbeans.modules.ada.editor.ast.nodes.PackageSpecification;
    1.12 -import org.netbeans.modules.ada.editor.ast.nodes.Reference;
    1.13 -import org.netbeans.modules.ada.editor.ast.nodes.Statement;
    1.14  import org.netbeans.modules.ada.editor.ast.nodes.SubprogramBody;
    1.15  import org.netbeans.modules.ada.editor.ast.nodes.SubprogramSpecification;
    1.16 +import org.netbeans.modules.ada.editor.ast.nodes.TypeAccess;
    1.17  import org.netbeans.modules.ada.editor.ast.nodes.TypeDeclaration;
    1.18 +import org.netbeans.modules.ada.editor.ast.nodes.TypeName;
    1.19  import org.netbeans.modules.ada.editor.ast.nodes.Variable;
    1.20  
    1.21  /**
    1.22 @@ -96,7 +98,7 @@
    1.23          return methodDeclaration.getMethodName();
    1.24      }
    1.25  
    1.26 -    @CheckForNull // null for RelectionVariable
    1.27 +    @CheckForNull
    1.28      public static String extractVariableName(Variable var) {
    1.29          if (var.getName() instanceof Identifier) {
    1.30              Identifier id = (Identifier) var.getName();
    1.31 @@ -109,7 +111,7 @@
    1.32          return null;
    1.33      }
    1.34  
    1.35 -    @CheckForNull // null for RelectionVariable
    1.36 +    @CheckForNull
    1.37      public static String extractTypeName(TypeDeclaration var) {
    1.38          if (var.getTypeName() instanceof Identifier) {
    1.39              Identifier id = (Identifier) var.getTypeName();
    1.40 @@ -122,6 +124,33 @@
    1.41          return null;
    1.42      }
    1.43  
    1.44 +    @CheckForNull
    1.45 +    public static String extractTypeName(NameBase type) {
    1.46 +        if (type instanceof TypeName) {
    1.47 +            Identifier id = ((TypeName)type).getTypeName();
    1.48 +            StringBuilder typeName = new StringBuilder();
    1.49 +            typeName.append(id.getName());
    1.50 +            return typeName.toString();
    1.51 +        } else if (type instanceof TypeAccess) {
    1.52 +            NameBase name = ((TypeAccess) type).getMember();
    1.53 +            return extractTypeName(name);
    1.54 +        }
    1.55 +
    1.56 +        return null;
    1.57 +    }
    1.58 +
    1.59 +    @CheckForNull
    1.60 +    public static TypeName extractType(NameBase type) {
    1.61 +        if (type instanceof TypeName) {
    1.62 +            return (TypeName)type;
    1.63 +        } else if (type instanceof TypeAccess) {
    1.64 +            NameBase name = ((TypeAccess) type).getMember();
    1.65 +            return extractType(name);
    1.66 +        }
    1.67 +
    1.68 +        return null;
    1.69 +    }
    1.70 +
    1.71      public static String getParamDisplayName(FormalParameter param) {
    1.72          Variable var = param.getParameterName();
    1.73          StringBuilder paramName = new StringBuilder();