public FieldInfo(
     FieldName fieldName,
     ClassName parentClass,
     AccessFlags accessFlags,
     SourceCodeSnippet sourceCode)
 {
     ParentClass        = parentClass;
     FieldName          = fieldName;
     FieldType          = TypeName.For(FieldName.FullyQualified.Split(':')[1]);
     AccessFlags        = accessFlags;
     Methods            = new List <MethodInfo>();
     ReferencesToThis   = new List <CodeReferenceEndpoint>();
     ReferencesFromThis = new List <CodeReferenceEndpoint>();
     SourceCode         = sourceCode;
 }
Ejemplo n.º 2
0
        // note: fullyQualified must look like:
        // dir1/dir2/filename.ext|my.class.package.OuterClass$InnerClass1$InnerClass2
        public ClassName(string fullyQualified)
        {
            FullyQualified = fullyQualified;
            string packageAndClass = fullyQualified;

            if (fullyQualified.Contains('|'))
            {
                packageAndClass = fullyQualified.Substring(fullyQualified.IndexOf('|') + 1);
            }

            string className = packageAndClass;

            if (packageAndClass.Contains('.'))
            {
                // my.class.package.class1 => class1
                className = packageAndClass.Substring(packageAndClass.LastIndexOf('.') + 1);
            }

            // only required to make the Java runtime trace match
            JavaFullyQualified = $"L{packageAndClass};";
            if (fullyQualified.Contains('|') && !fullyQualified.StartsWith("|"))
            {
                ContainmentFile = new FileName(
                    fullyQualified.Substring(0, fullyQualified.IndexOf('|')));
            }

            if (className.Contains('$'))
            {
                IsOuterClass = false;
                string[] innerClassSplit = className.Split('$');
                ShortName = innerClassSplit.Last();

                ParentClass =
                    new ClassName(
                        FullyQualified.Substring(
                            0,
                            // remove $ and name of inner
                            FullyQualified.LastIndexOf('$')));
            }
            else
            {
                IsOuterClass = true;
                ShortName    = className;
            }
        }
Ejemplo n.º 3
0
        public FieldName(string fullyQualified)
        {
            FullyQualified = fullyQualified;
            string className = fullyQualified.Substring(
                0,
                fullyQualified.IndexOf(';'));

            ContainmentParent = new ClassName(className);
            Package           = ContainmentParent.Package;

            // ...class;field:type -> field
            string fieldLongName = fullyQualified.Substring(fullyQualified.IndexOf(';') + 1);

            ShortName = fieldLongName;
            if (fieldLongName.Contains(':'))
            {
                ShortName = fieldLongName.Substring(0, fieldLongName.IndexOf(':'));
            }
        }
        public MethodInfo(
            MethodName methodName,
            AccessFlags accessFlags,
            ClassName parentClass,
            IEnumerable <Argument> arguments,
            TypeName returnType,
            SourceCodeSnippet sourceCode)
        {
            MethodName       = methodName;
            this.accessFlags = accessFlags;
            ParentClass      = parentClass;

            Arguments  = arguments.ToArray();
            ReturnType = returnType;

            Field              = null;
            ReferencesToThis   = new List <CodeReferenceEndpoint>();
            ReferencesFromThis = new List <CodeReferenceEndpoint>();

            SourceCode = sourceCode;
        }
        public ClassInfo(
            ClassName className,
            IEnumerable <MethodInfo> methods,
            IEnumerable <FieldInfo> fields,
            AccessFlags accessFlags,
            IEnumerable <ClassInfo> innerClasses,
            SourceCodeSnippet headerSource,
            bool isTestClass)
        {
            this.className   = className;
            this.accessFlags = accessFlags;

            Children = new List <ICodebaseElementInfo>();
            Children.AddRange(fields);
            Children.AddRange(methods);
            Children.AddRange(innerClasses);

            ReferencesToThis   = new List <CodeReferenceEndpoint>();
            ReferencesFromThis = new List <CodeReferenceEndpoint>();
            SourceCode         = headerSource;
            IsTestClass        = isTestClass;
        }