Skip to content

Software-Analytics-Visualisation-Team/Andromeda-Code-Parsing-Tool

Repository files navigation

Code-to-SPIF-Tool

Setup (after a new galaxy install)

  1. Open the command line
  2. Navigate to the galaxy directory
  3. Create a galaxy/tools/moonshot/ directory:
    mkdir tools/moonshot
  4. Clone this repository:
    git clone https://github.com/Moonshot-SEP/Code-to-SPIF-Tool.git tools/moonshot/Code-to-SPIF-Tool
  5. Change the galaxy tool-configuration at config/tool_conf.xml.sample by adding:
<section name="Moonshot" id="moonshot">
  <tool file="moonshot/Code-to-SPIF-Tool/zip_to_spif.xml" />
</section>

before

<!--
<section id="interactivetools" name="Interactive tools">
 <tool file="interactive/interactivetool_askomics.xml" />
 <tool file="interactive/interactivetool_bam_iobio.xml" />
 <tool file="interactive/interactivetool_cellxgene_0.16.2.xml" />
 <tool file="interactive/interactivetool_cellxgene_1.1.1.xml" />
 <tool file="interactive/interactivetool_ethercalc.xml" />
 <tool file="interactive/interactivetool_guacamole_desktop.xml" />
 <tool file="interactive/interactivetool_hicbrowser.xml" />
 <tool file="interactive/interactivetool_jupyter_notebook_1.0.0.xml" />
 <tool file="interactive/interactivetool_jupyter_notebook.xml" />
 <tool file="interactive/interactivetool_neo4j.xml" />
 <tool file="interactive/interactivetool_openrefine.xml" />
 <tool file="interactive/interactivetool_phinch.xml" />
 <tool file="interactive/interactivetool_rstudio.xml" />
</section>
-->

How to use the tool

  1. Open the command line
  2. Navigate to the galaxy directory
  3. Run galaxy:
    sh run.sh
  4. Open galaxy in your browser
  5. Navigate to the Convert code to SPIF tool under the Moonshot header in the Tools column.
  6. Upload a zip file:
    • Click on the "..."-button (Browse or Upload Datasets)
    • Click on the "Upload"-button
    • Click on the "Choose local file"-button
    • Select the zip file you want to convert
    • Click on the "Start"-button
    • Wait until the file-row becomes green
    • Click on the "Cancel"-button
  7. Select the zip file:
    • Click on the "..."-button (Browse or Upload Datasets)
    • Click on the zip file that you just uploaded
    • Click on the "Ok"-button
  8. Pick a language:
    • Click on the dropdown menu (Java by default)
    • Click on the language you want the tool to convert files of from the zip file
  9. Click on "Run Tool"-button

How to run unit tests

Run the command:

python -m unittest discover -s tests

Add -v flag at the end for more detailed testing
Depending on how your python environment is set up the command can also be:

python3 -m unittest discover -s tests

Java implementation progress:

Note: Strikethrough means that they don't have to be implemented directly as they just serve as parrent classes for other classes that must be implemented or are already all defined in java.owl.

Classes (Nodes):

  • [ ] Thing
  • [ ] AccessModifier (Defined in java.owl)
  • AnnotationType
  • [ ] Artifact
  • ClassType
  • [ ] CodeEntity
  • [ ] ComplexType
  • Constructor
  • [ ] Datatype
  • EnumerationType
  • ExceptionType
  • Field
  • File
  • InterfaceType
  • Method
  • [ ] Namespace (It has JavaPackage which extends NameSpace)
  • [ ] Nothing
  • Parameter
  • PrimitiveTypes
  • [ ] SeonThing
  • Variable
  • JavaPackage

Object properties (Edges):

  • accessesField
  • catchesException
  • constructorIsInvokedBy
  • containsCodeEntity
  • declaresConstructor
  • declaresField
  • declaresMethod
  • [ ] dependsOn
  • expectsDatatype
  • hasAccessModifier
  • [ ] hasChild
  • hasDatatype
  • hasNamespaceMember
  • hasParameter
  • [ ] hasParent
  • hasReturnType
  • hasSubClass
  • hasSubInterface
  • [ ] hasSubtype
  • hasSuperClass
  • hasSuperInterface
  • [ ] hasSuperType
  • implementsInterface
  • instantiatesClass
  • invokesConstructor
  • invokesMethod
  • isAccessedBy
  • isCaughtBy
  • isDatatypeOf
  • isDeclaredConstructorOf
  • isDeclaredFieldOf
  • isDeclaredMethodOf
  • isExpectedDatatype
  • isImplementedBy
  • isInstantiatedBy
  • isNamespaceMemberOf
  • isParameterOf
  • isReturnTypeOf
  • isThrownBy
  • methodIsInvokedBy
  • throwsException
  • usesComplexType

Data properties (Properties):

  • hasCodeIdentifier
  • hasDoc
  • hasIdentifier
  • hasLength
  • hasPosition
  • isAbstract
  • isConstant
  • isStatic
  • startsAt
  • hasJavaDoc

Custom properties added (not from SEON)

  • isStaticComplexType (on ComplexType)
  • isExternalImport (on ComplexType, on ExceptionType and on Datatype)

Custom edges added (not from SEON)

  • isNestedNamespaceIn (namespeace -> namespace)
  • hasNestedNamespaceMember (namespeace -> namespace)
  • isNestedComplexTypeIn (complexType -> complexType)
  • hasNestedComplexTypeMember (complexType -> complexType)

C++ Implementation progress:

Classes (Nodes):

  • [ ] Thing
  • [ ] AccessModifier
  • [] AnnotationType
  • [ ] Artifact
  • ClassType
  • [ ] CodeEntity
  • [ ] ComplexType
  • Constructor
  • [ ] Datatype
  • EnumerationType
  • ExceptionType
  • Field
  • File
  • InterfaceType
  • Method
  • Namespace
  • [ ] Nothing
  • Parameter
  • PrimitiveTypes
  • [ ] SeonThing
  • Variable
  • [ ] JavaPackage

Object properties (Edges):

  • accessesField (Language Server)
  • catchesException (Language Server)
  • constructorIsInvokedBy (Language Server)
  • containsCodeEntity
  • declaresConstructor
  • declaresField
  • declaresMethod
  • [ ] dependsOn
  • expectsDatatype (partially Language Server)
  • hasAccessModifier
  • [ ] hasChild
  • hasDatatype (partially Language Server)
  • hasNamespaceMember (does not take into consideration nested complexTypes and nested namespaceTypes, for this separate edges were added)
  • hasParameter
  • [ ] hasParent
  • hasReturnType (partially Language Server)
  • hasSubClass (Language Server)
  • [ ] hasSubInterface (not applicable to CPP)
  • [ ] hasSubtype
  • hasSuperClass (Language Server)
  • [ ] hasSuperInterface (not applicable to CPP)
  • [ ] hasSuperType
  • implementsInterface (Language Server, header files are considered to be interfaces)
  • instantiatesClass (Language Server)
  • invokesConstructor (Language Server)
  • invokesMethod (Language Server)
  • isAccessedBy (Language Server)
  • isCaughtBy (Language Server)
  • isDatatypeOf (partially Language Server)
  • isDeclaredConstructorOf
  • isDeclaredFieldOf
  • isDeclaredMethodOf
  • isExpectedDatatype (partially Language Server)
  • isImplementedBy (Language Server, header files are considered to be interfaces)
  • isInstantiatedBy (Language Server)
  • isNamespaceMemberOf (does not take into consideration nested complexTypes and nested namespaceTypes, for this separate edges were added)
  • isParameterOf
  • isReturnTypeOf (partially Language Server)
  • isThrownBy (Language Server)
  • methodIsInvokedBy (Language Server)
  • throwsException (Language Server)
  • usesComplexType

Data properties (Properties):

  • hasCodeIdentifier
  • [ ] hasDoc (ANTRL does not check comments)
  • [ ] hasIdentifier (Do not need as it serves as a superclass for hasCodeIdentifier and every node has the property hasCodeIdentifier)
  • hasLength
  • hasPosition
  • isAbstract
  • isConstant
  • isStatic
  • startsAt
  • [ ] hasJavaDoc (this is CPP)

Custom edges added (not from SEON)

  • isNestedNamespaceIn (namespeace -> namespace)
  • hasNestedNamespaceMember (namespeace -> namespace)
  • isNestedComplexTypeIn (complexType -> complexType)
  • hasNestedComplexTypeMember (complexType -> complexType)

Custom properties added (not from SEON)

  • isStaticVariable (on Variable)

Design choices and assumptions:

In cpp, in order to to implement data from cpp file A.cpp into B.cpp, you have to create the A.h file, and include it into B.cpp to use the functionality of the "interface" of A.h implemented in A.cpp. Thus, edges like "invokesMethod", "invokesConstrucot", "accessesField", etc. that start in B.cpp can only reffer to nodes from the A.h file, due to lsp limitations. To fix this, we have added the implementsInterface edge and pair from the node of the A.cpp file to the node fo the A.h file and vice versa to add a sensible connection from the specification of nodes to their implementation. Also, due to lsp and antlr limitations, there is no context for #include clauses to see what .cpp file implements what .h file, so we can check either only the first lines before a context is encountered, or check all the lines for #include statements using lsp, for which we have found no way of computing. Thus, we assume the #inlcude statement is at the start of the file, before any contex of antlr can be found.

Reference

For automated installation of Galaxy and the Moonshot tools (including SPIF-to-SVIF-Tool), see the Andromeda Ansible playbooks: Software-Analytics-Visualisation-Team/andromeda-ansible.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published