~ubuntu-branches/ubuntu/feisty/monodevelop/feisty

« back to all changes in this revision

Viewing changes to Extras/VBNetBinding/SharpRefactoryVB/src/Parser/AST/LookupTableVisitor.cs

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-08-18 00:51:23 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060818005123-5iit07y0j7wjg55f
Tags: 0.11+svn20060818-0ubuntu1
* New SVN snapshot
  + Works with Gtk# 2.9.0
* debian/control:
  + Updated Build-Depends
* debian/patches/use_nunit2.2.dpatch,
  debian/patches/use_real_libs.dpatch:
  + Updated
* debian/patches/versioncontrol_buildfix.dpatch:
  + Fix build failure in the version control addin

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
using System;
2
 
using System.Drawing;
3
 
using System.Collections;
4
 
 
5
 
using ICSharpCode.SharpRefactory.Parser.AST.VB;
6
 
 
7
 
namespace ICSharpCode.SharpRefactory.Parser.VB
8
 
{
9
 
        public class LocalLookupVariable
10
 
        {
11
 
                TypeReference typeRef;
12
 
                Point         startPos;
13
 
                Point         endPos;
14
 
                
15
 
                public TypeReference TypeRef {
16
 
                        get {
17
 
                                return typeRef;
18
 
                        }
19
 
                }
20
 
                public Point StartPos {
21
 
                        get {
22
 
                                return startPos;
23
 
                        }
24
 
                }
25
 
                public Point EndPos {
26
 
                        get {
27
 
                                return endPos;
28
 
                        }
29
 
                }
30
 
                
31
 
                public LocalLookupVariable(TypeReference typeRef, Point startPos, Point endPos)
32
 
                {
33
 
                        this.typeRef = typeRef;
34
 
                        this.startPos = startPos;
35
 
                        this.endPos = endPos;
36
 
                }
37
 
        }
38
 
        
39
 
        public class LookupTableVisitor : AbstractASTVisitor
40
 
        {
41
 
                Hashtable variables      = new Hashtable();
42
 
                ArrayList withStatements = new ArrayList();
43
 
                
44
 
                public Hashtable Variables {
45
 
                        get {
46
 
                                return variables;
47
 
                        }
48
 
                }
49
 
                
50
 
                public ArrayList WithStatements {
51
 
                        get {
52
 
                                return withStatements;
53
 
                        }
54
 
                }
55
 
                
56
 
                public void AddVariable(TypeReference typeRef, string name, Point startPos, Point endPos)
57
 
                {
58
 
                        if (name == null || name.Length == 0) {
59
 
                                return;
60
 
                        }
61
 
                        name = name.ToLower();
62
 
                        ArrayList list;
63
 
                        if (variables[name] == null) {
64
 
                                variables[name] = list = new ArrayList();
65
 
                        } else {
66
 
                                list = (ArrayList)variables[name];
67
 
                        }
68
 
                        list.Add(new LocalLookupVariable(typeRef, startPos, endPos));
69
 
                }
70
 
                
71
 
                public override object Visit(LocalVariableDeclaration localVariableDeclaration, object data)
72
 
                {
73
 
                        foreach (VariableDeclaration varDecl in localVariableDeclaration.Variables) {
74
 
                                AddVariable(varDecl.Type, 
75
 
                                            varDecl.Name,
76
 
                                            localVariableDeclaration.StartLocation,
77
 
                                            CurrentBlock == null ? new Point(-1, -1) : CurrentBlock.EndLocation);
78
 
                        }
79
 
                        return data;
80
 
                }
81
 
                
82
 
                public override object Visit(LoopControlVariableExpression loopControlVariableExpression, object data)
83
 
                {
84
 
                        AddVariable(loopControlVariableExpression.Type, 
85
 
                                    loopControlVariableExpression.Name,
86
 
                                    loopControlVariableExpression.StartLocation,
87
 
                                    CurrentBlock == null ? new Point(-1, -1) : CurrentBlock.EndLocation);
88
 
                        return data;
89
 
                }
90
 
                
91
 
                public override object Visit(WithStatement withStatement, object data)
92
 
                {
93
 
                        withStatements.Add(withStatement);
94
 
                        return base.Visit(withStatement, data);
95
 
                }
96
 
                
97
 
        }
98
 
}