public void CreateSourceAnchor(FAMIX.SourcedEntity sourcedEntity, SyntaxNode node) { var lineSpan = node.SyntaxTree.GetLineSpan(node.Span); FAMIX.FileAnchor fileAnchor = CreateNewFileAnchor(node, ref lineSpan); var loc = lineSpan.EndLinePosition.Line - lineSpan.StartLinePosition.Line; if (sourcedEntity is FAMIX.BehaviouralEntity) { (sourcedEntity as FAMIX.BehaviouralEntity).numberOfLinesOfCode = loc; } sourcedEntity.sourceAnchor = fileAnchor; repository.Add(fileAnchor); }
private FAMIX.FileAnchor CreateNewFileAnchor(SyntaxNode node, ref FileLinePositionSpan lineSpan) { String relativePath = ""; if (node.SyntaxTree.FilePath.Length > 0) { relativePath = node.SyntaxTree.FilePath.Substring(projectBaseFolder.Length + 1); } FAMIX.FileAnchor fileAnchor = new FAMIX.FileAnchor { startLine = lineSpan.StartLinePosition.Line + 1, startColumn = lineSpan.StartLinePosition.Character, endLine = lineSpan.EndLinePosition.Line + 1, endColumn = lineSpan.EndLinePosition.Character + 1, fileName = relativePath }; return(fileAnchor); }
public void CreateSourceAnchor(FAMIX.Type sourcedEntity, ClassDeclarationSyntax node) { var lineSpan = node.SyntaxTree.GetLineSpan(node.Span); FAMIX.FileAnchor fileAnchor = CreateNewFileAnchor(node, ref lineSpan); var loc = lineSpan.EndLinePosition.Line - lineSpan.StartLinePosition.Line; if (node.Modifiers.ToFullString().Contains("partial")) { if (sourcedEntity.sourceAnchor == null) { sourcedEntity.sourceAnchor = new FAMIX.MultipleFileAnchor(); repository.Add(sourcedEntity.sourceAnchor); } (sourcedEntity.sourceAnchor as FAMIX.MultipleFileAnchor).AddAllFile(fileAnchor); } else { sourcedEntity.sourceAnchor = fileAnchor; } (sourcedEntity as FAMIX.Type).numberOfLinesOfCode += loc; repository.Add(fileAnchor); }