protected FSharpTypeParametersOwnerPart([NotNull] T declaration, MemberDecoration memberDecoration,
                                                TreeNodeCollection <ITypeParameterOfTypeDeclaration> typeParameters, [NotNull] ICacheBuilder cacheBuilder)
            : base(declaration, cacheBuilder.Intern(declaration.CompiledName), memberDecoration, typeParameters.Count,
                   cacheBuilder)
        {
            if (typeParameters.Count == 0)
            {
                myTypeParameterNames = EmptyArray <string> .Instance;
                return;
            }

            myTypeParameterNames = new string[typeParameters.Count];
            for (var i = 0; i < typeParameters.Count; i++)
            {
                myTypeParameterNames[i] = cacheBuilder.Intern(typeParameters[i].CompiledName);
            }
        }
Example #2
0
        public static string GetNestedModuleShortName(this INestedModuleDeclaration declaration, ICacheBuilder cacheBuilder)
        {
            var parent     = declaration.Parent as IModuleLikeDeclaration;
            var shortName  = declaration.ShortName;
            var moduleName =
                parent?.Children <IFSharpTypeDeclaration>().Any(t => t.TypeParameters.IsEmpty && t.ShortName.Equals(shortName, StringComparison.Ordinal)) ?? false
          ? shortName + "Module"
          : shortName;

            return(cacheBuilder.Intern(moduleName));
        }
        protected FSharpTypeParametersOwnerPart([NotNull] T declaration, MemberDecoration memberDecoration,
                                                TreeNodeCollection <ITypeParameterOfTypeDeclaration> typeParameters, [NotNull] ICacheBuilder cacheBuilder)
            : base(declaration, cacheBuilder.Intern(declaration.ShortName), memberDecoration, typeParameters.Count, cacheBuilder)
        {
            var parameters = declaration.TypeParameters;

            if (parameters.Count == 0)
            {
                myTypeParameterNames = EmptyArray <string> .Instance;
                return;
            }

            myTypeParameterNames = new string[typeParameters.Count];
            for (var i = 0; i < typeParameters.Count; i++)
            {
                var name    = typeParameters[i].GetText();
                var trimmed = !name.IsEmpty() && name[0] == '\'' ? name.Substring(1) : name;
                myTypeParameterNames[i] = cacheBuilder.Intern(trimmed);
            }
        }
Example #4
0
        public UnionCasePart([NotNull] INestedTypeUnionCaseDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder)
            : base(declaration, ModifiersUtil.GetDecoration(declaration),
                   TreeNodeCollection <ITypeParameterOfTypeDeclaration> .Empty, cacheBuilder)
        {
            var unionShortName = declaration.GetContainingNode <IUnionDeclaration>()?.ShortName;

            ExtendsListShortNames =
                unionShortName != null
          ? new[] { cacheBuilder.Intern(unionShortName) }
          : EmptyArray <string> .Instance;
        }
Example #5
0
        private void StartNamespaceQualifier([CanBeNull] IReferenceName referenceName)
        {
            if (referenceName == null)
            {
                return;
            }

            StartNamespaceQualifier(referenceName.Qualifier);
            var qualifierName = Builder.Intern(referenceName.ShortName);

            Builder.StartPart(new QualifiedNamespacePart(referenceName.Identifier.GetTreeStartOffset(), qualifierName));
        }
Example #6
0
        protected FSharpTypePart([NotNull] T declaration, [NotNull] string shortName, MemberDecoration memberDecoration,
                                 int typeParameters, [NotNull] ICacheBuilder cacheBuilder) : base(declaration, shortName, typeParameters)
        {
            Modifiers = memberDecoration;

            var attrNames = new FrugalLocalHashSet <string>();

            foreach (var attr in declaration.GetAttributes())
            {
                attrNames.Add(cacheBuilder.Intern(attr.GetShortName()));
            }
            AttributeClassNames = attrNames.ToArray();

            var methods = new LocalList <ExtensionMethodInfo>();

            foreach (var member in declaration.MemberDeclarations)
            {
                // There are two interesting scenarios:
                // * Members in types
                // * Bindings in modules
                // Type declaration as a member can only appear in module and we ignore it.
                if (member is ITypeDeclaration)
                {
                    continue;
                }

                // A cheap check until we have a proper attributes resolve during cache building.
                if (!member.GetAttributes().Any(a => a.ShortNameEquals("Extension")))
                {
                    continue;
                }

                var offset = member.GetTreeStartOffset().Offset;
                methods.Add(new ExtensionMethodInfo(AnyCandidateType.INSTANCE, offset, member.DeclaredName)
                {
                    Owner = this
                });
            }

            if (methods.IsEmpty())
            {
                return;
            }

            ExtensionMethodInfos = methods.ToArray();
        }
Example #7
0
        public void ProcessNamedModuleLikeDeclaration(INamedModuleLikeDeclaration decl, Part part)
        {
            var qualifiers = decl.LongIdentifier?.Qualifiers ?? TreeNodeCollection <ITokenNode> .Empty;

            foreach (var qualifier in qualifiers)
            {
                var qualifierName = Builder.Intern(qualifier.GetText().RemoveBackticks());
                Builder.StartPart(new QualifiedNamespacePart(qualifier.GetTreeStartOffset(), qualifierName));
            }

            Builder.StartPart(part);
            FinishModuleLikeDeclaration(decl);

            foreach (var _ in qualifiers)
            {
                Builder.EndPart();
            }
        }
Example #8
0
        protected FSharpTypePart([NotNull] T declaration, [NotNull] string shortName, MemberDecoration memberDecoration,
                                 int typeParameters, [NotNull] ICacheBuilder cacheBuilder) : base(declaration, shortName, typeParameters)
        {
            Modifiers = memberDecoration;

            var attributes = declaration.GetAttributes();
            var attrNames  = new FrugalLocalHashSet <string>();

            foreach (var attr in attributes)
            {
                attrNames.Add(cacheBuilder.Intern(attr.LongIdentifier?.Name.GetAttributeShortName()));
            }
            AttributeClassNames = attrNames.ToArray();

            if (!attributes.Any(a => a.ShortNameEquals("Extension")))
            {
                return;
            }

            var methods = new LocalList <ExtensionMethodInfo>();

            foreach (var member in declaration.MemberDeclarations)
            {
                if (!member.GetAttributes().Any(a => a.ShortNameEquals("Extension")))
                {
                    continue;
                }

                var offset = member.GetTreeStartOffset().Offset;
                methods.Add(new ExtensionMethodInfo(AnyCandidateType.INSTANCE, offset, member.DeclaredName)
                {
                    Owner = this
                });
            }

            ExtensionMethodInfos = methods.ToArray();
        }
Example #9
0
        public override void VisitFSharpFile(IFSharpFile fsFile)
        {
            var sourceFile = fsFile.GetSourceFile();

            if (sourceFile == null)
            {
                return;
            }

            var fileKind    = GetFSharpFileKind(fsFile);
            var hasPairFile = myCheckerService.HasPairFile(sourceFile);

            Builder.CreateProjectFilePart(new FSharpProjectFilePart(sourceFile, fileKind, hasPairFile));

            foreach (var declaration in fsFile.DeclarationsEnumerable)
            {
                var qualifiers = declaration.LongIdentifier?.Qualifiers;
                if (qualifiers == null)
                {
                    declaration.Accept(this);
                    continue;
                }

                foreach (var qualifier in qualifiers)
                {
                    var qualifierName = qualifier.GetText().RemoveBackticks();
                    Builder.StartPart(new QualifiedNamespacePart(qualifier.GetTreeStartOffset(), Builder.Intern(qualifierName)));
                }

                declaration.Accept(this);

                foreach (var _ in qualifiers)
                {
                    Builder.EndPart();
                }
            }
        }
Example #10
0
        public override void VisitFSharpFile(IFSharpFile fsFile)
        {
            fsFile.TokenBuffer = fsFile.ActualTokenBuffer; // todo: remove this when/if a proper lexer is implemented
            var sourceFile  = fsFile.GetSourceFile();
            var fileKind    = GetFSharpFileKind(fsFile);
            var hasPairFile = myCheckerService.HasPairFile(sourceFile);

            Builder.CreateProjectFilePart(new FSharpProjectFilePart(sourceFile, fileKind, hasPairFile));

            foreach (var declaration in fsFile.DeclarationsEnumerable)
            {
                var qualifiers = declaration.LongIdentifier.Qualifiers;
                foreach (var qualifier in qualifiers)
                {
                    var qualifierName = qualifier.GetText().RemoveBackticks();
                    Builder.StartPart(new QualifiedNamespacePart(qualifier.GetTreeStartOffset(), Builder.Intern(qualifierName)));
                }

                declaration.Accept(this);

                foreach (var _ in qualifiers)
                {
                    Builder.EndPart();
                }
            }
        }
Example #11
0
 public AnonModulePart([NotNull] IAnonModuleDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder)
     : base(declaration, cacheBuilder.Intern(declaration.CompiledName),
            MemberDecoration.FromModifiers(ReSharper.Psi.Modifiers.PUBLIC), cacheBuilder)
 {
 }
 public NamedModulePart([NotNull] INamedModuleDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder)
     : base(declaration, cacheBuilder.Intern(declaration.CompiledName),
            ModifiersUtil.GetDecoration(declaration.AccessModifier, declaration.Attributes), cacheBuilder)
 {
 }
 public TopLevelModulePart([NotNull] ITopLevelModuleDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder)
     : base(declaration, cacheBuilder.Intern(declaration.CompiledName),
            ModifiersUtil.GetDecoration(declaration.AccessModifiers, declaration.AttributesEnumerable), cacheBuilder)
 {
 }