本文整理汇总了C#中ICSharpCode.NRefactory.Ast.UsingDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# UsingDeclaration类的具体用法?C# UsingDeclaration怎么用?C# UsingDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UsingDeclaration类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了UsingDeclaration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: VisitUsingDeclaration
public object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data)
{
foreach (Using u in usingDeclaration.Usings) {
VisitUsing(u, data);
}
return null;
}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:7,代码来源:ConvertVisitorGlobal.cs
示例2: UsingDirective
void UsingDirective() {
#line 189 "cs.ATG"
string qualident = null; TypeReference aliasedType = null;
Expect(121);
#line 192 "cs.ATG"
Location startPos = t.Location;
Qualident(
#line 193 "cs.ATG"
out qualident);
if (la.kind == 3) {
lexer.NextToken();
NonArrayType(
#line 194 "cs.ATG"
out aliasedType);
}
Expect(11);
#line 196 "cs.ATG"
if (qualident != null && qualident.Length > 0) {
INode node;
if (aliasedType != null) {
node = new UsingDeclaration(qualident, aliasedType);
} else {
node = new UsingDeclaration(qualident);
}
node.StartLocation = startPos;
node.EndLocation = t.EndLocation;
compilationUnit.AddChild(node);
}
}
开发者ID:almazik,项目名称:ILSpy,代码行数:34,代码来源:Parser.cs
示例3: RemoveCurrentNamespaceUsings
public void RemoveCurrentNamespaceUsings()
{
string program = @"package Janett.Translator;
public class Translation
{
}";
string expected = @"namespace Janett.Translator
{
public class Translation
{
}
}";
CompilationUnit cu = TestUtil.ParseProgram(program);
NamespaceDeclaration ns = (NamespaceDeclaration) cu.Children[0];
UsingDeclaration us1 = new UsingDeclaration("Refactoring", AstUtil.GetTypeReference("Janett.Translator.Refactoring", ns));
UsingDeclaration us2 = new UsingDeclaration("Transformation", AstUtil.GetTypeReference("Janett.Translator.Transformation", ns));
ns.Children.Insert(0, us2);
ns.Children.Insert(0, us1);
us1.Parent = ns;
us2.Parent = ns;
VisitCompilationUnit(cu, null);
TestUtil.CodeEqual(expected, TestUtil.GenerateCode(cu));
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:28,代码来源:UsedTypesTest.cs
示例4: VisitUsingDeclaration
public override object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data)
{
base.VisitUsingDeclaration(usingDeclaration, data);
if (usingDeclaration.Usings.Count == 0) {
RemoveCurrentNode();
}
return null;
}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:8,代码来源:CSharpToVBNetConvertVisitor.cs
示例5: TrackedVisitUsingDeclaration
public override object TrackedVisitUsingDeclaration(UsingDeclaration usingDeclaration, object data)
{
Using usi = (Using) usingDeclaration.Usings[0];
string type = GetShortReferenceTypeName(usi);
if (similarTypes.Contains(type))
RemoveCurrentNode();
return null;
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:8,代码来源:SameProjectAndExternalTypeNameTransformer.cs
示例6: VisitUsingDeclaration
public override object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data)
{
base.VisitUsingDeclaration(usingDeclaration, data);
if (usingDeclaration.Parent is NamespaceDeclaration) {
nodesToMoveToCompilationUnit.Add(usingDeclaration);
RemoveCurrentNode();
}
return null;
}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:9,代码来源:ToVBNetConvertVisitor.cs
示例7: VisitUsingDeclaration
public override object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data)
{
foreach (var usingLine in usingDeclaration.Usings)
if (usingLine.IsAlias)
TypeResolver.AliasNamespace(usingLine.Name, usingLine.Alias.Type);
else
TypeResolver.UseNamespace(usingLine.Name);
return base.VisitUsingDeclaration(usingDeclaration, data);
}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:10,代码来源:TypeResolvingVisitor.cs
示例8: TrackedVisitNamespaceDeclaration
public override object TrackedVisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data)
{
NamespaceDeclaration replacedNamespace = namespaceDeclaration;
UsingDeclaration usingDeclaration = new UsingDeclaration("java.lang.*");
replacedNamespace.Children.Insert(0, usingDeclaration);
ReplaceCurrentNode(replacedNamespace);
return base.TrackedVisitNamespaceDeclaration(namespaceDeclaration, data);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:10,代码来源:DefaultImportTransformer.cs
示例9: VisitUsingDeclaration
public override object VisitUsingDeclaration (UsingDeclaration node, object data)
{
//Usings = new HashSet<string> ();
foreach (Using item in node.Usings) {
if (item.IsAlias)
throw CreateException (node, "Aliases not are supported");
if (!Usings.Contains (item.Name))
Usings.Add (item.Name);
}
return null;
}
开发者ID:hallvar,项目名称:Joddes.CS,代码行数:12,代码来源:JsSourceInspector.cs
示例10: AddUsing
private void AddUsing(INode currentNode, object data, string name)
{
string ns = name.Substring(name.LastIndexOf('.') + 1);
NamespaceDeclaration namespaceDeclaration = (NamespaceDeclaration) AstUtil.GetParentOfType(currentNode, typeof(NamespaceDeclaration));
UsingDeclaration usingDeclaration = new UsingDeclaration(ns);
usingDeclaration.Parent = namespaceDeclaration;
((Using) usingDeclaration.Usings[0]).Alias = AstUtil.GetTypeReference(name, usingDeclaration);
IList usings = AstUtil.GetChildrenWithType(namespaceDeclaration, typeof(UsingDeclaration));
if (! ContainsUsing(usings, usingDeclaration) && !ContainsUsing((IList) data, usingDeclaration))
((IList) data).Add(usingDeclaration);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:12,代码来源:ShortenReferencesTransformer.cs
示例11: add_Using
public static UsingDeclaration add_Using(this CompilationUnit compilationUnit, string @namespace)
{
@namespace = @namespace.remove(";").trim();
var currentUsingDeclaration = [email protected](@namespace);
if (currentUsingDeclaration != null)
// these UsingDeclaration & Using classes are a bit of a mess (need to normalize this later)
return new UsingDeclaration(currentUsingDeclaration.wrapOnList());
var newUsing = new UsingDeclaration(@namespace);
compilationUnit.insert(newUsing);
return newUsing;
}
开发者ID:pusp,项目名称:o2platform,代码行数:12,代码来源:UsingDeclaration_ExtensionMethods.cs
示例12: FieldTwoLayerInvocation
public void FieldTwoLayerInvocation()
{
string program = TestUtil.StatementParse("Field f; f.getName().indexOf('$')");
string expected = TestUtil.StatementParse("Field f; java.lang.String.instancehelper_indexOf(f.getName(), '$')");
CompilationUnit cu = TestUtil.ParseProgram(program);
CompilationUnit cv = TestUtil.ParseProgram(expected);
UsingDeclaration usiDec = new UsingDeclaration("Field", new TypeReference("java.lang.reflect.Field"));
((NamespaceDeclaration) cu.Children[0]).Children.Insert(0, usiDec);
((NamespaceDeclaration) cv.Children[0]).Children.Insert(0, usiDec);
VisitCompilationUnit(cu, null);
TestUtil.CodeEqual(TestUtil.GenerateCode(cv), TestUtil.GenerateCode(cu));
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:13,代码来源:MemberMapperTest_IKVM.cs
示例13: AddAssembly
public void AddAssembly(AssemblyDefinition assemblyDefinition)
{
Ast.UsingDeclaration astUsing = new Ast.UsingDeclaration("System");
astCompileUnit.Children.Add(astUsing);
foreach(TypeDefinition typeDef in assemblyDefinition.MainModule.Types) {
// Skip nested types - they will be added by the parent type
if (typeDef.DeclaringType != null) continue;
// Skip the <Module> class
if (typeDef.Name == "<Module>") continue;
AddType(typeDef);
}
}
开发者ID:almazik,项目名称:ILSpy,代码行数:14,代码来源:AstBuilder.cs
示例14: Used
public void Used()
{
string program = TestUtil.PackageMemberParse("public class A {object obj = new ToStringBuilder();}");
string expected = TestUtil.NamespaceMemberParse("using ToStringBuilder = NClassifier.Util.ToStringBuilder; public class A {object obj = new ToStringBuilder();}");
CompilationUnit cu = TestUtil.ParseProgram(program);
NamespaceDeclaration ns = (NamespaceDeclaration) cu.Children[0];
UsingDeclaration us = new UsingDeclaration("ToStringBuilder", AstUtil.GetTypeReference("NClassifier.Util.ToStringBuilder", ns));
ns.Children.Insert(0, us);
us.Parent = ns;
Mode = "DotNet";
VisitCompilationUnit(cu, null);
TestUtil.CodeEqual(expected, TestUtil.GenerateCode(cu));
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:16,代码来源:UsedTypesTest.cs
示例15: ContainsUsing
private bool ContainsUsing(IList usingList, UsingDeclaration usingDec)
{
foreach (UsingDeclaration usi in usingList)
{
Using usingDeclared = (Using) usingDec.Usings[0];
Using usiUsing = (Using) usi.Usings[0];
if (usiUsing.IsAlias && usingDeclared.IsAlias)
{
if (usiUsing.Name == usingDeclared.Name &&
usiUsing.Alias.Type == usingDeclared.Alias.Type)
return true;
}
else if (!(usiUsing.IsAlias && usingDeclared.IsAlias))
{
if (usingDeclared.Name == usiUsing.Name)
return true;
}
}
return false;
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:21,代码来源:ShortenReferencesTransformer.cs
示例16: AddUsing
public void AddUsing(NamespaceDeclaration namespaceDeclaration, IList usings, UsingDeclaration usingDeclaration)
{
Using usin = (Using) usingDeclaration.Usings[0];
string alias = null;
string name = usin.Name;
if (!usin.IsAlias)
name = name.Substring(name.LastIndexOf('.') + 1);
else
alias = usin.Alias.Type;
if (CodeBase.References.Contains(name))
{
string reference = (string) CodeBase.References[name];
alias = alias.Replace("." + name, "." + reference);
TypeReference typeReference = AstUtil.GetTypeReference(alias, namespaceDeclaration);
UsingDeclaration addingUsingDeclaration = new UsingDeclaration(reference, typeReference);
if (!Contains(usings, addingUsingDeclaration))
{
namespaceDeclaration.Children.Insert(0, addingUsingDeclaration);
}
}
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:23,代码来源:ReferenceTransformer.cs
示例17: TrackedVisitUsingDeclaration
public override object TrackedVisitUsingDeclaration(UsingDeclaration usingDeclaration, object data)
{
Using usi = (Using) usingDeclaration.Usings[0];
if (usi.IsAlias)
{
string type = usi.Alias.Type;
string usingNamespace = type.Substring(0, type.LastIndexOf('.'));
if (usingDeclaration.Parent is NamespaceDeclaration)
{
NamespaceDeclaration namespaceDeclaration = (NamespaceDeclaration) usingDeclaration.Parent;
if (namespaceDeclaration.Name == usingNamespace)
{
RemoveCurrentNode();
}
else if (usingNamespace.StartsWith(namespaceDeclaration.Name))
{
string movedType = namespaceDeclaration.Name + usingNamespace.Substring(usingNamespace.LastIndexOf('.'));
if (CodeBase.Types.Contains(movedType))
RemoveCurrentNode();
}
}
}
Intersect(Removeables, UsedTypes);
if (Removeables.Count > 0)
{
if ((!usi.IsAlias && Removeables.Contains(usi.Name)) || (usi.IsAlias && Removeables.Contains(usi.Alias.Type)))
RemoveCurrentNode();
}
if (UsedTypes.Count > 0)
{
if ((!usi.IsAlias && !UsedTypes.Contains(usi.Name)) || (usi.IsAlias && !UsedTypes.Contains(usi.Alias.Type)))
RemoveCurrentNode();
}
return base.TrackedVisitUsingDeclaration(usingDeclaration, data);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:37,代码来源:UsageRemoverTransformer.cs
示例18: VisitUsingDeclaration
public virtual object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data) {
throw new global::System.NotImplementedException("UsingDeclaration");
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:3,代码来源:NotImplementedAstVisitor.cs
示例19: ImportsStmt
void ImportsStmt() {
#line 299 "VBNET.ATG"
List<Using> usings = new List<Using>();
Expect(124);
#line 303 "VBNET.ATG"
Location startPos = t.Location;
Using u;
ImportClause(
#line 306 "VBNET.ATG"
out u);
#line 306 "VBNET.ATG"
if (u != null) { usings.Add(u); }
while (la.kind == 12) {
lexer.NextToken();
ImportClause(
#line 308 "VBNET.ATG"
out u);
#line 308 "VBNET.ATG"
if (u != null) { usings.Add(u); }
}
EndOfStmt();
#line 312 "VBNET.ATG"
UsingDeclaration usingDeclaration = new UsingDeclaration(usings);
usingDeclaration.StartLocation = startPos;
usingDeclaration.EndLocation = t.Location;
compilationUnit.AddChild(usingDeclaration);
}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:35,代码来源:Parser.cs
示例20: UsingDirective
void UsingDirective() {
#line 196 "cs.ATG"
string qualident = null; TypeReference aliasedType = null;
string alias = null;
Expect(121);
#line 200 "cs.ATG"
Location startPos = t.Location;
if (
#line 201 "cs.ATG"
IdentAndDoubleColon()) {
Identifier();
#line 201 "cs.ATG"
alias = t.val;
Expect(10);
}
Qualident(
#line 202 "cs.ATG"
out qualident);
if (la.kind == 3) {
lexer.NextToken();
NonArrayType(
#line 203 "cs.ATG"
out aliasedType);
}
Expect(11);
#line 205 "cs.ATG"
if (qualident != null && qualident.Length > 0) {
string name = (alias != null && alias != "global") ? alias + "." + qualident : qualident;
INode node;
if (aliasedType != null) {
node = new UsingDeclaration(name, aliasedType);
} else {
node = new UsingDeclaration(name);
}
node.StartLocation = startPos;
node.EndLocation = t.EndLocation;
AddChild(node);
}
}
开发者ID:pluraldj,项目名称:SharpDevelop,代码行数:45,代码来源:Parser.cs
注:本文中的ICSharpCode.NRefactory.Ast.UsingDeclaration类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论