本文整理汇总了C#中IDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# IDeclaration类的具体用法?C# IDeclaration怎么用?C# IDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDeclaration类属于命名空间,在下文中一共展示了IDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: PsiIntentionResult
public PsiIntentionResult(List<ITemplateFieldHolder> holders, IDeclaration declaration, ITreeNode anchor, DocumentRange range)
{
myDeclaration = declaration;
myHolders = holders;
myPrefferedSelection = range;
myAnchor = anchor;
}
示例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
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
//.........这里部分代码省略.........