当前位置: 首页>>代码示例>>C#>>正文


C# IDeclaredElement.GetPsiServices方法代码示例

本文整理汇总了C#中IDeclaredElement.GetPsiServices方法的典型用法代码示例。如果您正苦于以下问题:C# IDeclaredElement.GetPsiServices方法的具体用法?C# IDeclaredElement.GetPsiServices怎么用?C# IDeclaredElement.GetPsiServices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDeclaredElement的用法示例。


在下文中一共展示了IDeclaredElement.GetPsiServices方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GeneratedClassSearchRequest

    public GeneratedClassSearchRequest(IDeclaredElement declaredElement)
    {
      if (declaredElement == null)
        throw new ArgumentNullException("declaredElement");
      Logger.Assert(declaredElement.IsValid(), "declaredElement should be valid");

      mySolution = declaredElement.GetPsiServices().Solution;
      var ruleDeclaration = declaredElement as RuleDeclaration;
      if( ruleDeclaration == null)
        throw new ArgumentNullException("ruleDeclaration");

      if (ruleDeclaration.DerivedClasses.Count() > 0)
      {
        myTarget = new DeclaredElementEnvoy<IDeclaredElement>(ruleDeclaration.DerivedClasses.First());
      }
      else
      {
        myTarget = new DeclaredElementEnvoy<IDeclaredElement>(declaredElement);
      }
    }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:20,代码来源:GeneratedClassSearchRequest.cs

示例2: CSharpToPsiSearchRequest

    public CSharpToPsiSearchRequest(IDeclaredElement declaredElement)
    {
      if (declaredElement == null)
        throw new ArgumentNullException("declaredElement");
      Logger.Assert(declaredElement.IsValid(), "declaredElement should be valid");

      mySolution = declaredElement.GetPsiServices().Solution;


      var @class = declaredElement as IClass;
      if (@class != null)
      {
        myTarget = new DeclaredElementEnvoy<IDeclaredElement>(DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForClass(@class));
      }

      var @method = declaredElement as IMethod;
      if (@method != null)
      {
        myTarget = new DeclaredElementEnvoy<IDeclaredElement>(DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForMethod(@method));
      }

      var @interface = declaredElement as IInterface;
      if (@interface != null)
      {
        myTarget = new DeclaredElementEnvoy<IDeclaredElement>(DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForInterface(@interface));
      }

      var @constructor = declaredElement as IConstructor;

      if(@constructor != null)
      {
        @class = @constructor.GetContainingType() as IClass;

        if(@class != null)
        {
          myTarget = new DeclaredElementEnvoy<IDeclaredElement>(DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForClass(@class));
        }
      }
    }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:39,代码来源:CSharpToPsiSearchRequest.cs

示例3: GetPrimaryDeclaredElementForVisitorMethod

 private static IDeclaredElement GetPrimaryDeclaredElementForVisitorMethod(IDeclaredElement declaredElement, IMethod method)
 {
   var cache = declaredElement.GetPsiServices().Solution.GetComponent<PsiCache>();
   Dictionary<ITypeElement, IList<PsiOptionSymbol>> classesWithInfo = GetVisitorClasses(cache);
   if (classesWithInfo.Count > 0)
   {
     var parentClass = method.GetContainingType() as IClass;
     if (parentClass != null)
     {
       if (classesWithInfo.ContainsKey(parentClass))
       {
         IList<PsiOptionSymbol> list = classesWithInfo[parentClass];
         PsiOptionSymbol visitorName = list[0];
         PsiOptionSymbol methodSuffix = list[1];
         PsiOptionSymbol methodPrefix = list[2];
         IPsiSourceFile sourceFile = visitorName.SourceFile;
         string name = method.ShortName;
         if (name.Length > methodPrefix.Value.Length + methodSuffix.Value.Length)
         {
           if (methodPrefix.Value.Length > 0)
           {
             name = name.Substring(methodPrefix.Value.Length, name.Length - methodPrefix.Value.Length);
           }
           if (methodSuffix.Value.Length > 0)
           {
             name = name.Substring(0, name.Length - methodSuffix.Value.Length);
           }
           IEnumerable<IPsiSymbol> elements = cache.GetSymbols(NameFromCamelCase(name));
           foreach (IPsiSymbol psiSymbol in elements)
           {
             if (psiSymbol.SourceFile == sourceFile)
             {
               var psiFile = sourceFile.GetPsiFile<PsiLanguage>(new DocumentRange(psiSymbol.SourceFile.Document, 0)) as PsiFile;
               if (psiFile != null)
               {
                 IList<ISymbolInfo> infos = psiFile.FileRuleSymbolTable.GetSymbolInfos(name);
                 foreach (ISymbolInfo info in infos)
                 {
                   IDeclaredElement element = info.GetDeclaredElement();
                   if (element is RuleDeclaration)
                   {
                     var ruleDeclaration = element as RuleDeclaration;
                     {
                       return ruleDeclaration;
                     }
                   }
                 }
               }
             }
           }
         }
         else
         {
           {
             return null;
           }
         }
       }
     }
   }
   {
     return null;
   }
 }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:64,代码来源:DerivedDeclaredElementUtil.cs

示例4: EvalTestPartPredicate

			private bool EvalTestPartPredicate(IDeclaredElement element, Predicate<TestPart> predicate)
			{
				if (!element.IsValid())
					return false;

				try
				{
#if RESHARPER_60
					var reflectionPolicy = new PsiReflectionPolicy(element.GetPsiServices().PsiManager);
#else
					var reflectionPolicy = new PsiReflectionPolicy(element.GetPsiServices().PsiManager, provider.CacheManager);
#endif
					var elementInfo = reflectionPolicy.Wrap(element);
					if (elementInfo == null)
						return false;

					var driver = CreateTestDriver();
					var testParts = driver.GetTestParts(reflectionPolicy, elementInfo);
					return GenericCollectionUtils.Exists(testParts, predicate);
				}
				catch (Exception ex)
				{
					HandleEmbeddedProcessCancelledException(ex);
					throw;
				}
			}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:26,代码来源:GallioTestProvider6.cs


注:本文中的IDeclaredElement.GetPsiServices方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。