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


C# SymbolTable.Merge方法代码示例

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


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

示例1: GetReferenceSymbolTable

    public static ISymbolTable GetReferenceSymbolTable(IPathReference pathReference, bool useReferenceName, bool includeHttpHandlers = true)
    {
      var propertiesSearcher =
        pathReference.GetTreeNode().GetSolution().GetComponent<MSBuildPropertiesCache>();

      string productHomeDir = propertiesSearcher.GetProjectPropertyByName(pathReference.GetTreeNode().GetProject(),
        "ProductHomeDir");
      var basePath = new FileSystemPath(productHomeDir);
      if (basePath.IsEmpty)
      {
        return EmptySymbolTable.INSTANCE;
      }

      FolderQualifierInfo folderQualifierInfo = null;
      IPsiServices psiServices = pathReference.GetTreeNode().GetPsiServices();
      var baseProjectFolder = psiServices.Solution.FindProjectItemsByLocation(basePath).FirstOrDefault() as IProjectFolder;
      if (baseProjectFolder != null)
      {
        folderQualifierInfo = new FolderQualifierInfo(baseProjectFolder);
      }

      FileSystemPath websiteRoot = GetRootPath(pathReference);
      IQualifier qualifier = pathReference.GetQualifier();
      if (useReferenceName)
      {
        PathDeclaredElement target = null;
        string name = pathReference.GetName();
        switch (name)
        {
          case PathDeclaredElement.CURRENT_DIR_NAME:
            target = new PathDeclaredElement(PathDeclaredElement.CURRENT_DIR_NAME, psiServices, basePath);
            break;
          case PathDeclaredElement.LEVEL_UP_NAME:
            target = new PathDeclaredElement(PathDeclaredElement.LEVEL_UP_NAME, psiServices, basePath.Directory);
            break;
          case PathDeclaredElement.ROOT_NAME:
            if (qualifier != null)
            {
              goto default;
            }
            target = new PathDeclaredElement(PathDeclaredElement.ROOT_NAME, psiServices, websiteRoot);
            break;
          default:
            try
            {
              string parserGenOutputBase =
                propertiesSearcher.GetProjectPropertyByName(pathReference.GetTreeNode().GetProject(), "ParserGenOutputBase");
              FileSystemPath path = basePath.Combine(parserGenOutputBase + "\\" + name);
              target = new PathDeclaredElement(name, psiServices, path);
            }
            catch (InvalidPathException)
            {
            }
            catch (ArgumentException)
            {
            }
            break;
        }
        var table = new SymbolTable(psiServices, folderQualifierInfo != null ? new SymbolTableDependencySet(folderQualifierInfo) : null);
        if (target != null)
        {
          table.AddSymbol(target, EmptySubstitution.INSTANCE, 1);
        }
        return table;
      }

      FileSystemPath rootPath = (qualifier == null) ? websiteRoot : FileSystemPath.Empty;
      ISymbolTable symbolTableByPath = PathReferenceUtil.GetSymbolTableByPath(basePath, psiServices, basePath.Directory, rootPath, true);
      FileSystemPath basePathBeforeMapping = GetBasePathBeforeMapping(pathReference);
      if (!basePathBeforeMapping.IsNullOrEmpty())
      {
        IWebProjectPathMapping pathMapping = WebPathMappingManager.GetPathMapping(pathReference);
        List<FileSystemPath> mappedPaths = pathMapping.GetAllPathPartsIn(basePathBeforeMapping).ToList();
        if (mappedPaths.Any())
        {
          var mappedPathsTable = new SymbolTable(psiServices, folderQualifierInfo != null ? new SymbolTableDependencySet(folderQualifierInfo) : null);
          foreach (FileSystemPath mappedPath in mappedPaths)
          {
            var declaredElement = new PathDeclaredElement(psiServices, mappedPath);
            mappedPathsTable.AddSymbol(declaredElement, EmptySubstitution.INSTANCE, 1);
          }
          symbolTableByPath = symbolTableByPath.Merge(mappedPathsTable);
        }
      }

      if (!includeHttpHandlers)
      {
        return symbolTableByPath;
      }

      var httpHandlersTable = new SymbolTable(psiServices);

      return httpHandlersTable.Merge(symbolTableByPath);
    }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:94,代码来源:PsiPathReferenceUtil.cs


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