本文整理汇总了C#中CodeElement类的典型用法代码示例。如果您正苦于以下问题:C# CodeElement类的具体用法?C# CodeElement怎么用?C# CodeElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeElement类属于命名空间,在下文中一共展示了CodeElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddCommentsTo
private static void AddCommentsTo(CodeElement codeElement)
{
if (CodeElementsThatNeedDocComment.Contains(codeElement.Kind))
{
if (string.IsNullOrWhiteSpace(codeElement.GetDocComment()))
{
if (codeElement.IsInherited() || codeElement.OverridesSomething())
{
codeElement.SetDocComment(@"<DOC><inheritdoc/></DOC>");
}
else
{
switch (codeElement.Kind)
{
case vsCMElement.vsCMElementProperty: AddDocCommentToProperty(codeElement as CodeProperty); break;
case vsCMElement.vsCMElementFunction: AddDocCommentToFunction(codeElement as CodeFunction); break;
case vsCMElement.vsCMElementEnum: AddGhostDogCommand(codeElement); break;
case vsCMElement.vsCMElementStruct: AddGhostDogCommand(codeElement); break;
case vsCMElement.vsCMElementInterface: AddDocCommentToInterface(codeElement as CodeInterface); break;
case vsCMElement.vsCMElementEvent: AddGhostDogCommand(codeElement); break;
case vsCMElement.vsCMElementClass: AddDocCommentToClass(codeElement as CodeClass); break;
case vsCMElement.vsCMElementVariable: AddGhostDogCommand(codeElement); break;
}
}
}
}
if (CodeElementsWithChildren.Contains(codeElement.Kind))
{
foreach (CodeElement child in codeElement.Children)
{
AddCommentsTo(child);
}
}
}
示例2: GoToCodeElementHelper
/// <summary>
/// Selects text in the code editor.
/// </summary>
/// <param name="dte">A DTE2 object exposing the Visual Studio automation object model.</param>
/// <param name="element">The CodeElementWrapper object containing the selection.</param>
/// <param name="useTryShow">true to use TryToShow to adjust the code editor window to show the selection, otherwise false.</param>
public static void GoToCodeElementHelper(DTE dte, CodeElement element, bool useTryShow)
{
if (element != null)
{
try
{
TextPoint start = element.StartPoint;
var tx = (TextDocument)dte.ActiveDocument.Object("TextDocument");
int line = start.Line;
int offset = start.LineCharOffset;
if (!useTryShow)
{
tx.Selection.MoveToLineAndOffset(line, offset, false);
}
else
{
start.TryToShow(vsPaneShowHow.vsPaneShowCentered, start);
}
if (!useTryShow)
{
tx.Selection.SelectLine();
}
}
catch (COMException)
{
// Discard the exception that gets thrown when accessing
// a non-code TextDocument, for example a Windows form.
}
}
}
示例3: Process
// ------------------------------------------------------
public void Process(CodeElement element)
{
bool visitChildren = Visit(element);
if (visitChildren)
Process(element.Children);
}
示例4: RenameSymbols
/// <summary>
/// Rename function in scope of parentElement.
/// </summary>
/// <param name="element">Element to rename.</param>
/// <param name="parentElement">Containing element.</param>
/// <param name="elementType">Type of element.</param>
/// <param name="oldName">Old name of element.</param>
/// <param name="newName">New name of element.</param>
public override IRenameResult RenameSymbols(CodeElement element, LuaCodeClass parentElement,
vsCMElement elementType, string oldName, string newName)
{
renameResult = new RenameResult(oldName, newName);
changedCodeElements = new List<CodeElement>();
//Function without parent element could not be renamed
if (element is LuaCodeFunction && parentElement == null)
{
var ex = new InvalidCodeElementException(Resources.InvalidFunctionParentMessage, parentElement);
Trace.WriteLine(ex);
throw ex;
}
//Rename function, function calls or null element by its name
if (element is LuaCodeFunction || element is LuaCodeElement<FunctionCall> || element == null)
{
renameResult = Rename(element, parentElement, oldName, newName);
}
else
{
throw new InvalidCodeElementException(
Resources.InvalidFunctionElementMessage, parentElement);
}
//Set RenameReferences flag to indicates that rename is local or not
renameResult.RenameReferences = !IsLocalDeclaration;
renameResult.ChangedElements = changedCodeElements;
renameResult.Success = true;
return renameResult;
}
示例5: GetCodeElementMembers
private EnvDTE.CodeElements GetCodeElementMembers(CodeElement objCodeElement)
{
EnvDTE.CodeElements colCodeElements = default(EnvDTE.CodeElements);
if (objCodeElement is EnvDTE.CodeNamespace)
{
colCodeElements = ((EnvDTE.CodeNamespace)objCodeElement).Members;
}
else if (objCodeElement is EnvDTE.CodeType)
{
colCodeElements = ((EnvDTE.CodeType)objCodeElement).Members;
}
else if (objCodeElement is EnvDTE.CodeFunction)
{
colCodeElements = ((EnvDTE.CodeFunction)objCodeElement).Parameters;
}
return colCodeElements;
}
示例6: ExamineCodeElement
private static string ExamineCodeElement(CodeElement codeElement, vsCMElement type)
{
return codeElement.Kind == type
? codeElement.Name
: (from CodeElement childElement in codeElement.Children select ExamineCodeElement(childElement, type))
.FirstOrDefault(result => !string.IsNullOrEmpty(result));
}
示例7: CodeFieldInfo
/// <summary>
///
/// </summary>
public CodeFieldInfo(BaseInfo parent, CodeElement item, TypeInfo type)
: base(parent, item as CodeElement2)
{
this._item = item;
this.Access = CMAccess.Public; // ObjectFactory.Convert(this._item.Access);
this._type = type;
}
示例8: MoveToRegionForm
public MoveToRegionForm(CodeElement classElement)
{
this.classElement = classElement;
InitializeComponent();
BindRegionToTreeView();
}
示例9: GetFieldStringFromElement
private static string GetFieldStringFromElement(CodeElement elem)
{
var v = (CodeVariable) elem;
var typeName = GenericNameMangler.MangleTypeName(GetTypeName(v.Parent));
var oftype = GetVariableType(v);
return oftype + " " + typeName + "::" + v.Name;
}
示例10: GetMethodStringFromElement
public static string GetMethodStringFromElement(CodeElement elem)
{
try
{
if (elem.Kind == vsCMElement.vsCMElementFunction)
{
return GetMethodStringFromElement(elem as CodeFunction);
}
if (elem.Kind == vsCMElement.vsCMElementProperty)
{
var getter = ((CodeProperty) elem).Getter;
return GetMethodStringFromElement(getter);
}
if (elem.Kind == vsCMElement.vsCMElementVariable)
{
return GetFieldStringFromElement(elem);
}
}
catch(Exception ex)
{
Core.DebugLog.Debug.WriteDebug("Exception getting Method String : " + ex.ToString());
return null;
}
return null;
}
示例11: Parse
public static VsClass Parse( CodeElement codeElement)
{
var vsClass = new VsClass();
vsClass.Name = codeElement.Name;
var codeClass = (CodeClass) codeElement;
var startPoint = codeClass.StartPoint.CreateEditPoint();
var endPoint = codeClass.EndPoint.CreateEditPoint();
int i = 1;
while( startPoint.LessThan(endPoint))
{
i++;
startPoint.LineDown(1);
}
vsClass.Loc = i;
foreach (CodeElement element in ((CodeClass)codeElement).Members)
{
if (element.Kind == vsCMElement.vsCMElementVariable)
{
vsClass.Variables.Add(VsVariable.Parse(element));
}
else if (element.Kind == vsCMElement.vsCMElementFunction)
{
CodeFunction function = element as CodeFunction;
if (function.FunctionKind == vsCMFunction.vsCMFunctionConstructor)
vsClass.Constructors.Add(VsConstructors.Parse(function));
else
vsClass.Methods.Add(VsMethod.Parse(function));
}
}
return vsClass;
}
示例12: Visit
protected override void Visit(CodeElement element)
{
//结果已经找到,退出访问。
if (_result != null) return;
base.Visit(element);
}
示例13: RenameSymbols
/// <summary>
/// Rename element in scope of parentElement.
/// </summary>
/// <param name="element">Element to rename.</param>
/// <param name="parentElement">Containing element.</param>
/// <param name="elementType">Type of element.</param>
/// <param name="oldName">Old name of element.</param>
/// <param name="newName">New name of element.</param>
public IRenameResult RenameSymbols(CodeElement element, LuaCodeClass parentElement, vsCMElement elementType, string oldName, string newName)
{
if (CodeElementRename == null)
{
throw new InvalidStrategyException(CodeElementRename);
}
return CodeElementRename.RenameSymbols(element, parentElement, elementType, oldName, newName);
}
示例14: getCodeElements
public CodeElements getCodeElements(CodeElement ce)
{
if (ce is CodeNamespace) return ((CodeNamespace) ce).Members;
if (ce is CodeClass) return ((CodeClass) ce).Members;
if (ce is CodeType ) return ((CodeType )ce).Members;
if (ce is CodeFunction ) return ((CodeFunction )ce).Parameters ;
return null;
}
示例15: CreateNodeFactoryFromCodeElement
internal static CodeElementNodeFactory CreateNodeFactoryFromCodeElement(CodeElement element)
{
if (element is CodeNamespace)
{
return new CodeNamespaceNodeFactory(element as CodeNamespace);
}
if (element is CodeClass2)
{
return new CodeClassNodeFactory(element as CodeClass2);
}
if (element is CodeInterface2)
{
return new CodeInterfaceNodeFactory(element as CodeInterface2);
}
if (element is CodeProperty)
{
return new CodePropertyNodeFactory(element as CodeProperty);
}
if (element is CodeFunction2)
{
return new CodeMethodNodeFactory(element as CodeFunction2);
}
if (element is CodeEvent)
{
return new CodeEventNodeFactory(element as CodeEvent);
}
if (element is CodeVariable2)
{
return new CodeVariableNodeFactory(element as CodeVariable2);
}
if (element is CodeEnum)
{
return new CodeEnumNodeFactory(element as CodeEnum);
}
if (element is CodeAttribute2)
{
return new CodeAttributeNodeFactory(element as CodeAttribute2);
}
if (element is CodeDelegate2)
{
return new CodeDelegateNodeFactory(element as CodeDelegate2);
}
if (element is CodeParameter2)
{
return new CodeParameterNodeFactory(element as CodeParameter2);
}
if (element is CodeAttributeArgument)
{
return new CodeAttributeArgumentNodeFactory(element);
}
if (element is CodeStruct2)
{
return new CodeStructNodeFactory(element as CodeStruct2);
}
return new CodeElementNodeFactory(element);
}