-
Notifications
You must be signed in to change notification settings - Fork 0
Distinguishing Rules
JSAnalyzer leverages rules for distinguishing interaction-related code fragments in the source code (distinguishing rules).
Find raw XML files containing distinguishing rules at YOUR_CLONE_DIR/res/rules/*.
Here, we define the distinguishing rules to help you give JSAnalyzer your original rules.
We have already define distinguishing rules for build-in elements. First, we would like to explain how we describe the rules in our XML formats.
| Class | HTML attribute | JavaScript function | CSS property |
|---|---|---|---|
| Trigger | User event handler | - | - |
| Function | - | Event handling functions | - |
| Control | Control & Hidden | DOM manipulation functions | Display & Visibility |
A trigger rule should have its interaction type (User, Server, or Self) and an event type (e.g., onchange).
| Attribute | Definition | Instances |
|---|---|---|
| interact | Interaction type | User, Server, or Self |
| event | Event type | onchange, onclick, etc |
A XML description for the onchange event is below.
<Trigger interact="User" event="onchange" />TBA
TBA
TBA
| Attribute | Definition | Instances |
|---|---|---|
| func | Function name | getElementById, createElement, appendChild, setAttribute, etc |
| semantic | Semantic of manipulate function | get, create, insert, or set |
| by | A method to determine manipulate target | id and tagname (TBD) |
| value | Manipulate value | arg_1, etc |
| target | Manipulate target | ret and propTarget (TBD) |
A XML description for the document.getElementById("foo") is below.
<Manipulate func="getElementById" semantic="get" by="id" value="arg_1" target="ret" />To precisely analyze Ajax apps behavior, define rules for each too complex JavaScript libraries. You can describe Trigger, Potential, Control, and Manipulate rules for the JS libraries as well as build-in ones above. And give a XML file path containing the descriptions to JSAnalyzer.
| Attribute | Definition | Instances |
|---|---|---|
| method | Utility methods to match ruled JavaScript libraries | startsWith, contains, or regex |
| name | Keyword to match depending on the above method | prototype.js, jquery, md[0-9].js, etc |
| path | A file path containing this libraries' rules | path/to/rules4prototypejs.xml, etc |
| skip | Skip to parse this library or not | true or false (currently ignored, i.e., always true) |
Your original rules should be registered in your project.
For example, you can find a registration of the jQuery rule at res/rules/ruledJS.xml.
<Library method="startsWith" name="jquery" path="res/libRules/jquery.xml" skip="true" />And res/libRules/jquery.xml has the following distinguishing rules.
...<Potential interact="User" func="submit" target="propTarget" event="submit" callback="arg_1"/>...
...<Manipulate func="$" semantic="get" by="css_query" value="arg_1" target="ret" />...