本文整理汇总了C#中ITreeNode类的典型用法代码示例。如果您正苦于以下问题:C# ITreeNode类的具体用法?C# ITreeNode怎么用?C# ITreeNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITreeNode类属于命名空间,在下文中一共展示了ITreeNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessBeforeInterior
/// <summary>
/// Processes a node, before its descendants are processed.
/// </summary>
/// <param name="element">The node to process.</param>
public override void ProcessBeforeInterior(ITreeNode element) {
string attributeId = GetHighlightingAttributeId(element);
if (attributeId != null) {
DocumentRange range = element.GetHighlightingRange();
AddHighlighting(new HighlightingInfo(range, new PredefinedHighlighting(attributeId, range)));
}
}
示例2: GetComponentRegistrations
public override IEnumerable<IComponentRegistration> GetComponentRegistrations(ITreeNode registrationRootElement)
{
IStructuralMatchResult match = Match(registrationRootElement);
if (match.Matched)
{
var statements = match.GetMatchedElementList("statements").Cast<ICSharpStatement>();
var collectedTypes = statements.SelectMany(statement =>
{
var returnTypeCollector = new ReturnTypeCollector(new UniversalContext(statement.GetPsiModule()));
statement.ProcessThisAndDescendants(returnTypeCollector);
return returnTypeCollector.CollectedTypes;
});
foreach (var type in collectedTypes)
{
var declaredType = type as IDeclaredType;
if (declaredType != null)
{
var typeElement = declaredType.GetTypeElement();
if (typeElement != null)
{
yield return new ServiceRegistration(registrationRootElement, typeElement);
}
}
}
}
}
示例3: GetComponentRegistrations
public override IEnumerable<IComponentRegistration> GetComponentRegistrations(ITreeNode registrationRootElement)
{
IStructuralMatchResult match = Match(registrationRootElement);
if (match.Matched)
{
var argument = match.GetMatchedElement(ElementName) as ICSharpArgument;
if (argument == null)
{
yield break;
}
// match typeof() expressions
var typeOfExpression = argument.Value as ITypeofExpression;
if (typeOfExpression != null)
{
var typeElement = ((IDeclaredType)typeOfExpression.ArgumentType).GetTypeElement();
if (typeElement == null) // can happen if the typeof() expression is empty
{
yield break;
}
yield return new ComponentRegistration(registrationRootElement, typeElement);
}
}
}
示例4: CodeMustNotContainMultipleWhitespaceInARow
/// <summary>
/// The code must not contain multiple whitespace in a row.
/// </summary>
/// <param name="node">
/// The node.
/// </param>
public void CodeMustNotContainMultipleWhitespaceInARow(ITreeNode node)
{
for (ITreeNode currentNode = node; currentNode != null; currentNode = currentNode.NextSibling)
{
if (currentNode is ITokenNode)
{
ITokenNode currentToken = currentNode as ITokenNode;
ITokenNode previousToken = currentToken.GetPrevToken();
if (previousToken != null)
{
if (currentToken.GetTokenType() == CSharpTokenType.WHITE_SPACE && previousToken.GetTokenType() == CSharpTokenType.WHITE_SPACE)
{
using (WriteLockCookie.Create(true))
{
LowLevelModificationUtil.DeleteChild(currentToken);
}
}
}
}
if (currentNode.FirstChild != null)
{
this.CodeMustNotContainMultipleWhitespaceInARow(currentNode.FirstChild);
}
}
}
示例5: TreeConnection
public TreeConnection(ITreeNode ignParent, ITreeNode ignChild, List<DPoint> lstPt)
: this()
{
IgnChild = ignChild;
IgnParent = ignParent;
LstPt = lstPt;
}
示例6: GetComponentRegistrations
public override IEnumerable<IComponentRegistration> GetComponentRegistrations(ITreeNode registrationRootElement)
{
// This entire thing is one big hack. Need to come back to it one day :)
// There is (currently) no way to create a pattern that would match the Bind() call with implicit this in ReSharper SSR.
// Therefore I'm only matching by the method name only, and later verifying that the method invocation's qualifier
// is indeed derived from global::Ninject.Syntax.IBindingRoot
if (!IsNinjectBindCall(registrationRootElement))
{
yield break;
}
IExpressionStatement statement = GetParentExpressionStatemenmt(registrationRootElement);
if (statement == null)
{
yield break;
}
foreach (var toPattern in toPatterns)
{
var implementedByRegistration = toPattern.GetComponentRegistrations(statement.Expression)
.Cast<ComponentRegistration>()
.FirstOrDefault();
if (implementedByRegistration != null)
{
foreach (var registration in DoCreateRegistrations(statement.Expression).OfType<ComponentRegistration>())
{
registration.Implementation = implementedByRegistration.ServiceType;
yield return registration;
}
}
}
}
示例7: IsAssignment
private static bool IsAssignment(ITreeNode referenceExpression)
{
var binaryexpression = referenceExpression.Parent as IBinaryExpression;
return binaryexpression != null &&
binaryexpression.LeftOperand == referenceExpression &&
IsAssignmentImpl(binaryexpression);
}
示例8: PrintTree
private static void PrintTree(IDomainTree domainTree, ITreeNode node, String tab = "")
{
var outputAttributeId = domainTree.Attributes.Count - 1;
if (node.IsLeaf())
{
var values = domainTree.GetAllSymbolicValuesOfAttribute(SymbolicDomainDataParams.CreateIt(node.Data, outputAttributeId));
if (values.Length == 0)
{
Console.WriteLine("{0}\t{1} = \"null\";", tab, domainTree.Attributes[outputAttributeId]);
}
else
{
Console.WriteLine("{0}\t{1} = \"{2}\";", tab, domainTree.Attributes[outputAttributeId],
domainTree.Domain[outputAttributeId][values[0]]);
}
return;
}
var numvalues = node.Children.Length;
for (var i = 0; i < numvalues; i++)
{
Console.WriteLine(tab + "if( " + domainTree.Attributes[node.TestAttribute] + " == \"" +
domainTree.Domain[node.TestAttribute][i] + "\") {");
PrintTree(domainTree, node.Children[i], tab + "\t");
if (i != numvalues - 1)
Console.Write(tab + "} else ");
else
Console.WriteLine(tab + "}");
}
}
示例9: GetNodePairs
private static void GetNodePairs(ITreeNode firstNode, ITreeNode lastNode, IList<FormattingRange> list)
{
var firstChild = firstNode;
var lastChild = lastNode;
var commonParent = firstNode.FindCommonParent(lastNode);
while (firstChild != null && firstChild.Parent != commonParent)
{
firstChild = firstChild.Parent;
}
while (lastChild != null && lastChild.Parent != commonParent)
{
lastChild = lastChild.Parent;
}
Assertion.Assert(firstChild != null, "firstChild != null");
Assertion.Assert(lastChild != null, "lastChild != null");
var node = firstChild;
while (node != null && node != lastChild.NextSibling)
{
if (!node.IsWhitespaceToken())
{
GetNodePairs(node, list, commonParent);
}
node = node.NextSibling;
}
}
示例10: HasReference
// Same
public bool HasReference(ITreeNode element, ICollection<string> names)
{
var literal = element as ILiteralExpression;
if (literal != null && literal.ConstantValue.Value is string)
return names.Contains((string)literal.ConstantValue.Value);
return false;
}
示例11: GetComponentRegistrations
public override IEnumerable<IComponentRegistration> GetComponentRegistrations(ITreeNode registrationRootElement)
{
var parentExpression = registrationRootElement.GetParentExpression<IExpressionStatement>();
if (parentExpression == null)
{
yield break;
}
IStructuralMatchResult match = Match(registrationRootElement);
if (match.Matched)
{
var expression = match.GetMatchedElement<ICSharpExpression>("expression");
if (IsResolvedToObject(expression))
{
yield break;
}
IEnumerable<IComponentRegistration> componentRegistrations = GetRegistrationsFromExpression(registrationRootElement, expression);
IEnumerable<FilteredRegistrationBase> basedOnRegistrations = basedOnPatterns.SelectMany(
basedOnPattern => basedOnPattern.GetBasedOnRegistrations(parentExpression.Expression)).ToList();
var registrations = componentRegistrations.Concat(basedOnRegistrations).ToList();
if (registrations.Any())
{
yield return new CompositeRegistration(registrationRootElement, registrations);
}
}
}
示例12: ProcessBeforeInterior
public void ProcessBeforeInterior(ITreeNode element)
{
var declaration = element as IDeclaration;
if (declaration == null)
return;
var declaredElement = declaration.DeclaredElement;
if (declaredElement == null || declaredElement.ShortName == SharedImplUtil.MISSING_DECLARATION_NAME)
return;
IUnitTestElement testElement = null;
var testClass = declaredElement as IClass;
if (testClass != null)
testElement = ProcessTestClass(testClass);
var testMethod = declaredElement as IMethod;
if (testMethod != null)
testElement = ProcessTestMethod(testMethod);
if (testElement != null)
{
var nameRange = declaration.GetNameDocumentRange().TextRange;
var documentRange = declaration.GetDocumentRange().TextRange;
if (nameRange.IsValid && documentRange.IsValid)
{
var disposition = new UnitTestElementDisposition(testElement, psiFile.GetSourceFile().ToProjectFile(),
nameRange, documentRange);
consumer(disposition);
}
}
}
示例13: InteriorShouldBeProcessed
public bool InteriorShouldBeProcessed(ITreeNode element)
{
if (element is ITypeMemberDeclaration)
return (element is ITypeDeclaration);
return true;
}
示例14: GetComponentRegistrations
/// <summary>
/// The get component registrations.
/// </summary>
/// <param name="registrationRootElement">
/// The registration root element.
/// </param>
/// <returns>
/// </returns>
public override IEnumerable<IComponentRegistration> GetComponentRegistrations(ITreeNode registrationRootElement)
{
IStructuralMatchResult match = Match(registrationRootElement);
if (match.Matched)
{
var invocationExpression = match.MatchedElement as IInvocationExpression;
if (invocationExpression == null)
{
yield break;
}
if (invocationExpression.TypeArguments.Count > 0)
{
foreach (IComponentRegistration registration in FromGenericArguments(invocationExpression))
{
yield return registration;
}
}
else
{
foreach (IComponentRegistration registration in FromArguments(invocationExpression))
{
yield return registration;
}
}
}
}
示例15: GetComponentRegistrations
public override IEnumerable<IComponentRegistration> GetComponentRegistrations(ITreeNode registrationRootElement)
{
IExpressionStatement parentExpression = GetParentExpressionStatemenmt(registrationRootElement);
if (parentExpression == null)
{
yield break;
}
IStructuralMatchResult match = Match(registrationRootElement);
if (match.Matched)
{
var arguments = match.GetMatchedElementList("assemblies").Cast<ICSharpArgument>();
IEnumerable<IModule> modules = arguments.SelectNotNull(argument => ModuleExtractor.GetTargetModule(argument.Value));
foreach (IModule module in modules)
{
var registration = new ModuleBasedOnRegistration(module, new DefaultScanAssemblyRegistration(registrationRootElement));
var basedOnRegistrations = BasedOnPatterns.SelectMany(
basedOnPattern => basedOnPattern.GetBasedOnRegistrations(parentExpression.Expression));
yield return new CompositeRegistration(registrationRootElement, registration, basedOnRegistrations.ToArray());
}
}
}