Skip to content

Commit b797af7

Browse files
mdaloialildude
andauthored
Add Mule language (github-linguist#5925)
* Add Mule language Mule applications are written using XML language but unfortunately they don't have a specific file extension and uses `.xml`. But they have at least 2 distinctive characteristics: - The root node is called `<mule>` - The default namespace for `<mule>` node is `xmlns="http://www.mulesoft.org/schema/mule/core"` In order to distinguish this language from other XML file an heuristic was added with a pattern to match those characteristics. * Add Mule grammar reference in vendor/README.md Altought it is the same as the XML language if not added the TestGrammars#test_readme_file_is_in_sync fails. * Fix pattern for Mule language The previous one for some reason made the tests to hang and never end. This new one seems to fix that while preserves the matching intentions (node called `mule` containing a specific default XML namespace). * Add missing heuristics test for Mule language Co-authored-by: Colin Seymour <colin@github.com>
1 parent a665b5f commit b797af7

13 files changed

+744
-0
lines changed

lib/linguist/heuristics.yml

+4
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,10 @@ disambiguations:
674674
pattern: '^%(end|ctor|hook|group)\b'
675675
- language: Linker Script
676676
pattern: 'OUTPUT_ARCH\(|OUTPUT_FORMAT\(|SECTIONS'
677+
- extensions: ['.xml']
678+
rules:
679+
- language: Mule
680+
pattern: '<mule\s[^>]*xmlns="http:\/\/www\.mulesoft\.org\/schema\/mule\/core"'
677681
- extensions: ['.yaml']
678682
rules:
679683
- language: MiniYAML

lib/linguist/languages.yml

+10
Original file line numberDiff line numberDiff line change
@@ -4006,6 +4006,16 @@ Motorola 68K Assembly:
40064006
tm_scope: source.m68k
40074007
ace_mode: assembly_x86
40084008
language_id: 477582706
4009+
Mule:
4010+
type: programming
4011+
color: "#00a1df"
4012+
tm_scope: text.xml
4013+
ace_mode: xml
4014+
codemirror_mode: xml
4015+
codemirror_mime_type: application/xml
4016+
extensions:
4017+
- ".xml"
4018+
language_id: 213085803
40094019
Muse:
40104020
type: prose
40114021
extensions:

samples/Mule/dataweave.xml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
4+
xmlns="http://www.mulesoft.org/schema/mule/core"
5+
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
6+
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
7+
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
8+
<http:listener-config name="DW_HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="4d265575-e82b-489e-af85-32c28ae51697" >
9+
<http:listener-connection host="0.0.0.0" port="8082" />
10+
</http:listener-config>
11+
<flow name="dataweaveFlow" doc:id="fb9f311f-c951-4459-a094-387c076b2399" >
12+
<http:listener doc:name="Listener" doc:id="5dc3e696-2c93-41f0-8952-a9003cee5361" config-ref="DW_HTTP_Listener_config" path="/"/>
13+
<ee:transform doc:name="Transform Message" doc:id="b9d228d0-7e8d-46f0-97e4-a9043842fb90" >
14+
<ee:message >
15+
<ee:set-payload ><![CDATA[%dw 2.0
16+
output application/json
17+
---
18+
classrooms: payload..*teacher groupBy $.subject mapObject ((teacherGroup, subject) -> {
19+
class: {
20+
name: subject,
21+
teachers: { (teacherGroup map {
22+
teacher:{
23+
name: $.name,
24+
lastName: $.lastName
25+
}
26+
})
27+
}
28+
}
29+
})]]></ee:set-payload>
30+
</ee:message>
31+
</ee:transform>
32+
</flow>
33+
</mule>

samples/Mule/empty.xml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd"></mule>

samples/Mule/global.xml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:wsc="http://www.mulesoft.org/schema/mule/wsc"
4+
xmlns:american-flights-api="http://www.mulesoft.org/schema/mule/american-flights-api"
5+
xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
6+
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
7+
http://www.mulesoft.org/schema/mule/american-flights-api http://www.mulesoft.org/schema/mule/american-flights-api/current/mule-american-flights-api.xsd
8+
http://www.mulesoft.org/schema/mule/wsc http://www.mulesoft.org/schema/mule/wsc/current/mule-wsc.xsd
9+
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
10+
<configuration-properties doc:name="Configuration properties" doc:id="8c9cdd94-6f21-4b4f-ab97-e29aad0baed2" file="config.yaml" />
11+
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="a5df1eb0-4251-42de-9e1c-016a7e25c25a" >
12+
<http:listener-connection host="0.0.0.0" port="${http.port}" />
13+
</http:listener-config>
14+
<american-flights-api:config name="American_Flights_API_Config" doc:name="American Flights API Config" doc:id="782b14ef-3f15-437d-a12b-f02b3b91eaf1" property_host="${american.host}" property_port="${american.port}" property_protocol="${american.protocol}" property_basePath="${american.basepath}"/>
15+
<http:request-config name="HTTP_Request_config_training" doc:name="HTTP Request configuration" doc:id="9d95e3b0-dd8a-4077-b04b-b59cf15fd2ce" basePath="${training.basepath}" >
16+
<http:request-connection host="${training.host}" port="${training.port}" />
17+
</http:request-config>
18+
<wsc:config name="Delta_Web_Service_Consumer_Config" doc:name="Web Service Consumer Config" doc:id="704b5225-f6b8-4f2b-9bb5-af6b6f96a364" >
19+
<wsc:connection wsdlLocation="${delta.wsdl}" service="${delta.service}" port="${delta.port}" >
20+
<reconnection >
21+
<reconnect />
22+
</reconnection>
23+
<wsc:web-service-security actor="http://schemas.xmlsoap.org/soap/actor/next" />
24+
</wsc:connection>
25+
</wsc:config>
26+
<configuration doc:name="Configuration" doc:id="e2b21b57-950c-4220-8885-86bc60cb12b4" defaultErrorHandler-ref="globalError_Handler" />
27+
<error-handler name="globalError_Handler" doc:id="d052484b-2cee-45c8-b4ce-741f24971b2f" >
28+
<on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" doc:id="4cf10751-6c0e-424a-b267-9dd6cc3302f6" type="APP:INVALID_DESTINATION">
29+
<ee:transform doc:name="error.description" doc:id="24c132ab-664d-4142-9f78-4c926d4f5cdc" >
30+
<ee:message >
31+
<ee:set-payload ><![CDATA[%dw 2.0
32+
output application/json
33+
---
34+
{
35+
"message": error.description
36+
}]]></ee:set-payload>
37+
</ee:message>
38+
</ee:transform>
39+
<set-variable value="400" doc:name="httpStatus" doc:id="3b3e6176-df64-47a2-b839-cd06c32e1642" variableName="httpStatus"/>
40+
</on-error-continue>
41+
<on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" doc:id="97f3a0b0-e63e-4c67-827a-45a441dc6187" type="WSC:CONNECTIVITY, WSC:INVALID_WSDL">
42+
<ee:transform doc:name="Data unavailable" doc:id="1f17158e-15f1-41c1-9502-76bbd30097af" >
43+
<ee:message >
44+
<ee:set-payload ><![CDATA[%dw 2.0
45+
output application/json
46+
---
47+
{
48+
"message": "Data unavailable. Try later. " ++ error.description as String
49+
}]]></ee:set-payload>
50+
</ee:message>
51+
</ee:transform>
52+
<set-variable value="500" doc:name="httpStatus" doc:id="9101e996-fef2-4abd-afe5-1e4f80d0aa1d" variableName="httpStatus"/>
53+
</on-error-continue>
54+
<on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" doc:id="427ed494-100a-4ba0-a0e3-b168fe942f50" type="ANY">
55+
<ee:transform doc:name="error.description" doc:id="20ac6986-d8a4-4f9d-b179-8c25d8c16de5">
56+
<ee:message>
57+
<ee:set-payload><![CDATA[%dw 2.0
58+
output application/json
59+
---
60+
{
61+
"message": error.description
62+
}]]></ee:set-payload>
63+
</ee:message>
64+
</ee:transform>
65+
<set-variable value="500" doc:name="httpStatus" doc:id="e723383c-7a41-4900-83a5-26a1084d0a7a" variableName="httpStatus" />
66+
</on-error-continue>
67+
</error-handler>
68+
</mule>

samples/Mule/http-listener.xml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
4+
xmlns="http://www.mulesoft.org/schema/mule/core"
5+
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
6+
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
7+
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
8+
<http:listener-config name="Basic_HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="4ecd07b9-dce8-494a-8f60-6a65dc2f05a1" >
9+
<http:listener-connection host="0.0.0.0" port="8081" />
10+
</http:listener-config>
11+
<flow name="http-listenerFlow" doc:id="dbf78a12-7993-4a85-9c2f-c09357d3df33" >
12+
<http:listener doc:name="Listener" doc:id="26f56fd5-fbdb-46af-a7e4-a5e20d1f6f70" config-ref="Basic_HTTP_Listener_config" path="/linguist"/>
13+
<ee:transform doc:name="Transform Message" doc:id="47a03d1c-0ddc-4529-bed3-34b8f8db57fa" >
14+
<ee:message >
15+
<ee:set-payload ><![CDATA[%dw 2.0
16+
output text/plain
17+
---
18+
"Hello " ++ (attributes.queryParams.name default "World") ++ "!!!"]]></ee:set-payload>
19+
</ee:message>
20+
</ee:transform>
21+
</flow>
22+
</mule>

0 commit comments

Comments
 (0)