Documentation ¶
Overview ¶
Package model refers to model part of mvc. It performs abstraction of datamodel and encapsulates save and retrieves.
Package model refers to model part of mvc. It performs abstraction of datamodel and encapsulates save and retrieves.
Index ¶
- Variables
- type AccessSpecifierModel
- type CallModel
- type ClassModel
- type CodeSnippetModel
- type FileModel
- type FileWrapperModel
- type FunctionBodyModel
- type FunctionModel
- type MongoDB
- func (db *MongoDB) Add(rm *RepoModel) error
- func (db *MongoDB) Count() int
- func (db *MongoDB) DropDB() (err error)
- func (db *MongoDB) FindAllURI() (repos []bson.M, err error)
- func (db *MongoDB) FindRepoByID(id string) (repo RepoModel, err error)
- func (db *MongoDB) Init() error
- func (db *MongoDB) Update(rm *RepoModel) error
- type NamespaceModel
- type ParameterModel
- type ParseResponse
- type ProjectModel
- type RepoModel
- func (repo RepoModel) FetchAll() (repoModels []bson.M, err error)
- func (repo RepoModel) GetRepoByID(id string) (rep RepoModel, err error)
- func (repo RepoModel) GetRepoFiles() (files string, err error)
- func (repo RepoModel) Load(file string, target string) (data FileModel, err error)
- func (repo RepoModel) ParseDataFromFiles(files string, responsePerNFiles int, c chan ParseResponse)
- func (repo RepoModel) SanitizeFilePaths(projectModel ProjectModel)
- func (repo RepoModel) Save(c chan SaveResponse)
- func (repo RepoModel) UpdateRepo() error
- type SaveResponse
- type ScopeModel
- type UsingNamespaceModel
- type VariableModel
Constants ¶
This section is empty.
Variables ¶
var DB = &MongoDB{"mongodb://localhost", "CodeVis3D", "gitRepository"}
DB is a mongo database with name CodeVis3D and collection gitRepository
var JavaParserPath string
JavaParserPath is the path where is java parser is stored.
var RepoPath string
RepoPath is the path where git repositories are stored.
Functions ¶
This section is empty.
Types ¶
type AccessSpecifierModel ¶
type AccessSpecifierModel struct { Name string `json:"name"` Classes []ClassModel `json:"classes,omitempty"` Functions []FunctionModel `json:"functions,omitempty"` Variables []VariableModel `json:"variables,omitempty"` }
AccessSpecifierModel represents code for a single access specifier
type CallModel ¶
type CallModel struct { Identifier string `json:"identifier"` Scope []ScopeModel `json:"scopes,omitempty"` }
CallModel represents a function call from code.
type ClassModel ¶
type ClassModel struct { Name string `json:"name"` AccessSpecifierModels []AccessSpecifierModel `json:"access_specifiers,omitempty"` Parents []string `json:"parents,omitempty"` }
ClassModel represents code for a single calss
type CodeSnippetModel ¶
type CodeSnippetModel struct { FilePath string `json:"file_path"` // File name to be searched through. ID bson.ObjectId `json:"-" bson:"_id,omitempty"` // Folder name where repo is stored StartLine int `json:"start_line"` EndLine int `json:"end_line"` }
CodeSnippetModel represents metadata for a file from a git project.
func (CodeSnippetModel) FetchLinesOfCode ¶
func (codeSnippet CodeSnippetModel) FetchLinesOfCode() (string, error)
FetchLinesOfCode fetch loc from specified range.
type FileModel ¶
type FileModel struct { Parsed bool `json:"parsed"` FileName string `json:"file_name"` Functions []FunctionModel `json:"functions,omitempty"` Namespaces []NamespaceModel `json:"namespaces,omitempty"` UsingNamespaces []UsingNamespaceModel `json:"using_namespaces,omitempty"` Includes []string `json:"includes,omitempty"` Classes []ClassModel `json:"classes,omitempty"` Variables []VariableModel `json:"variables,omitempty"` LinesInFile int `json:"linesInFile"` }
FileModel represents a single code file
type FileWrapperModel ¶
type FileWrapperModel struct {
File FileModel `json:"file"`
}
FileWrapperModel is a wrapper for FileModel for json parsing
type FunctionBodyModel ¶
type FunctionBodyModel struct { Calls []CallModel `json:"calls,omitempty"` Variables []VariableModel `json:"variables,omitempty"` }
FunctionBodyModel represents calls and variable from a function.
type FunctionModel ¶
type FunctionModel struct { Name string `json:"name"` DeclID string `json:"declrator_id"` ReturnType string `json:"return_type,omitempty"` FunctionBody FunctionBodyModel `json:"function_body,omitempty"` Parameters []ParameterModel `json:"parameters,omitempty"` Scope string `json:"scope,omitempty"` StartLine int `json:"start_line"` EndLine int `json:"end_line"` }
FunctionModel represents code for a single function
type MongoDB ¶
MongoDB stores the details of the DB connection.
func (*MongoDB) FindAllURI ¶
FindAllURI finds and returns all the repos stored in DB.
func (*MongoDB) FindRepoByID ¶
FindRepoByID takes the repo with field id as given id. It returns empty repo if it is not in db.
type NamespaceModel ¶
type NamespaceModel struct { NamespaceName string `json:"name"` Functions []FunctionModel `json:"functions,omitempty"` Namespaces []NamespaceModel `json:"namespaces,omitempty"` UsingNamespaces []UsingNamespaceModel `json:"using_namespaces,omitempty"` Includes []string `json:"includes,omitempty"` Classes []ClassModel `json:"classes,omitempty"` Variables []VariableModel `json:"variables,omitempty"` }
NamespaceModel represents code for a single namespace
type ParameterModel ¶
ParameterModel represents a parameter from code.
type ParseResponse ¶
type ParseResponse struct { StatusText string Err error CurrentFile string ParsedFileCount int SkippedFileCount int FileCount int Result ProjectModel }
ParseResponse is used by ParseDataFromFiles to update channel used by go routine to indicate status of request and result
type ProjectModel ¶
type ProjectModel struct {
Files []FileModel `json:"files"`
}
ProjectModel represent the codebase in a repository
type RepoModel ¶
type RepoModel struct { URI string `json:"uri"` // Where the repository was found ID bson.ObjectId `json:"id" bson:"_id,omitempty"` // Folder name where repo is stored ParsedRepo ProjectModel `json:"parsedrepo,omitempty"` // Parsed repository in json format }
RepoModel represents metadata for a git repository.
func (RepoModel) GetRepoByID ¶
GetRepoByID finds repo in database and returns.
func (RepoModel) GetRepoFiles ¶
GetRepoFiles finds and returns all files stored in repository directory. Excludes directories them selfs (as files) and anything from ".git" folder
func (RepoModel) ParseDataFromFiles ¶
func (repo RepoModel) ParseDataFromFiles(files string, responsePerNFiles int, c chan ParseResponse)
ParseDataFromFiles fetch all functions from gives files set.
func (RepoModel) SanitizeFilePaths ¶
func (repo RepoModel) SanitizeFilePaths(projectModel ProjectModel)
SanitizeFilePaths removes the repopath from the filepaths.
func (RepoModel) Save ¶
func (repo RepoModel) Save(c chan SaveResponse)
Save is expected to run as a go rutine writing to a c.
func (RepoModel) UpdateRepo ¶
UpdateRepo updates the repo model with repo in db.
type SaveResponse ¶
SaveResponse is used by save function to update channel used by go routine to indicate status of the save request.
type ScopeModel ¶
type ScopeModel struct { Identifier string `json:"identifier"` Type string `json:"type,omitempty"` }
ScopeModel represents the scope and name of the function call.
type UsingNamespaceModel ¶
UsingNamespaceModel represents the use of namespace.
type VariableModel ¶
VariableModel represents a variable from code.