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


C# IElement.GetDocumentRange方法代码示例

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


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

示例1: AddHighlighting

 private void AddHighlighting(IElement elementToHighlight, IHighlighting highlighting) {
     m_Highlightings.Add(new HighlightingInfo(elementToHighlight.GetDocumentRange(), highlighting));
 }
开发者ID:hazzik,项目名称:ReSharper.NHibernate,代码行数:3,代码来源:MappingFileAnalysisElementProcessor.cs

示例2: ProcessElementParametersOwner

        private void ProcessElementParametersOwner(IElement element)
        {
            IDeclaredParametersOwner declaredParametersOwner = element as IDeclaredParametersOwner;

            // TODO use get reference

            if(declaredParametersOwner != null)
            {
                IParameterDescriptorProvider parameterDescriptorProvider = declaredParametersOwner as IParameterDescriptorProvider;

                if (parameterDescriptorProvider == null)
                    return;

                if(!parameterDescriptorProvider.IsAvailable)
                    return;

                ICollection<IParameterDescriptor> infos = parameterDescriptorProvider.GetParameterDescriptors();

                ICollection<IDeclaredParameter> declaredParameters = declaredParametersOwner.GetParams();

                // Highlight invalid names
                foreach (IDeclaredParameter param in declaredParameters)
                {
                    if(ParametersUtil.GetByName(infos, param.Name) == null)
                    {
                        highlightings.Add(new HighlightingInfo(param.NameDocumentRange, new InvalidPropertyHighlighting()));
                    }
                }

                // Highlight requred attributes
                IXmlTag tag = element as IXmlTag;
                foreach (IParameterDescriptor descriptor in infos)
                {
                    if(descriptor.IsRequired)
                    {
                        if(ParametersUtil.GetByName(declaredParameters, descriptor.Name) != null
                            // it is conxeption hak, TODO fix parameters conception
                            || (tag != null && tag.GetAttribute(descriptor.Name) != null))
                            continue;

                        DocumentRange range;
                        if (tag != null)
                            range = GetHighlightRange(tag.ToTreeNode().Header);
                        else
                            range = element.ToTreeNode().GetDocumentRange();

                        highlightings.Add(new HighlightingInfo(range, new MissedParameterError(descriptor, element)));

                    }
                }

                // highlight invalid values
                foreach (IDeclaredParameter param in declaredParameters)
                {
                    IParameterDescriptor descriptor = ParametersUtil.GetByName(infos, param.Name);
                    if (descriptor == null)
                        continue;

                    IParameterStringValueValidator validator = ValidatorsManager.Instance().GetValidator(descriptor);
                    if (validator == null)
                        continue;

                    // TODO introduce interface marker to determine tag pased parameters
                    PropertyParamImpl propertyParam = param as PropertyParamImpl;
                    IXmlAttributeValue attributeValue = null;
                    if (propertyParam != null)
                    {
                        attributeValue = propertyParam.Value;
                    }
                    else // attribute
                    {
                        IXmlAttribute attribute = ((IXmlTag)declaredParametersOwner).GetAttribute(param.Name);
                        if (attribute != null)
                            attributeValue = attribute.Value;
                    }

                    if (attributeValue == null)
                        continue;

                    string unquotedValue = attributeValue.UnquotedValue;
                    ValidationResult validateResult = validator.Validate(unquotedValue);
                    if (validateResult == ValidationResult.Ok)
                        continue;

                    if(validateResult.Range == TextRange.InvalidRange)
                        continue;

                    int valueStart = attributeValue.ToTreeNode().GetDocumentRange().TextRange.StartOffset + 1;
                    TextRange valueRange = new TextRange(valueStart, valueStart + unquotedValue.Length);
                    int errorStart = valueRange.StartOffset + validateResult.Range.StartOffset;
                    TextRange errorRange = new TextRange(errorStart, errorStart + validateResult.Range.Length);
                    errorRange = valueRange.Intersect(errorRange);

                    if (errorRange == TextRange.InvalidRange)
                        continue;

                    if(errorRange.IsEmpty)
                    {
                        if (attributeValue.UnquotedValue.Length  == 0)
                        {
//.........这里部分代码省略.........
开发者ID:willrawls,项目名称:arp,代码行数:101,代码来源:L4NProcessor.cs

示例3: GetLineNumberForElement

        /// <summary>
        /// Get the line number that the provided element is on. 0 based.
        /// </summary>
        /// <param name="element">
        /// The element to use.
        /// </param>
        /// <returns>
        /// An <see cref="int"/> of the line number. 0 based. -1 if the element was invalid.
        /// </returns>
        public static JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine> GetLineNumberForElement(IElement element)
        {
            DocumentRange range = element.GetDocumentRange();

            if (range == DocumentRange.InvalidRange)
            {
                JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine> line = (JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine>)0;

                return line.Minus1();
            }

            return range.Document.GetCoordsByOffset(range.TextRange.StartOffset).Line;
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:22,代码来源:Utils.cs


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