本文整理汇总了C#中LanguageElement类的典型用法代码示例。如果您正苦于以下问题:C# LanguageElement类的具体用法?C# LanguageElement怎么用?C# LanguageElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LanguageElement类属于命名空间,在下文中一共展示了LanguageElement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetClassBaseType
} // IsClass
/// <summary>
/// Get class base type
/// </summary>
private static TypeReferenceExpression GetClassBaseType(LanguageElement classElement)
{
LanguageElement current = classElement.FirstDetail;
while (current != null && !IsClass(current))
current = current.NextSibling;
return (TypeReferenceExpression)current;
} // GetClassBaseType
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:12,代码来源:EasyGotoPlugIn.cs
示例2: IsValidReferenceAndQualifier
private bool IsValidReferenceAndQualifier(LanguageElement activeRerence, out ITypeElement callerType, out Expression qualifier)
{
qualifier = null;
callerType = null;
if (!(activeRerence is IHasQualifier))
return false;
// should be undeclared....
IElement declaration = activeRerence.GetDeclaration(false);
if (declaration != null)
return false;
qualifier = (activeRerence as IHasQualifier).Qualifier;
if (qualifier is MethodReferenceExpression)
qualifier = (qualifier as MethodReferenceExpression).Qualifier;
if (qualifier == null)
return false;
callerType = qualifier.Resolve(ParserServices.SourceTreeResolver) as ITypeElement;
if (callerType == null)
return false;
return true;
}
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:25,代码来源:PlugIn1.cs
示例3: Scan
public void Scan()
{
_ElementType = LanguageElementType.Unknown;
_ElementsFound = 0;
_TopNode = null;
CodeRush.Source.IterateNodesInSelection(NodeIterator);
}
开发者ID:modulexcite,项目名称:CR_MultiSelect,代码行数:7,代码来源:SelectionScanner.cs
示例4: IsMethodCall
private bool IsMethodCall(LanguageElement Item)
{
if (Item is MethodCall)
{
// Calls which discard any returned value.
return true;
}
if (Item is MethodCallExpression)
{
// Method calls which are themselves passed to other methods.
return true;
}
// C# requires parenthesis for it's method calls. This makes identifying method calls very easy.
// Other languages (VB.Net for example) do not share this requirement.
// References to Methods and Variables end up looking exactly the same to the parser.
// ElementReferenceExpressions may potentially refer to Methods.
if (!(Item is ElementReferenceExpression))
return false;
// This forces us to locate the declaration of the item the reference points at.
// Once there we can confirm if the Item in question is a Method.
if (!(Item.GetDeclaration() is IMethodElement))
return false;
// Finally we need to confirm that the method reference is in fact a call.
// We do this by eliminating the other purpose of a method reference: That of a Method pointer.
// No parent AddressOf operator. Therefore not a method pointer.
if (!(Item.Parent is AddressOfExpression))
return true;
return false;
}
开发者ID:RoryBecker,项目名称:CodeRushPluginExamples,代码行数:31,代码来源:PlugIn1.cs
示例5: GetAllPropertyReferences
private static FileSourceRangeCollection GetAllPropertyReferences(LanguageElement startElement)
{
FileSourceRangeCollection allReferences = new FileSourceRangeCollection();
Property property;
PrimitiveExpression primitiveExpression;
if (!GetPrimitiveExpressionAndProperty(startElement, out primitiveExpression, out property))
return allReferences;
// Add references found...
IElementCollection allPropertyReferences = property.FindAllReferences();
foreach (IElement element in allPropertyReferences)
allReferences.Add(new FileSourceRange(element.FirstFile as SourceFile, element.FirstNameRange));
// Add the contents of the string primitive...
SourceRange primitiveRange = primitiveExpression.NameRange;
int nameStart = primitiveExpression.Name.IndexOf(property.Name);
int nameEndMargin = primitiveExpression.Name.Length - property.Name.Length - nameStart;
primitiveRange.Start.Offset += nameStart;
primitiveRange.End.Offset -= nameEndMargin;
allReferences.Add(new FileSourceRange(primitiveExpression.FileNode, primitiveRange));
// Add the NameRange of the property declaration itself....
allReferences.Add(new FileSourceRange(property.FileNode, property.NameRange));
return allReferences;
}
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:27,代码来源:PlugIn1.cs
示例6: PromoteIfReference
private LanguageElement PromoteIfReference(LanguageElement element)
{
if (element.ElementType == LanguageElementType.MethodReferenceExpression)
if (element.Parent.ElementType == LanguageElementType.MethodCallExpression)
return element.Parent;
return element;
}
开发者ID:RoryBecker,项目名称:CR_ReverseArgs,代码行数:8,代码来源:PlugIn1.cs
示例7: GetNamespaceReference
private ElementReferenceExpression GetNamespaceReference(LanguageElement element)
{
MethodReferenceExpression methodReference = element as MethodReferenceExpression;
MethodCall methodCall = methodReference.Parent as MethodCall;
ElementReferenceExpression classReference = methodReference.Nodes[0] as ElementReferenceExpression;
ElementReferenceExpression namespaceReference = classReference.Nodes[0] as ElementReferenceExpression;
return namespaceReference;
}
开发者ID:modulexcite,项目名称:CR_UseExtensionMethod,代码行数:8,代码来源:PlugIn1.cs
示例8: events_LanguageElementActivated
private void events_LanguageElementActivated(LanguageElementActivatedEventArgs ea)
{
LanguageElement activeMember = CodeRush.Source.ActiveMember;
if (lastMember == activeMember)
return;
lastMember = activeMember;
ShowCode();
}
开发者ID:modulexcite,项目名称:CR_TranslationToolWindow,代码行数:8,代码来源:ToolWindow1.cs
示例9: GetBestLocation
public SourcePoint GetBestLocation(LanguageElement element)
{
int smallestLineDeltaSoFar = int.MaxValue;
int smallestOffsetDeltaSoFar = int.MaxValue;
ElementLocation location = this;
SourcePoint result = SourcePoint.Empty;
LanguageElement parent = null;
while (location != null && element != null)
{
CaretVector vector = location._Vector;
int lineDeltaSize = Math.Abs(vector.LineDelta);
int offsetDeltaSize = Math.Abs(vector.OffsetDelta);
if (lineDeltaSize < smallestLineDeltaSoFar || (lineDeltaSize == smallestLineDeltaSoFar && offsetDeltaSize < smallestOffsetDeltaSoFar))
{
// Found a smaller vector...
SourcePoint newPosition = GetSourcePoint(element, vector);
if (newPosition != SourcePoint.Empty)
{
result = newPosition;
smallestLineDeltaSoFar = lineDeltaSize;
smallestOffsetDeltaSoFar = offsetDeltaSize;
if (lineDeltaSize == 0 && offsetDeltaSize == 0)
if (vector.ElementPosition != ElementPosition.LastDetailEnd || element.ElementType != LanguageElementType.Method && element.ElementType != LanguageElementType.Property)
return result;
}
}
location = location._Child;
parent = element;
element = GetChildElement(element, location);
if (location != null && element == null)
{
// We were expecting a child but found nothing...
if (location._ElementType == LanguageElementType.Parameter)
{
Method method = parent as Method;
if (method != null)
return method.ParamOpenRange.End;
else
{
Property property = parent as Property;
if (property != null)
return property.NameRange.End;
}
}
else
{
SourcePoint newDefaultPosition = GetDefaultPosition(parent);
if (newDefaultPosition != SourcePoint.Empty)
return newDefaultPosition;
}
}
}
return result;
}
开发者ID:modulexcite,项目名称:CR_SuperSiblingNav,代码行数:58,代码来源:ElementLocation.cs
示例10: GetTypeReference
/// <summary>
/// Gets the type reference pointed to by a qualifying namespace reference.
/// </summary>
private static TypeReferenceExpression GetTypeReference(LanguageElement namespaceReference)
{
LanguageElement parentTypeReference = namespaceReference.Parent;
while (parentTypeReference is TypeReferenceExpression && parentTypeReference.IsDetailNode && parentTypeReference.Parent != null && parentTypeReference.Parent is TypeReferenceExpression)
parentTypeReference = parentTypeReference.Parent;
if (parentTypeReference is TypeReferenceExpression /* && !parentTypeReference.IsDetailNode */) // We've found the class reference...
return (TypeReferenceExpression)parentTypeReference;
return null;
}
开发者ID:modulexcite,项目名称:CR_SyncNamespacesToFolder,代码行数:12,代码来源:PlugIn1.cs
示例11: CurrentNamespace
private string CurrentNamespace(LanguageElement element)
{
var names = new List<string>();
while (element != null && element.ElementType == LanguageElementType.Namespace)
{
names.Add(element.Name);
element = element.Parent;
}
return string.Join(".", names.Reverse<string>().ToArray());
}
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:10,代码来源:Refactor_UpdateNamespacePlugIn.cs
示例12: IsValidSelection
protected override bool IsValidSelection(LanguageElement element, TextViewSelection selection)
{
if ((element == null) || (selection == null))
return false;
if (selection.Exists)
return false;
var creationExpression = element.Parent as ObjectCreationExpression;
return creationExpression != null && element.GetDeclaration() == null;
}
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:10,代码来源:DeclareClassInSpecificProject.cs
示例13: GetAssignmentExpression
private static AssignmentExpression GetAssignmentExpression(LanguageElement element)
{
// Rory is right. ea.Element will not always be equal to CodeRush.Source.Active.
// Also, CodeProviders can be called programmatically, targeting other places.
// Rory recommends always exhausting the ea.Xxxxxxx methods and properties, before looking elsewhere.
AssignmentExpression assignmentExpression = element as AssignmentExpression;
if (assignmentExpression == null)
assignmentExpression = element.GetParent(LanguageElementType.AssignmentExpression) as AssignmentExpression;
return assignmentExpression;
}
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:10,代码来源:PlugIn1.cs
示例14: IsApproveCall
private static bool IsApproveCall(LanguageElement element)
{
if (element.ElementType == LanguageElementType.MethodCall && element.Name.Contains("Approve"))
return true;
if (element.Parent != null)
return IsApproveCall(element.Parent);
return false;
}
开发者ID:chrisortman,项目名称:approval_tests,代码行数:10,代码来源:ApprovalTestsPlugin.cs
示例15: AddAttribute
private void AddAttribute(LanguageElement element, string AttributeName)
{
var Builder = new ElementBuilder();
var Attribute = Builder.BuildAttribute(AttributeName);
var Section = Builder.BuildAttributeSection();
Section.AddAttribute(Attribute);
var Code = CodeRush.CodeMod.GenerateCode(Section, false);
SourcePoint InsertionPoint = new SourcePoint(element.Range.Start.Line, 1);
CodeRush.Documents.ActiveTextDocument.QueueInsert(InsertionPoint, Code);
}
开发者ID:modulexcite,项目名称:CR_AddDataContract,代码行数:10,代码来源:PlugIn1.cs
示例16: IsCaretOnPairedHtmlTag
/// <summary>
/// Returns true if the specified caret position is located inside either the start or end tag of the specified HtmlElement.
/// </summary>
private static bool IsCaretOnPairedHtmlTag(LanguageElement element, SourcePoint caret)
{
DevExpress.CodeRush.StructuralParser.HtmlElement htmlElement = element as DevExpress.CodeRush.StructuralParser.HtmlElement;
if (htmlElement == null) // Not an HtmlElement
return false;
if (htmlElement.CloseTagNameRange == SourceRange.Empty) // Not a paired Html tag.
return false;
return htmlElement.NameRange.Contains(caret) || htmlElement.CloseTagNameRange.Contains(caret);
}
开发者ID:modulexcite,项目名称:CR_ElementTagTabber,代码行数:14,代码来源:PlugIn1.cs
示例17: GetNamespaceForElement
private string GetNamespaceForElement(LanguageElement element)
{
IElement parent = element.Parent;
while (parent != null && parent.ElementType != LanguageElementType.Namespace)
{
parent = parent.Parent;
}
return parent == null ? string.Empty : parent.Name;
}
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:11,代码来源:MoveTypeToFileInSpecificProjectPlugin.cs
示例18: GetActiveProperty
// Private implementation
private Property GetActiveProperty(LanguageElement element)
{
if (element == null)
return null;
Property property = element as Property;
if (property == null)
property = element.GetParent(LanguageElementType.Property) as Property;
return property;
}
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:12,代码来源:ConvertPropertyPlugIn.cs
示例19: IsAvailable
internal bool IsAvailable(LanguageElement element)
{
return (element.ElementType == LanguageElementType.MethodCallExpression
&& element.Name == "getElementById")
|| (element.ElementType == LanguageElementType.ElementReferenceExpression
&& (element.Name == "value"
|| element.Name == "checked")
&& element.NextNode.ElementType == LanguageElementType.MethodCallExpression
&& element.NextNode.Name == "getElementById");
}
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:11,代码来源:JqueryPlugin.cs
示例20: Invalidate
/// <summary>
/// Force a redraw of the class which contains the given language element
/// </summary>
/// <param name="element">what to invalidate</param>
internal static void Invalidate(LanguageElement element)
{
if (element != null)
{
TextView view = element.View as TextView;
view.Invalidate(element);//(element.StartLine - 1, 0, element.EndLine + 1, 0);
}
else
{
CodeRush.TextViews.Active.Invalidate();
}
}
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:16,代码来源:DxCoreUtils.cs
注:本文中的LanguageElement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论