Utils
M
ModuleQualificationUtil
See also: IXmlAttributeValue
Helper methods to support references to CLR types inside XML documents, e.g. web.config files.
GetModuleName
returns the name of the given module, e.g. if it's a project, then return the assembly name, else return the module's name.GetModuleQualification
returns the fully qualified assembly name of the module, either the compiled assemblies name, or the name built up from the project settings.GetTypeName
returns a CLR type name and assembly name info from an assembly qualified type name specified in an XML attribute. Defers toJetBrains.Metadata.Utils.ModuleQualificationUtil.GetTypeName
.GetTypeNameCompletionRange
takes in a string and a starting offset and works out from the text where a type name will start and end, by walking backwards from the start whileIsTypeNameChar
is true, and walking forwards whileIsIdentifierChar
is true.GetTypeNameFullRange
returns the full range of a type name inside a given string. This is different toGetTypeNameCompletionRange
by allowing type name characters after the start offset, which allows for the current offset to be in a namespace, or for the type name to include nested types.IsIdentifierChar
returnstrue
if the given character is a letter, digit or the underscore symbol (_
).IsTypeNameChar
returnstrue
if the given character is a letter, digit, or either an underscore, period, plus or backtick symbol (_
,.
,+
or ```).ResolveType
retrieves a collection ofITypeElement
instances for the given CLR name, using anISymbolScope
retrieved viaIPsiServices.Symbols
.
R
ReferenceWithTokenUtil
See also: IXmlToken
Helper methods for handling references within a token node. The methods defer to ReferenceWithinElementUtil<IXmlToken>
. The SetText
methods provide a factory method to create an appropriate token to replace the existing element.
X
XmlAttributeContainerExtensions
See also: IXmlAttribute, IXmlAttributeContainer
Gets an attribute from an instance of IXmlAttributeContainer
either of a specific derived type, or matching a predicate, or based on name (including namespace prefix, if specified).
XmlAttributeExtension
See also: IXmlAttribute
Helper methods to get information about the unquoted text of an instance of IXmlAttribute
. GetUnquotedText
will return the unquoted text, as well as the tree range of the value. It is better to use the properties on IXmlValueToken
, as that implementation will cache the values for repeated calls. GetUnquotedValueRange
returns the range of the unquoted value, relative to the document the XML PSI is hosted inside (this might be an XML file, or an XML island inside another doucment).
XmlAttributeExtensions
See also: IXmlAttribute
Convenience method. Will remove the given attribute from its parent tag via IXmlTag.RemoveAttribute()
, or directly removes it from the tree if it's not a child of a tag.
XmlAttributeUtil
See also: IXmlAttribute
Helper methods for working with XML attributes. SetValue
replaces an attributes value by creating a new instance of IXmlAttributeValue
and modifying the tree (it takes the write-lock, so the caller doesn't have to). The other methods return the range of the unquoted value of the attribute, relative to the tree, and relative to the document. These may be different if the XML IFile
is not the primary PSI tree in the file.
XmlElementFactoryExtensions
See also: IXmlAttribute, IXmlElementFactory, IXmlFile
Creates an instance of IXmlFile
or IXmlAttribute
using the passed in IXmlElementFactory
without putting the created file into a sandbox. The resulting node is essentially not fully initialised - it is not part of a file, and not part of a sandbox, either.
XmlReferenceUtil
Helper method that will recursively walk down the PSI tree starting at element
, looking for a particular reference, as decided by predicate
.
XmlTagExtensions
See also: IXmlAttribute, IXmlIdentifier, IXmlTag
Convenience methods that call into properties and methods on IXmlTag
and child nodes. E.g. GetTagName
returns tag.Header.Name.XmlName
, and Remove
finds the tag's parent IXmlTagContainer
and calls IXmlTagContainer.RemoveTag
.
XmlTagUtil
See also: IXmlTag
Helper methods for working with IXmlTag
.
CanBeEmptyTag
returnstrue
if the given tag doesn't have any significant children (e.g. anything other than whitespace), and checks that the current XML language supports converting this tag to be empty, by callingIXmlLanguageSupport.CanMakeTagEmpty
.MakeCompound
converts an empty, self-closed tag to an empty tag with a header and footer, (e.g.<foo></foo>
). Modifies the tree, taking the write-lock.MakeEmpty
removes all inner nodes and the footer, and converts the header into a self-closing tag (e.g.<foo />
). Modifies the tree, taking the write-lock.
XPathUtil
See also: IXmlTagContainer
Walks the child tags of the container
until it has satisfied the given XPath-like expression. The xpath
parameter isn't really an XPath string, but XPath-like. The path must be relative to the current container
, and walks down the tree comparing the tag names at each level with the current path segment name. If the name matches, or the path segment is the wildcard symbol *
, the walk continues. The tags that match the last path segment name are returned as part of the list.