本文整理汇总了C#中ICSharpCode.NRefactory.CSharp.Resolver.CSharpResolver类的典型用法代码示例。如果您正苦于以下问题:C# CSharpResolver类的具体用法?C# CSharpResolver怎么用?C# CSharpResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CSharpResolver类属于ICSharpCode.NRefactory.CSharp.Resolver命名空间,在下文中一共展示了CSharpResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveConstructor
public IMethod ResolveConstructor(ITypeResolveContext context)
{
CSharpResolver r = new CSharpResolver(context);
IType type = attributeType.Resolve(context);
int totalArgumentCount = 0;
if (positionalArguments != null)
totalArgumentCount += positionalArguments.Count;
if (namedCtorArguments != null)
totalArgumentCount += namedCtorArguments.Count;
ResolveResult[] arguments = new ResolveResult[totalArgumentCount];
string[] argumentNames = new string[totalArgumentCount];
int i = 0;
if (positionalArguments != null) {
while (i < positionalArguments.Count) {
IConstantValue cv = positionalArguments[i];
arguments[i] = cv.Resolve(context);
i++;
}
}
if (namedCtorArguments != null) {
foreach (var pair in namedCtorArguments) {
argumentNames[i] = pair.Key;
arguments[i] = pair.Value.Resolve(context);
i++;
}
}
MemberResolveResult mrr = r.ResolveObjectCreation(type, arguments, argumentNames) as MemberResolveResult;
return mrr != null ? mrr.Member as IMethod : null;
}
示例2: TypeSystemAstBuilder
/// <summary>
/// Creates a new TypeSystemAstBuilder.
/// </summary>
/// <param name="resolver">
/// A resolver initialized for the position where the type will be inserted.
/// </param>
public TypeSystemAstBuilder(CSharpResolver resolver)
{
if (resolver == null)
throw new ArgumentNullException("resolver");
this.resolver = resolver;
InitProperties();
}
示例3: GetShortType
protected string GetShortType (IType type)
{
if (builder == null) {
var ctx = ext.CSharpUnresolvedFile.GetTypeResolveContext (ext.UnresolvedFileCompilation, ext.Document.Editor.Caret.Location) as CSharpTypeResolveContext;
var state = new CSharpResolver (ctx);
builder = new TypeSystemAstBuilder (state);
var dt = state.CurrentTypeDefinition;
var declaring = ctx.CurrentTypeDefinition != null ? ctx.CurrentTypeDefinition.DeclaringTypeDefinition : null;
if (declaring != null) {
while (dt != null) {
if (dt.Equals (declaring)) {
builder.AlwaysUseShortTypeNames = true;
break;
}
dt = dt.DeclaringTypeDefinition;
}
}
}
try {
return GLib.Markup.EscapeText (builder.ConvertType(type).ToString (ext.FormattingPolicy.CreateOptions ()));
} catch (Exception e) {
LoggingService.LogError ("Exception while getting short type.", e);
return "";
}
}
示例4: ResolveCref
public override IEntity ResolveCref(string cref)
{
if (cref.Length > 2 && cref[1] == ':') {
// resolve ID string
return base.ResolveCref(cref);
}
var documentationReference = new CSharpParser().ParseDocumentationReference(cref);
var csharpContext = context as CSharpTypeResolveContext;
CSharpResolver resolver;
if (csharpContext != null) {
resolver = new CSharpResolver(csharpContext);
} else {
resolver = new CSharpResolver(context.Compilation);
}
var astResolver = new CSharpAstResolver(resolver, documentationReference);
var rr = astResolver.Resolve(documentationReference);
MemberResolveResult mrr = rr as MemberResolveResult;
if (mrr != null)
return mrr.Member;
TypeResolveResult trr = rr as TypeResolveResult;
if (trr != null)
return trr.Type.GetDefinition();
return null;
}
示例5: CSharpCompletionDataFactory
public CSharpCompletionDataFactory(CSharpCompletionContext completionContext, CSharpResolver contextAtCaret)
{
Debug.Assert(completionContext != null);
Debug.Assert(contextAtCaret != null);
this.completionContext = completionContext;
this.contextAtCaret = contextAtCaret;
this.builder = new TypeSystemAstBuilder(contextAtCaret);
}
示例6: Resolve
public override ResolveResult Resolve(CSharpResolver resolver)
{
ResolveResult targetRR = target.Resolve(resolver);
if (targetRR.IsError)
return targetRR;
IList<IType> typeArgs = typeArguments.Resolve(resolver.CurrentTypeResolveContext);
return resolver.ResolveMemberAccess(targetRR, identifier, typeArgs, lookupMode);
}
示例7: OverrideCompletionData
public OverrideCompletionData(int declarationBegin, IMember m, CSharpResolver contextAtCaret)
: base(m)
{
this.declarationBegin = declarationBegin;
this.contextAtCaret = contextAtCaret;
var ambience = new CSharpAmbience();
ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList | ConversionFlags.ShowParameterList | ConversionFlags.ShowParameterNames;
this.CompletionText = ambience.ConvertSymbol(m);
}
示例8: Resolve
public static ResolveResult Resolve(ICompilation compilation, CSharpParsedFile parsedFile, CompilationUnit cu, TextLocation location,
CancellationToken cancellationToken = default(CancellationToken))
{
AstNode node = cu.GetNodeAt(location);
if (node == null)
return null;
AstNode resolvableNode;
if (node is AstType) {
resolvableNode = node;
if (resolvableNode.Parent is ComposedType) {
while (resolvableNode.Parent is ComposedType)
resolvableNode = resolvableNode.Parent;
//node is preffered over the resolvable node. Which shouldn't be done in the case of nullables, arrays etc.
node = resolvableNode;
}
} else if (node is Identifier) {
resolvableNode = node.Parent;
} else if (node.NodeType == NodeType.Token) {
if (node.Parent is ConstructorInitializer) {
resolvableNode = node.Parent;
} else {
return null;
}
} else {
// don't resolve arbitrary nodes - we don't want to show tooltips for everything
return null;
}
if (resolvableNode != null && resolvableNode.Parent is ObjectCreateExpression) {
resolvableNode = resolvableNode.Parent;
}
InvocationExpression parentInvocation = null;
if ((resolvableNode is IdentifierExpression || resolvableNode is MemberReferenceExpression || resolvableNode is PointerReferenceExpression)) {
// we also need to resolve the invocation
parentInvocation = resolvableNode.Parent as InvocationExpression;
}
IResolveVisitorNavigator navigator;
if (parentInvocation != null)
navigator = new NodeListResolveVisitorNavigator(new[] { resolvableNode, parentInvocation });
else
navigator = new NodeListResolveVisitorNavigator(new[] { resolvableNode });
CSharpResolver resolver = new CSharpResolver(compilation);
ResolveVisitor v = new ResolveVisitor(resolver, parsedFile, navigator);
v.Scan(cu);
// Prefer the RR from the token itself, if it was assigned a ResolveResult
// (this can happen with the identifiers in various nodes such as catch clauses or foreach statements)
ResolveResult rr = v.GetResolveResult(node) ?? v.GetResolveResult(resolvableNode);
if (rr is MethodGroupResolveResult && parentInvocation != null)
return v.GetResolveResult(parentInvocation);
else
return rr;
}
示例9: EventCreationCompletionData
public EventCreationCompletionData(string handlerName, IType delegateType, IEvent evt, string parameterList, IUnresolvedMember callingMember, IUnresolvedTypeDefinition declaringType, CSharpResolver contextAtCaret)
{
if (string.IsNullOrEmpty(handlerName)) {
handlerName = (evt != null ? evt.Name : "Handle");
}
this.handlerName = handlerName;
this.DisplayText = "<Create " + handlerName + ">";
this.delegateTypeReference = delegateType.ToTypeReference();
this.isStatic = callingMember != null && callingMember.IsStatic;
}
示例10: EventCreationCompletionData
public EventCreationCompletionData(string handlerName, IType delegateType, IEvent evt, string parameterList, IUnresolvedMember callingMember, IUnresolvedTypeDefinition declaringType, CSharpResolver contextAtCaret)
{
if (string.IsNullOrEmpty(handlerName)) {
handlerName = (evt != null ? evt.Name : "Handle");
}
this.handlerName = handlerName;
this.DisplayText = StringParser.Parse("${res:CSharpBinding.Refactoring.EventCreation.EventHandlerText}", new[] { new StringTagPair("HandlerName", handlerName) });
this.delegateTypeReference = delegateType.ToTypeReference();
this.isStatic = callingMember != null && callingMember.IsStatic;
}
示例11: CSharpAstResolver
/// <summary>
/// Creates a new C# AST resolver.
/// </summary>
/// <param name="resolver">The resolver state at the root node.</param>
/// <param name="rootNode">The root node of the resolved tree.</param>
/// <param name="parsedFile">The parsed file for the nodes being resolved. This parameter is used only
/// when the root node is on the type level; it is not necessary when an expression is passed.
/// This parameter may be null.</param>
public CSharpAstResolver(CSharpResolver resolver, AstNode rootNode, CSharpParsedFile parsedFile = null)
{
if (resolver == null)
throw new ArgumentNullException("resolver");
if (rootNode == null)
throw new ArgumentNullException("rootNode");
this.initialResolverState = resolver;
this.rootNode = rootNode;
this.parsedFile = parsedFile;
}
示例12: SignatureMarkupCreator
public SignatureMarkupCreator (CSharpResolver resolver, CSharpFormattingOptions formattingOptions)
{
this.colorStyle = SyntaxModeService.GetColorStyle (MonoDevelop.Ide.IdeApp.Preferences.ColorScheme);
this.resolver = resolver;
this.astBuilder = new TypeSystemAstBuilder (resolver) {
ConvertUnboundTypeArguments = true,
UseAliases = false
};
this.formattingOptions = formattingOptions;
}
示例13: DoResolve
public ResolveResult DoResolve(ITypeResolveContext context)
{
CSharpResolver r = new CSharpResolver(context);
r.CurrentTypeDefinition = parentTypeDefinition != null ? parentTypeDefinition.GetCompoundClass() : null;
r.UsingScope = parentUsingScope;
IType[] typeArgs = new IType[typeArguments.Count];
for (int i = 0; i < typeArgs.Length; i++) {
typeArgs[i] = typeArguments[i].Resolve(context);
}
return r.LookupSimpleNamespaceOrTypeName(identifier, typeArgs, isInUsingDeclaration);
}
示例14: CSharpAstResolver
/// <summary>
/// Creates a new C# AST resolver.
/// Use this overload if you are resolving within a complete C# file.
/// </summary>
/// <param name="compilation">The current compilation.</param>
/// <param name="syntaxTree">The syntax tree to be resolved.</param>
/// <param name="unresolvedFile">
/// Optional: Result of <see cref="SyntaxTree.ToTypeSystem()"/> for the file being resolved.
/// <para>
/// This is used for setting up the context on the resolver. The unresolved file must be registered in the compilation.
/// </para>
/// <para>
/// When a unresolvedFile is specified, the resolver will use the member's StartLocation/EndLocation to identify
/// member declarations in the AST with members in the type system.
/// When no unresolvedFile is specified (<c>null</c> value for this parameter), the resolver will instead compare the
/// member's signature in the AST with the signature in the type system.
/// </para>
/// </param>
public CSharpAstResolver(ICompilation compilation, SyntaxTree syntaxTree, CSharpUnresolvedFile unresolvedFile = null)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
if (syntaxTree == null)
throw new ArgumentNullException("syntaxTree");
this.initialResolverState = new CSharpResolver(compilation);
this.rootNode = syntaxTree;
this.unresolvedFile = unresolvedFile;
this.resolveVisitor = new ResolveVisitor(initialResolverState, unresolvedFile);
}
示例15: CSharpAstResolver
/// <summary>
/// Creates a new C# AST resolver.
/// Use this overload if you are resolving within a complete C# file.
/// </summary>
/// <param name="compilation">The current compilation.</param>
/// <param name="compilationUnit">The compilation unit corresponding to the specified parsed file.</param>
/// <param name="parsedFile">
/// Optional: Result of the <see cref="TypeSystemConvertVisitor"/> for the file being resolved.
/// <para>
/// This is used for setting up the context on the resolver. The parsed file must be registered in the compilation.
/// </para>
/// <para>
/// When a parsedFile is specified, the resolver will use the member's StartLocation/EndLocation to identify
/// member declarations in the AST with members in the type system.
/// When no parsedFile is specified (<c>null</c> value for this parameter), the resolver will instead compare the
/// member's signature in the AST with the signature in the type system.
/// </para>
/// </param>
public CSharpAstResolver(ICompilation compilation, CompilationUnit compilationUnit, CSharpParsedFile parsedFile = null)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
if (compilationUnit == null)
throw new ArgumentNullException("compilationUnit");
this.initialResolverState = new CSharpResolver(compilation);
this.rootNode = compilationUnit;
this.parsedFile = parsedFile;
this.resolveVisitor = new ResolveVisitor(initialResolverState, parsedFile);
}