Exemple #1
0
        public Either<MemberReference, PropertyReferenceContainer> Convert(IAstReference astReference, ModuleDefinition module, IReferenceProvider recursive)
        {
            var reflectedType = astReference as AstReflectedType;
            if (reflectedType != null)
                return module.Import(reflectedType.ActualType);

            var reflectedMethod = astReference as AstReflectedMethod;
            if (reflectedMethod != null)
                return module.Import(reflectedMethod.Method);

            var reflectedConstructor = astReference as AstReflectedConstructor;
            if (reflectedConstructor != null)
                return module.Import(reflectedConstructor.Constructor);

            var reflectedProperty = astReference as AstReflectedProperty;
            if (reflectedProperty != null) {
                var getMethod = reflectedProperty.Property.GetGetMethod();
                var setMethod = reflectedProperty.Property.GetSetMethod();
                return new PropertyReferenceContainer(
                    getMethod != null ? module.Import(getMethod) : null,
                    setMethod != null ? module.Import(setMethod) : null
                );
            }

            return null;
        }
        protected NamedThingsSearchSourceFileProcessorWorkaround(ITreeNode root, ICollection <string> wordsInText,
                                                                 ICollection <string> referenceNames, IDeclaredElementsSet elements)
        {
            myRoot = root;
            myReferenceProvider = GetReferenceProvider2((TreeElement)root);
            myElements          = elements;

            var languageService = root.Language.LanguageService();

            if (languageService != null)
            {
                myCaseSensitive = languageService.IsCaseSensitive;
            }
            myCaseSensitive = myCaseSensitive && elements.CaseSensitive;

            if (wordsInText != null && wordsInText.Count > 0)
            {
                myStringSearchers = wordsInText.Where(word => !string.IsNullOrEmpty(word))
                                    .Select(word => new StringSearcher(word, myCaseSensitive)).ToArray();
            }

            if (referenceNames != null && referenceNames.Count > 0)
            {
                myReferenceNameContainer = new ReferenceNameContainer(referenceNames, myCaseSensitive);
            }
        }
        internal IReferenceProvider GetReferenceProvider2(TreeElement root)
        {
            for (TreeElement treeElement = root; treeElement != null; treeElement = (TreeElement)treeElement.parent)
            {
                switch (treeElement)
                {
                case IFileImpl fileImpl:
                    IReferenceProvider referenceProvider = fileImpl.ReferenceProvider;
                    if (referenceProvider != null)
                    {
                        return(referenceProvider);
                    }
                    break;

                case ISandBox sandBox:
                    ITreeNode contextNode = sandBox.ContextNode;
                    if (contextNode != null)
                    {
                        return(GetReferenceProvider2((TreeElement)contextNode));
                    }
                    break;
                }
            }

            return(null);
        }
Exemple #4
0
        public Either<MemberReference, PropertyReferenceContainer> Convert(IAstReference astReference, ModuleDefinition module, IReferenceProvider recursive)
        {
            if (astReference != AstVoidType.Instance)
                return null;

            return module.Import(typeof(void));
        }
Exemple #5
0
        Either<MemberReference, PropertyReferenceContainer> IReferenceProvider.Convert(IAstReference astReference, ModuleDefinition module, IReferenceProvider recursive)
        {
            if (module != this.module)
                throw new InvalidOperationException("Expected module to be " + this.module + ", received " + module);

            return this.ConvertReference(astReference);
        }
 public IdentifierHighlightingProcess(IDaemonProcess process, IYamlFile file,
                                      ResolveHighlighterRegistrar resolveHighlighterRegistrar,
                                      bool allowOpeningChameleons)
     : base(process, file, allowOpeningChameleons)
 {
     myResolveProblemHighlighter = new ResolveProblemHighlighter(resolveHighlighterRegistrar);
     myReferenceProvider         = ((IFileImpl)file).ReferenceProvider;
 }
        /// <summary>
        /// Registers the specified provider with the service.
        /// </summary>
        /// <param name="provider">The reference provider to register.</param>
        /// <exception cref="ArgumentException">A provider has already been registered
        /// for the same <see cref="IReferenceProvider.Scheme"/> scheme.</exception>
        public void Register(IReferenceProvider provider)
        {
            if (IsRegistered(provider.Scheme))
            {
                throw new ArgumentException();
            }

            this.providers[provider.Scheme] = provider;
        }
Exemple #8
0
 public IdentifierHighlighterProcess(IDaemonProcess process, ResolveHighlighterRegistrar registrar,
                                     IContextBoundSettingsStore settingsStore, DaemonProcessKind processKind,
                                     IShaderLabFile file, bool internalMode)
     : base(process, file)
 {
     myProcessKind               = processKind;
     myInternalMode              = internalMode;
     myVisualElementHighlighter  = new VisualElementHighlighter(ShaderLabLanguage.Instance, settingsStore);
     myResolveProblemHighlighter = new ResolveProblemHighlighter(registrar);
     myReferenceProvider         = ((IFileImpl)file).ReferenceProvider;
 }
 public IdentifierHighlighterProcess(IDaemonProcess process, ResolveHighlighterRegistrar registrar,
                                     IContextBoundSettingsStore settingsStore, DaemonProcessKind processKind, IShaderLabFile file,
                                     ConfigurableIdentifierHighlightingStageService identifierHighlightingStageService)
     : base(process, settingsStore, file)
 {
     myProcessKind = processKind;
     myIdentifierHighlightingEnabled = identifierHighlightingStageService.ShouldHighlightIdentifiers(settingsStore);
     myVisualElementHighlighter      = new VisualElementHighlighter(ShaderLabLanguage.Instance, settingsStore);
     myResolveProblemHighlighter     = new ResolveProblemHighlighter(registrar);
     myReferenceProvider             = ((IFileImpl)file).ReferenceProvider;
 }
Exemple #10
0
 public CsharpCompilationProvider(ISyntaxTreeProvider syntaxTreeProvider,
                                  ICodeProvider codeProvider,
                                  IFileNameProvider fileNameProvider,
                                  IReferenceProvider referenceProvider,
                                  ICompilationOptionProvider compilationOptionProvider)
 {
     _syntaxTreeProvider        = syntaxTreeProvider;
     _codeProvider              = codeProvider;
     _fileNameProvider          = fileNameProvider;
     _referenceProvider         = referenceProvider;
     _compilationOptionProvider = compilationOptionProvider;
 }
Exemple #11
0
        public Either<MemberReference, PropertyReferenceContainer> Convert(IAstReference astReference, ModuleDefinition module, IReferenceProvider recursive)
        {
            var generic = astReference as AstGenericTypeWithArguments;
            if (generic == null)
                return null;

            var primary = recursive.Convert(generic.PrimaryType, module, recursive).As<TypeReference>();
            var arguments = generic.TypeArguments.Select(a => recursive.Convert(a, module, recursive).As<TypeReference>());

            var result = new GenericInstanceType(primary);
            arguments.ForEach(result.GenericArguments.Add);

            return result;
        }
        public Either<MemberReference, PropertyReferenceContainer> Convert(IAstReference astReference, ModuleDefinition module, IReferenceProvider recursive)
        {
            var methodAst = astReference as AstGenericMethodWithTypeArguments;
            if (methodAst == null)
                return null;

            var method = recursive.Convert(methodAst.Actual, module, recursive).As<MethodReference>();
            var typeArguments = methodAst.GenericArgumentTypes.Select(a => recursive.Convert(a, module, recursive).As<TypeReference>());

            var result = new GenericInstanceMethod(method);
            typeArguments.ForEach(result.GenericArguments.Add);

            return result;
        }
Exemple #13
0
        public Either<MemberReference, PropertyReferenceContainer> Convert(IAstReference astReference, ModuleDefinition module, IReferenceProvider recursive)
        {
            var functionType = astReference as IAstFunctionTypeReference;
            if (functionType == null)
                return null;

            var types = new List<IAstTypeReference>(functionType.GetParameterTypes());
            var delegateTypeName = "Action";
            if (!(functionType.ReturnType is AstVoidType)) {
                delegateTypeName = "Func";
                types.Add(functionType.ReturnType);
            }
            delegateTypeName += "`" + types.Count;

            var delegateOpenType = module.Import(Type.GetType("System." + delegateTypeName, true));
            var delegateType = new GenericInstanceType(delegateOpenType);
            types.Select(t => recursive.Convert(t, module, recursive).As<TypeReference>())
                 .ForEach(delegateType.GenericArguments.Add);

            return delegateType;
        }
Exemple #14
0
 public LightCompiler(IDefinitionBuilder[] builders, ICilCompiler[] cilCompilers, IReferenceProvider[] referenceProviders)
 {
     this.builders = builders;
     this.cilCompilers = cilCompilers;
     this.referenceProviders = referenceProviders;
 }
Exemple #15
0
        public Either <MemberReference, PropertyReferenceContainer> Convert(IAstReference astReference, ModuleDefinition module, IReferenceProvider recursive)
        {
            var functionType = astReference as IAstFunctionTypeReference;

            if (functionType == null)
            {
                return(null);
            }

            var types            = new List <IAstTypeReference>(functionType.GetParameterTypes());
            var delegateTypeName = "Action";

            if (!(functionType.ReturnType is AstVoidType))
            {
                delegateTypeName = "Func";
                types.Add(functionType.ReturnType);
            }
            delegateTypeName += "`" + types.Count;

            var delegateOpenType = module.Import(Type.GetType("System." + delegateTypeName, true));
            var delegateType     = new GenericInstanceType(delegateOpenType);

            types.Select(t => recursive.Convert(t, module, recursive).As <TypeReference>())
            .ForEach(delegateType.GenericArguments.Add);

            return(delegateType);
        }
Exemple #16
0
        public Either <MemberReference, PropertyReferenceContainer> Convert(IAstReference astReference, ModuleDefinition module, IReferenceProvider recursive)
        {
            if (astReference != AstVoidType.Instance)
            {
                return(null);
            }

            return(module.Import(typeof(void)));
        }
 public LearnerAnonymiser(IReferenceProvider <long> ulnProvider, IReferenceProvider <string> learnerRefProvider)
 {
     _ulnProvider        = ulnProvider;
     _learnerRefProvider = learnerRefProvider;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CoordinateOperationStrategyFactory" /> class.
 /// </summary>
 /// <param name="provider">The reference provider.</param>
 /// <exception cref="System.ArgumentNullException">The provider is null.</exception>
 public CoordinateOperationStrategyFactory(IReferenceProvider provider)
 {
     this.provider = provider ?? throw new ArgumentNullException(nameof(provider));
 }
Exemple #19
0
 public TypeDeducingVisitor(IReferenceProvider provider, ITypeRef predicateClass)
 {
     _predicateClass    = predicateClass;
     _referenceProvider = provider;
     _clazz             = null;
 }
Exemple #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReferenceSystemFactory" /> class.
 /// </summary>
 /// <param name="provider">The reference provider.</param>
 /// <exception cref="System.ArgumentNullException">The provider is null.</exception>
 public ReferenceSystemFactory(IReferenceProvider provider)
 {
     this.provider = provider ?? throw new ArgumentNullException(nameof(provider));
 }
Exemple #21
0
        public Either <MemberReference, PropertyReferenceContainer> Convert(IAstReference astReference, ModuleDefinition module, IReferenceProvider recursive)
        {
            var generic = astReference as AstGenericTypeWithArguments;

            if (generic == null)
            {
                return(null);
            }

            var primary   = recursive.Convert(generic.PrimaryType, module, recursive).As <TypeReference>();
            var arguments = generic.TypeArguments.Select(a => recursive.Convert(a, module, recursive).As <TypeReference>());

            var result = new GenericInstanceType(primary);

            arguments.ForEach(result.GenericArguments.Add);

            return(result);
        }
        public Either <MemberReference, PropertyReferenceContainer> Convert(IAstReference astReference, ModuleDefinition module, IReferenceProvider recursive)
        {
            var methodAst = astReference as AstGenericMethodWithTypeArguments;

            if (methodAst == null)
            {
                return(null);
            }

            var method        = recursive.Convert(methodAst.Actual, module, recursive).As <MethodReference>();
            var typeArguments = methodAst.GenericArgumentTypes.Select(a => recursive.Convert(a, module, recursive).As <TypeReference>());

            var result = new GenericInstanceMethod(method);

            typeArguments.ForEach(result.GenericArguments.Add);

            return(result);
        }
Exemple #23
0
        public Either <MemberReference, PropertyReferenceContainer> Convert(IAstReference astReference, ModuleDefinition module, IReferenceProvider recursive)
        {
            var reflectedType = astReference as AstReflectedType;

            if (reflectedType != null)
            {
                return(module.Import(reflectedType.ActualType));
            }

            var reflectedMethod = astReference as AstReflectedMethod;

            if (reflectedMethod != null)
            {
                return(module.Import(reflectedMethod.Method));
            }

            var reflectedConstructor = astReference as AstReflectedConstructor;

            if (reflectedConstructor != null)
            {
                return(module.Import(reflectedConstructor.Constructor));
            }

            var reflectedProperty = astReference as AstReflectedProperty;

            if (reflectedProperty != null)
            {
                var getMethod = reflectedProperty.Property.GetGetMethod();
                var setMethod = reflectedProperty.Property.GetSetMethod();
                return(new PropertyReferenceContainer(
                           getMethod != null ? module.Import(getMethod) : null,
                           setMethod != null ? module.Import(setMethod) : null
                           ));
            }

            return(null);
        }
 public LearnerDestinationandProgressionAnonymiser(IReferenceProvider <long> ulnProvider, IReferenceProvider <string> learnerRefProvider)
 {
     _ulnProvider        = ulnProvider;
     _learnerRefProvider = learnerRefProvider;
 }
		public TypeDeducingVisitor(IReferenceProvider provider, ITypeRef predicateClass)
		{
			this._predicateClass = predicateClass;
			this._referenceProvider = provider;
			_clazz = null;
		}
Exemple #26
0
        Either <MemberReference, PropertyReferenceContainer> IReferenceProvider.Convert(IAstReference astReference, ModuleDefinition module, IReferenceProvider recursive)
        {
            if (module != this.module)
            {
                throw new InvalidOperationException("Expected module to be " + this.module + ", received " + module);
            }

            return(this.ConvertReference(astReference));
        }