本文整理汇总了C#中ICompilationUnit类的典型用法代码示例。如果您正苦于以下问题:C# ICompilationUnit类的具体用法?C# ICompilationUnit怎么用?C# ICompilationUnit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ICompilationUnit类属于命名空间,在下文中一共展示了ICompilationUnit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetResult
public GenerateNamespaceImport GetResult (ProjectDom dom, ICompilationUnit unit, IType type, TextEditorData data)
{
GenerateNamespaceImport result;
if (cache.TryGetValue (type.Namespace, out result))
return result;
result = new GenerateNamespaceImport ();
cache[type.Namespace] = result;
result.InsertNamespace = false;
DomLocation location = new DomLocation (data.Caret.Line, data.Caret.Column);
foreach (IUsing u in unit.Usings.Where (u => u.ValidRegion.Contains (location))) {
if (u.Namespaces.Any (ns => type.Namespace == ns)) {
result.GenerateUsing = false;
return result;
}
}
result.GenerateUsing = true;
string name = type.DecoratedFullName.Substring (type.Namespace.Length + 1);
foreach (IUsing u in unit.Usings.Where (u => u.ValidRegion.Contains (location))) {
foreach (string ns in u.Namespaces) {
if (dom.SearchType (unit, unit.GetTypeAt (location), unit.GetMemberAt (location), ns + "." + name) != null) {
result.GenerateUsing = false;
result.InsertNamespace = true;
return result;
}
}
}
return result;
}
示例2: AddImportedNamespaceContents
public static void AddImportedNamespaceContents(ArrayList result, ICompilationUnit cu, IClass callingClass)
{
IProjectContent projectContent = cu.ProjectContent;
projectContent.AddNamespaceContents(result, "", projectContent.Language, true);
foreach (IUsing u in cu.GetAllUsings()) {
AddUsing(result, u, projectContent);
}
AddUsing(result, projectContent.DefaultImports, projectContent);
if (callingClass != null) {
string[] namespaceParts = callingClass.Namespace.Split('.');
for (int i = 1; i <= namespaceParts.Length; i++) {
foreach (object member in projectContent.GetNamespaceContents(string.Join(".", namespaceParts, 0, i))) {
if (!result.Contains(member))
result.Add(member);
}
}
IClass currentClass = callingClass;
do {
foreach (IClass innerClass in currentClass.GetCompoundClass().GetAccessibleTypes(currentClass)) {
if (!result.Contains(innerClass))
result.Add(innerClass);
}
currentClass = currentClass.DeclaringType;
} while (currentClass != null);
}
}
示例3: CreateMyApplication
static IClass CreateMyApplication(ICompilationUnit cu, VBNetProject project, string ns)
{
DefaultClass c = new DefaultClass(cu, ns + ".MyApplication");
c.ClassType = ClassType.Class;
c.Modifiers = ModifierEnum.Internal | ModifierEnum.Sealed | ModifierEnum.Partial | ModifierEnum.Synthetic;
c.Attributes.Add(new DefaultAttribute(CreateTypeRef(cu, "Microsoft.VisualBasic.HideModuleNameAttribute")));
switch (project.OutputType) {
case OutputType.WinExe:
c.BaseTypes.Add(CreateTypeRef(cu, "Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase"));
if (project.GetEvaluatedProperty("MyType") == "WindowsForms") {
c.Methods.Add(
new DefaultMethod(c, "Main") {
Modifiers = ModifierEnum.Internal | ModifierEnum.Static,
ReturnType = c.ProjectContent.SystemTypes.Void,
Parameters = new[] {
new DefaultParameter(
"args",
new ArrayReturnType(c.ProjectContent, c.ProjectContent.SystemTypes.String, 1),
DomRegion.Empty
)
}
});
}
break;
case OutputType.Exe:
c.BaseTypes.Add(CreateTypeRef(cu, "Microsoft.VisualBasic.ApplicationServices.ConsoleApplicationBase"));
break;
default:
c.BaseTypes.Add(CreateTypeRef(cu, "Microsoft.VisualBasic.ApplicationServices.ApplicationBase"));
break;
}
return c;
}
示例4: JavaScriptRegionWalker
public JavaScriptRegionWalker(
JavaScriptAst ast,
ICompilationUnit compilationUnit)
{
this.ast = ast;
this.compilationUnit = compilationUnit;
}
示例5: AddDefaultUsings
void AddDefaultUsings(ICompilationUnit compilationUnit)
{
AddUsing("System.Web.Mvc", compilationUnit);
AddUsing("System.Web.Mvc.Ajax", compilationUnit);
AddUsing("System.Web.Mvc.Html", compilationUnit);
AddUsing("System.Web.Routing", compilationUnit);
}
示例6: AddNames
void AddNames (ICompilationUnit unit, int caretLine, int caretColumn)
{
foreach (IType cls in unit.Types) {
if (cls.BodyRegion.Contains (caretLine, caretColumn)) {
// Enclosing namespace:
AddName (cls.Namespace, "");
enclosingNamespace = cls.Namespace;
// For inner classes:
AddName (cls.FullName, "");
}
}
foreach (IUsing u in unit.Usings) {
if (u != null) {
foreach (string us in u.Namespaces)
AddName (us, "");
}
}
// Namespace aliases
foreach (IUsing u in unit.Usings) {
if (u != null) {
foreach (KeyValuePair<string, IReturnType> e in u.Aliases)
AddName (e.Value.FullName, e.Key);
}
}
}
示例7: ParseInformationEventArgs
public ParseInformationEventArgs(string fileName, IProjectContent projectContent, ICompilationUnit oldCompilationUnit, ICompilationUnit newCompilationUnit)
{
this.fileName = fileName;
this.projectContent = projectContent;
this.oldCompilationUnit = oldCompilationUnit;
this.newCompilationUnit = newCompilationUnit;
}
示例8: RetrieveRegions
void RetrieveRegions(ICompilationUnit cu, ICSharpCode.NRefactory.Parser.SpecialTracker tracker)
{
for (int i = 0; i < tracker.CurrentSpecials.Count; ++i) {
ICSharpCode.NRefactory.PreprocessingDirective directive = tracker.CurrentSpecials[i] as ICSharpCode.NRefactory.PreprocessingDirective;
if (directive != null) {
if (directive.Cmd == "#region") {
int deep = 1;
for (int j = i + 1; j < tracker.CurrentSpecials.Count; ++j) {
ICSharpCode.NRefactory.PreprocessingDirective nextDirective = tracker.CurrentSpecials[j] as ICSharpCode.NRefactory.PreprocessingDirective;
if (nextDirective != null) {
switch (nextDirective.Cmd) {
case "#region":
++deep;
break;
case "#endregion":
--deep;
if (deep == 0) {
cu.FoldingRegions.Add(new FoldingRegion(directive.Arg.Trim(), new DomRegion(directive.StartPosition, nextDirective.EndPosition)));
goto end;
}
break;
}
}
}
end: ;
}
}
}
}
示例9: GetModelTypeName
static string GetModelTypeName(ICompilationUnit compilationUnit)
{
var originalRazorCompilationUnit = compilationUnit as RazorCompilationUnit;
if (originalRazorCompilationUnit != null) {
return originalRazorCompilationUnit.ModelTypeName;
}
return String.Empty;
}
示例10: PythonClass
public PythonClass(ICompilationUnit compilationUnit, ClassDefinition classDefinition)
: base(compilationUnit, String.Empty)
{
GetFullyQualifiedName(classDefinition);
GetClassRegions(classDefinition);
AddBaseTypes(classDefinition.Bases);
compilationUnit.Classes.Add(this);
}
示例11: ParseInformation
public ParseInformation(ICompilationUnit unit)
{
if (unit == null)
throw new ArgumentNullException("unit");
unit.Freeze();
// if (!unit.IsFrozen)
// throw new ArgumentException("unit must be frozen for use in ParseInformation");
this.unit = unit;
}
示例12: SetUpFixture
public void SetUpFixture()
{
string python = "class Test:\r\n" +
"\tdef foo(self):\r\n" +
"\t\tpass";
DefaultProjectContent projectContent = new DefaultProjectContent();
PythonParser parser = new PythonParser();
compilationUnit = parser.Parse(projectContent, @"C:\test.py", python);
if (compilationUnit.Classes.Count > 0) {
c = compilationUnit.Classes[0];
if (c.Methods.Count > 0) {
method = c.Methods[0];
}
TextArea textArea = new TextArea();
document = new TextDocument();
textArea.Document = document;
textArea.Document.Text = python;
ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy(textArea);
ParseInformation parseInfo = new ParseInformation(compilationUnit);
foldingStrategy.UpdateFoldings(parseInfo);
List<FoldingSection> folds = new List<FoldingSection>(foldingStrategy.FoldingManager.AllFoldings);
if (folds.Count > 0) {
classFold = folds[0];
}
if (folds.Count > 1) {
methodFold = folds[1];
}
}
}
示例13: ResolveVisitor
public ResolveVisitor(BooResolver resolver)
{
this.resolver = resolver;
this.callingClass = resolver.CallingClass;
this.projectContent = resolver.ProjectContent;
this.cu = resolver.CompilationUnit;
}
示例14: Initialize
bool Initialize(ParseInformation parseInfo, int caretLine, int caretColumn)
{
if (parseInfo == null) {
return false;
}
this.cu = parseInfo.CompilationUnit;
if (cu == null) {
return false;
}
this.pc = cu.ProjectContent;
this.caretLine = caretLine;
this.caretColumn = caretColumn;
this.callingClass = GetCallingClass(pc);
callingMember = ResolveCurrentMember(callingClass);
if (callingMember == null) {
if (cu != parseInfo.CompilationUnit) {
IClass olderClass = GetCallingClass(parseInfo.CompilationUnit.ProjectContent);
if (olderClass != null && callingClass == null) {
this.callingClass = olderClass;
}
callingMember = ResolveCurrentMember(olderClass);
}
}
if (callingMember != null) {
if (caretLine > callingMember.BodyRegion.EndLine) {
this.caretLine = callingMember.BodyRegion.EndLine;
this.caretColumn = callingMember.BodyRegion.EndColumn - 1;
} else if (caretLine == callingMember.BodyRegion.EndLine && caretColumn >= callingMember.BodyRegion.EndColumn) {
this.caretColumn = callingMember.BodyRegion.EndColumn - 1;
}
}
return true;
}
示例15: Class
public Class(CompilationUnit cu, ClassType t, Modifier m, IRegion region)
{
this.cu = cu;
classType = t;
this.region = region;
modifiers = (ModifierEnum)m;
}