~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/ExpansionObject.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
                        }
54
54
                }
55
55
                
56
 
                public IParsedFile ParsedDocument {
 
56
                public IUnresolvedFile ParsedDocument {
57
57
                        get;
58
58
                        set;
59
59
                }
147
147
                                var baseTypeDef = baseType.GetDefinition();
148
148
                                if (baseTypeDef != null && baseTypeDef.Name == "IEnumerable") {
149
149
                                        if (baseTypeDef.Namespace == "System.Collections.Generic" && baseTypeDef.TypeParameterCount == 1) {
150
 
                                                var pt = baseType as ParameterizedType;
151
 
                                                if (pt != null) {
152
 
                                                        return pt.TypeArguments[0];
153
 
                                                }
 
150
                                                if (baseType.TypeArguments.Count > 0)
 
151
                                                        return baseType.TypeArguments[0];
154
152
                                        } else if (baseTypeDef.Namespace == "System.Collections" && baseTypeDef.TypeParameterCount == 0) {
155
153
                                                return CurrentContext.Compilation.FindType (KnownTypeCode.Object);
156
154
                                        }
254
252
                                member = name.Substring (idx);
255
253
                                name = name.Substring (0, idx);
256
254
                        }
257
 
                        
258
 
                        var type = CurrentContext.Compilation.LookupType (ns, name);
 
255
 
 
256
                        var type = new GetClassTypeReference (ns, name, 0).Resolve (new SimpleTypeResolveContext (CurrentContext.Document.Compilation.MainAssembly));
 
257
                        bool stripAttribute = false;
 
258
                        if (type == null || type.Kind == TypeKind.Unknown) {
 
259
                                type = new GetClassTypeReference (ns, name + "Attribute", 0).Resolve (
 
260
                                        new SimpleTypeResolveContext (CurrentContext.Document.Compilation.MainAssembly)
 
261
                                );      
 
262
                                stripAttribute = true;
 
263
                        }
259
264
                        if (type == null || type.Kind == TypeKind.Unknown)
260
 
                                return fullTypeName;
 
265
                                return fullTypeName.Replace ("#", ".");
261
266
                        var generator = CodeGenerator.CreateGenerator (CurrentContext.Document);
262
 
                        if (generator != null)
263
 
                                return generator.GetShortTypeString (CurrentContext.Document, type) + member;
264
 
                        return fullTypeName;
 
267
                        if (generator != null) {
 
268
                                var result = generator.GetShortTypeString (CurrentContext.Document, type) + member;
 
269
                                if (stripAttribute && result.EndsWith ("Attribute", StringComparison.Ordinal))
 
270
                                    result = result.Substring (0, result.Length - "Attribute".Length);
 
271
                                return result;
 
272
                        }
 
273
                        return fullTypeName.Replace ("#", ".");
265
274
                }
266
275
                
267
276
                static Regex functionRegEx = new Regex ("([^(]*)\\(([^(]*)\\)", RegexOptions.Compiled);