本文整理汇总了C#中IDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# IDeclaration类的具体用法?C# IDeclaration怎么用?C# IDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDeclaration类属于命名空间,在下文中一共展示了IDeclaration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CalculateQuickSearchTexts
protected override IList<string> CalculateQuickSearchTexts(IDeclaration declaration) {
if (!declaration.IsValid())
return EmptyList<string>.InstanceList;
var owner = declaration as IInterfaceQualificationOwner;
if (owner != null && owner.InterfaceQualificationReference != null)
return new[] { owner.GetDeclaredShortName(), owner.InterfaceQualificationReference.ShortName };
var constructorDeclaration = declaration as IConstructorDeclaration;
if (constructorDeclaration != null)
return new[] { constructorDeclaration.DeclaredName, "new", "ctor" };
var indexerDeclaration = declaration as IIndexerDeclaration;
if (indexerDeclaration != null)
return new[] { indexerDeclaration.DeclaredName, "this" };
var destructorDeclaration = declaration as IDestructorDeclaration;
if (destructorDeclaration != null)
return new[] { destructorDeclaration.DeclaredName, "Finalize" };
var operatorDeclaration = declaration as IOperatorDeclaration;
if (operatorDeclaration != null)
return new[] { operatorDeclaration.DeclaredName, "operator" };
var eventDeclaration = declaration as IEventDeclaration;
if (eventDeclaration != null)
return new[] { eventDeclaration.DeclaredName, "event" };
return base.CalculateQuickSearchTexts(declaration);
}
开发者ID:mnaoumov,项目名称:ForTea,代码行数:30,代码来源:T4CSharpCodeStructureAspects.cs
示例2: PsiIntentionResult
public PsiIntentionResult(List<ITemplateFieldHolder> holders, IDeclaration declaration, ITreeNode anchor, DocumentRange range)
{
myDeclaration = declaration;
myHolders = holders;
myPrefferedSelection = range;
myAnchor = anchor;
}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:7,代码来源:PsiIntentionResult.cs
示例3: Reference
public Reference(Cursor c, IDeclaration decl, ISymbolTable table)
{
_cursor = c;
_decl = decl;
_table = table;
_location = new CodeLocation(c.Extent.Start); //todo - replace for doc tracking
}
开发者ID:JadeHub,项目名称:Jade,代码行数:7,代码来源:Reference.cs
示例4: SetUp
public void SetUp()
{
mocks = new MockRepository();
objectBuilder = mocks.DynamicMock<IObjectBuilder<MyClass>>();
operable = mocks.DynamicMultiMock<IDeclaration<MyClass>>(typeof(IOperable<MyClass>));
func = x => x.Float = 1f;
propertyExpression = x => x.IntGetterOnly;
}
开发者ID:asiftasleem,项目名称:nbuilder,代码行数:8,代码来源:OperableExtensionTests.cs
示例5: FindOrAddParentNode
private DeclarationViewModel FindOrAddParentNode(IDeclaration decl)
{
if(decl is NamespaceDecl)
return FindOrAddNamespaceNode(decl as NamespaceDecl);
if(decl is ClassDecl)
return FindOrAddClassNode(decl as ClassDecl);
return null;
}
开发者ID:JadeHub,项目名称:Jade,代码行数:8,代码来源:ContextPaneViewModel.cs
示例6: NTriplesIntentionResult
public NTriplesIntentionResult(
List<ITemplateFieldHolder> holders, IDeclaration declaration, ITreeNode anchor, DocumentRange range)
{
this.myDeclaration = declaration;
this.myHolders = holders;
this.myPreferredSelection = range;
this.myAnchor = anchor;
}
开发者ID:xsburg,项目名称:ReSharper.NTriples,代码行数:8,代码来源:NTriplesIntentionResult.cs
示例7: Check
public void Check(IDeclaration declaration, INamingPolicyProvider namingPolicyProvider, out bool isFinalResult, out NamingConsistencyCheckResult result)
{
isFinalResult = false;
var methodDeclaration = declaration as IMethodDeclaration;
var method = methodDeclaration?.DeclaredElement;
if (method != null)
{
var unityApi = method.GetSolution().GetComponent<UnityApi>();
isFinalResult = unityApi.IsEventFunction(method);
}
result = isFinalResult ? NamingConsistencyCheckResult.OK : null;
}
开发者ID:JetBrains,项目名称:resharper-unity,代码行数:15,代码来源:NamingConsistencyWarningSuppressor.cs
示例8: SetUp
public void SetUp()
{
mocks = new MockRepository();
declarations = new DeclarationQueue<MyClass>(listSize);
declaration1 = mocks.DynamicMock<IDeclaration<MyClass>>();
declaration2 = mocks.DynamicMock<IDeclaration<MyClass>>();
globalDeclaration = mocks.DynamicMock<IGlobalDeclaration<MyClass>>();
using (mocks.Record())
{
declaration1.Stub(x => x.Start).Return(0).Repeat.Any();
declaration1.Stub(x => x.End).Return(10).Repeat.Any();
}
}
开发者ID:asiftasleem,项目名称:nbuilder,代码行数:15,代码来源:DeclarationQueueTests.cs
示例9: CreateContext
public IUnitTestElement CreateContext(string assemblyPath, IDeclaration declaration)
{
var type = (ITypeElement) declaration.DeclaredElement;
var context = GetOrCreateContext(assemblyPath,
declaration.GetProject(),
type.GetClrName().GetPersistent(),
type.GetSubjectString(),
type.GetTags(), type.IsIgnored());
foreach (var child in context.Children)
{
child.State = UnitTestElementState.Pending;
}
_cache.AddContext(type, context);
return context;
}
开发者ID:hennys,项目名称:machine.specifications,代码行数:17,代码来源:ContextFactory.cs
示例10: T4CSharpCodeStructureDeclaredElement
public T4CSharpCodeStructureDeclaredElement(CodeStructureElement parentElement, IDeclaration declaration, CSharpCodeStructureProcessingState state)
: base(parentElement, declaration) {
IDeclaredElement declaredElement = declaration.DeclaredElement;
InitiallyExpanded = true;
if (declaredElement != null && state.Options.BuildInheritanceInformation) {
_inheritanceInformation = InheritanceInformation.FromDeclaredElement(declaredElement);
if (_inheritanceInformation != null) {
var structureDeclaredElement = parentElement as T4CSharpCodeStructureDeclaredElement;
if (structureDeclaredElement != null)
structureDeclaredElement.ChildrenWithInheritance = true;
}
}
_parentRegion = state.Regions.TryPeek();
if (declaredElement != null)
_aspects = new T4CSharpCodeStructureAspects(this, declaration);
}
开发者ID:mnaoumov,项目名称:ForTea,代码行数:19,代码来源:T4CSharpCodeStructureDeclaredElement.cs
示例11: AddDeclaration
public void AddDeclaration(IDeclaration declaration)
{
List<IDeclaration> declarations;
if (declaration.Name != null)
{
string name = declaration.Name.Text;
if (string.IsNullOrEmpty(name))
return;
if (!Declarations.TryGetValue(name, out declarations))
{
declarations = new List<IDeclaration>();
Declarations.Add(name, declarations);
}
}
else
{
declarations = new List<IDeclaration>();
}
var genericsDeclarator = declaration as IGenerics;
if (genericsDeclarator != null)
{
for (int i = 0; i < genericsDeclarator.GenericParameters.Count; i++)
{
var genericArgument = genericsDeclarator.GenericParameters[i];
var genericName = genericArgument.Name.Text;
List<GenericDeclaration> generics;
if (!Generics.TryGetValue(genericName, out generics))
{
generics = new List<GenericDeclaration>();
Generics.Add(genericName, generics);
}
generics.Add(new GenericDeclaration(genericArgument.Name, genericsDeclarator, i, false) { Span = genericArgument.Span });
}
}
if (!declarations.Contains(declaration))
declarations.Add(declaration);
}
开发者ID:cg123,项目名称:xenko,代码行数:42,代码来源:ScopeDeclaration.cs
示例12: Annotate
/// <summary>Checks the declaration documentation.</summary>
/// <param name="declaration">The declaration.</param>
/// <param name="options">The options.</param>
private void Annotate(IDeclaration declaration, ValueAnalysisOptions options)
{
if (!options.AnnotateWithValueAnalysisAttributes && !options.InsertAssertStatements)
{
return;
}
var typeMemberDeclaration = declaration as ITypeMemberDeclaration;
if (typeMemberDeclaration == null)
{
return;
}
var refactoring = new ValueAnalysisRefactoring(typeMemberDeclaration);
refactoring.AnnotateWithValueAnalysisAttributes = options.AnnotateWithValueAnalysisAttributes;
refactoring.InsertAssertStatements = options.InsertAssertStatements;
refactoring.TreatAllMembersAsNonPublic = options.TreatAllMembersAsNonPublic;
refactoring.Execute();
}
开发者ID:jamiebriant,项目名称:agentjohnson,代码行数:24,代码来源:ValueAnalysisRules.cs
示例13: LayoutDocumentationHeader
/// <summary>
/// Builds a xml doc header from the string passed in all set out correctly.
/// </summary>
/// <param name="header">
/// The text to use to build the header.
/// </param>
/// <param name="declaration">
/// The declaration we start with.
/// </param>
/// <returns>
/// A String of the correctly formatted header.
/// </returns>
private static string LayoutDocumentationHeader(string header, IDeclaration declaration)
{
StringBuilder text = new StringBuilder();
text.AppendLine("<member>");
text.AppendLine(header);
text.AppendLine("</member>");
XmlDocument xmlDoc = new XmlDocument { PreserveWhitespace = true };
xmlDoc.LoadXml(text.ToString());
return LayoutDocumentationHeader(xmlDoc.SelectSingleNode("member"), declaration);
}
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:24,代码来源:DeclarationHeader.cs
示例14: GetXmlNodeForDeclaration
/// <summary>
/// Returns the xml for the given declaration or null.
/// </summary>
/// <param name="declaration">
/// The declaration to get the docs for.
/// </param>
/// <returns>
/// An XmlNode of the docs.
/// </returns>
private static XmlNode GetXmlNodeForDeclaration(IDeclaration declaration)
{
IDeclaration declarationTreeNode = declaration;
ITreeNode treeNode = declarationTreeNode is IMultipleDeclarationMember ? declarationTreeNode.Parent.FirstChild : declarationTreeNode.FirstChild;
XmlNode node;
StringBuilder text = new StringBuilder();
text.AppendLine("<member>");
for (ITreeNode child = treeNode.FirstChild; child != null; child = child.NextSibling)
{
if (child.IsNewLine())
{
text.AppendLine(string.Empty);
continue;
}
IDocCommentNode docCommentNode = child as IDocCommentNode;
if (docCommentNode != null)
{
text.Append(docCommentNode.CommentText);
}
}
text.AppendLine("</member>");
try
{
XmlDocument xmlDoc = new XmlDocument { PreserveWhitespace = true };
xmlDoc.LoadXml(text.ToString());
node = xmlDoc.SelectSingleNode("member");
}
catch (XmlException)
{
return null;
}
return node;
}
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:49,代码来源:DeclarationHeader.cs
示例15: CheckDeclarationDocumentation
/// <summary>
/// Checks declaration comment blocks.
/// </summary>
/// <param name="file">
/// The <see cref="ICSharpFile"/> to use.
/// </param>
/// <param name="declaration">
/// The <see cref="IDeclaration"/> to check.
/// </param>
/// <param name="options">
/// <see cref="OrderingOptions"/>Current options that we can reference.
/// </param>
public void CheckDeclarationDocumentation(ICSharpFile file, IDeclaration declaration, DocumentationOptions options)
{
Param.RequireNotNull(file, "file");
Param.RequireNotNull(declaration, "declaration");
Param.Ignore(options);
bool insertMissingElementDocOption = true;
bool documentationTextMustBeginWithACapitalLetter = true;
bool documentationTextMustEndWithAPeriod = true;
bool elementDocumentationMustHaveSummary = true;
bool constructorSummaryDocBeginsWithStandardText = true;
bool destructorSummaryDocBeginsWithStandardText = true;
bool propertyDocumentationMustHaveValueDocumented = true;
bool insertMissingParamTagOption = true;
bool genericTypeParametersMustBeDocumented = true;
if (options != null)
{
insertMissingElementDocOption = options.SA1600ElementsMustBeDocumented;
documentationTextMustBeginWithACapitalLetter = options.SA1628DocumentationTextMustBeginWithACapitalLetter;
documentationTextMustEndWithAPeriod = options.SA1629DocumentationTextMustEndWithAPeriod;
elementDocumentationMustHaveSummary = options.SA1604ElementDocumentationMustHaveSummary;
constructorSummaryDocBeginsWithStandardText = options.SA1642ConstructorSummaryDocumentationMustBeginWithStandardText;
destructorSummaryDocBeginsWithStandardText = options.SA1643DestructorSummaryDocumentationMustBeginWithStandardText;
propertyDocumentationMustHaveValueDocumented = options.SA1609PropertyDocumentationMustHaveValue;
insertMissingParamTagOption = options.SA1611ElementParametersMustBeDocumented;
genericTypeParametersMustBeDocumented = options.SA1618GenericTypeParametersMustBeDocumented;
}
DeclarationHeader declarationHeader = new DeclarationHeader(declaration);
bool formatSummary = false;
if (insertMissingElementDocOption && !Utils.IsRuleSuppressed(declaration, StyleCopRules.SA1600) && declarationHeader.IsMissing)
{
formatSummary = this.InsertMissingDeclarationHeader(file, declaration);
}
if (elementDocumentationMustHaveSummary && !Utils.IsRuleSuppressed(declaration, StyleCopRules.SA1604) && !declarationHeader.HasSummary)
{
formatSummary = formatSummary | this.InsertMissingSummaryElement(declaration);
}
if (formatSummary)
{
this.FormatSummaryElement(declaration);
}
if (declaration is IConstructorDeclaration)
{
if (insertMissingParamTagOption && !Utils.IsRuleSuppressed(declaration, StyleCopRules.SA1611))
{
IConstructorDeclaration constructorDeclaration = declaration as IConstructorDeclaration;
if (constructorDeclaration.ParameterDeclarations.Count > 0)
{
this.InsertMissingParamElement(constructorDeclaration);
}
}
if (constructorSummaryDocBeginsWithStandardText && !Utils.IsRuleSuppressed(declaration, StyleCopRules.SA1642))
{
this.EnsureConstructorSummaryDocBeginsWithStandardText(declaration as IConstructorDeclaration);
}
}
DocumentationRulesConfiguration docConfig = this.GetDocumentationRulesConfig(file);
// However it can be on/off depending on the file so we'd have to cache it per file
bool ruleIsEnabled = docConfig.GetStyleCopRuleEnabled("DocumentationTextMustBeginWithACapitalLetter");
if (documentationTextMustBeginWithACapitalLetter && ruleIsEnabled && !Utils.IsRuleSuppressed(declaration, StyleCopRules.SA1628))
{
this.EnsureDocumentationTextIsUppercase(declaration);
}
ruleIsEnabled = docConfig.GetStyleCopRuleEnabled("DocumentationTextMustEndWithAPeriod");
if (documentationTextMustEndWithAPeriod && ruleIsEnabled && !Utils.IsRuleSuppressed(declaration, StyleCopRules.SA1629))
{
this.EnsureDocumentationTextEndsWithAPeriod(declaration);
}
if (declaration is IDestructorDeclaration)
{
if (destructorSummaryDocBeginsWithStandardText && !Utils.IsRuleSuppressed(declaration, StyleCopRules.SA1643))
{
this.EnsureDestructorSummaryDocBeginsWithStandardText(declaration as IDestructorDeclaration);
}
//.........这里部分代码省略.........
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:101,代码来源:DocumentationRules.cs
示例16: InsertMissingTypeParamElement
/// <summary>
/// Updates the summary to include all <c>typeparam</c> and remove any extra ones and in the correct order.
/// </summary>
/// <param name="declaration">
/// The <see cref="ITypeDeclaration"/> to check and fix.
/// </param>
public void InsertMissingTypeParamElement(IDeclaration declaration)
{
ITypeParametersOwner declaredElement = declaration.DeclaredElement as ITypeParametersOwner;
if (declaredElement == null)
{
return;
}
DeclarationHeader declarationHeader = new DeclarationHeader(declaration);
if (declarationHeader.IsMissing || declarationHeader.IsInherited)
{
return;
}
XmlNode xmlNode = declarationHeader.XmlNode;
Hashtable ht = new Hashtable();
foreach (ITypeParameter parameter in declaredElement.TypeParameters)
{
ht.Add(parameter.ShortName, null);
if (declarationHeader.ContainsTypeParameter(parameter.ShortName))
{
continue;
}
XmlNode parameterNode = CreateTypeParamNode(xmlNode, parameter.ShortName);
XmlNodeList paramNodeList = xmlNode.SelectNodes("//typeparam");
if (paramNodeList != null)
{
XmlNode c = paramNodeList.Count == 0 ? declarationHeader.SummaryXmlNode : paramNodeList.Item(paramNodeList.Count - 1);
xmlNode.InsertAfter(parameterNode, c);
}
}
RemoveTypeParamsNotRequired(xmlNode, ht);
ReorderTypeParams(xmlNode, declaredElement.TypeParameters);
declarationHeader.Update();
}
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:50,代码来源:DocumentationRules.cs
示例17: InsertMissingParamElement
/// <summary>
/// Insert a missing parameter element to the comment.
/// </summary>
/// <param name="declaration">
/// The <see cref="IDeclaration"/> to check and fix.
/// </param>
public void InsertMissingParamElement(IDeclaration declaration)
{
Param.RequireNotNull(declaration, "declaration");
IParametersOwnerDeclaration parametersOwnerDeclaration = declaration as IParametersOwnerDeclaration;
if (parametersOwnerDeclaration == null)
{
return;
}
DeclarationHeader declarationHeader = new DeclarationHeader(declaration);
if (declarationHeader.IsMissing || declarationHeader.IsInherited)
{
return;
}
XmlNode xmlNode = declarationHeader.XmlNode;
Hashtable ht = new Hashtable();
IList<IParameterDeclaration> parameters = parametersOwnerDeclaration.ParameterDeclarations;
if (parameters != null)
{
foreach (IParameterDeclaration parameter in parameters)
{
ht.Add(parameter.DeclaredName, null);
if (declarationHeader.ContainsParameter(parameter.DeclaredName))
{
continue;
}
XmlNodeList paramNodeList = xmlNode.SelectNodes("//param");
if (paramNodeList != null)
{
XmlNode c = paramNodeList.Count == 0 ? declarationHeader.SummaryXmlNode : paramNodeList.Item(paramNodeList.Count - 1);
XmlNode parameterNode = CreateParamNode(xmlNode, parameter);
xmlNode.InsertAfter(parameterNode, c);
}
}
}
RemoveParamsNotRequired(xmlNode, ht);
ReorderParams(xmlNode, parameters);
declarationHeader.Update();
}
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:56,代码来源:DocumentationRules.cs
示例18: InsertMissingSummaryElement
/// <summary>
/// Inserts a missing summary element.
/// </summary>
/// <param name="declaration">
/// The <see cref="IDeclaration"/> to get comment from.
/// </param>
/// <returns>
/// True if the element was inserted.
/// </returns>
public bool InsertMissingSummaryElement(IDeclaration declaration)
{
bool returnValue = false;
DeclarationHeader declarationHeader = new DeclarationHeader(declaration);
if (declarationHeader.IsMissing || declarationHeader.IsInherited)
{
return false;
}
string summaryText = string.Empty;
IContextBoundSettingsStore settingsStore = PsiSourceFileExtensions.GetSettingsStore(null, declaration.GetSolution());
if (settingsStore.GetValue((StyleCopOptionsSettingsKey key) => key.InsertTextIntoDocumentation))
{
string text;
if (declaration is IInterfaceDeclaration)
{
text = declaration.DeclaredName.Substring(1) + " interface";
}
else
{
text = Utils.ConvertTextToSentence(declaration.DeclaredName).ToLower();
}
summaryText = string.Format("The {0}.", text);
}
summaryText = Utils.UpdateTextWithToDoPrefixIfRequired(summaryText, settingsStore);
XmlNode summaryXmlNode = declarationHeader.SummaryXmlNode;
if (declarationHeader.HasSummary)
{
if (declarationHeader.HasEmptySummary)
{
summaryXmlNode.InnerText = summaryText;
declarationHeader.Update();
returnValue = true;
}
}
else
{
XmlNode newChild = CreateNode(declarationHeader.XmlNode, "summary");
newChild.InnerText = summaryText;
declarationHeader.XmlNode.InsertBefore(newChild, declarationHeader.XmlNode.FirstChild);
declarationHeader.Update();
returnValue = true;
}
return returnValue;
}
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:60,代码来源:DocumentationRules.cs
示例19: FormatSummaryElement
/// <summary>
/// Formats a summary element.
/// </summary>
/// <param name="declaration">
/// The <see cref="IDeclaration"/> to format the text for.
/// </param>
public void FormatSummaryElement(IDeclaration declaration)
{
DeclarationHeader declarationHeader = new DeclarationHeader(declaration);
if (declarationHeader.IsMissing || declarationHeader.IsInherited || declarationHeader.HasEmptySummary || !declarationHeader.HasSummary)
{
return;
}
declarationHeader.Update();
}
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:17,代码来源:DocumentationRules.cs
示例20: InsertMissingDeclarationHeader
/// <summary>
/// Insert a summary element if missing.
/// </summary>
/// <param name="file">
/// The <see cref="ICSharpFile"/> to use.
/// </param>
/// <param name="declaration">
/// The <see cref="ITypeDeclaration"/> to check and fix.
/// </param>
/// <returns>
/// True if it inserted a missing header.
/// </returns>
public bool InsertMissingDeclarationHeader(ICSharpFile file, IDeclaration declaration)
{
StyleCopTrace.In(file, declaration);
Param.RequireNotNull(file, "file");
Param.RequireNotNull(declaration, "declaration");
Debug.Assert(declaration.DeclaredElement != null, "declaration.DeclaredElement != null");
bool returnValue = false;
DocumentationRulesConfiguration docConfig = this.GetDocumentationRulesConfig(file);
bool isIFieldDeclaration = declaration is IFieldDeclaration;
AccessRights accessRights = ((IModifiersOwnerDeclaration)declaration).GetAccessRights();
DeclaredElementType elementType = declaration.DeclaredElement.GetElementType();
if ((!isIFieldDeclaration || docConfig.RequireFields) && (accessRights != AccessRights.PRIVATE || !docConfig.IgnorePrivates)
&& (accessRights != AccessRights.INTERNAL || !docConfig.IgnoreInternals))
{
DeclarationHeader.CreateNewHeader(declaration, docConfig);
returnValue = true;
}
return StyleCopTrace.Out(returnValue);
}
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:36,代码来源:DocumentationRules.cs
注:本文中的IDeclaration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论