# Custom Plugin Development - Sensor extended class not executed

**URL:** <https://community.sonarsource.com/t/custom-plugin-development-sensor-extended-class-not-executed/126645>\
**Category:** Plugin Development\
**Created:** [September 25, 2024, 9:29pm UTC](https://community.sonarsource.com/t/custom-plugin-development-sensor-extended-class-not-executed/126645 "2024-09-25T21:29:23Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![G5un](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/g5un/32/62346_2.png) [@G5un](https://community.sonarsource.com/u/G5un)\
**Post date:** [September 25, 2024, 9:29pm UTC](https://community.sonarsource.com/t/custom-plugin-development-sensor-extended-class-not-executed/126645/1 "2024-09-25T21:29:23Z")

</div>

[sonarqube-community-10.6.0.92116]  
My New/Custom developed SQL (\*.sql) Sonar Plugin is not being detected/activated when I run analysis on new project that has .sql scripts.

I can see my new Quality Profile and new Rules in Sonar but not being run when I run code analysis. i.e., SQLComplianceSensor.execute(SensorContext context) was never called. (I see no debug messages in the log files)

I followed all the steps listed in developing a new plugin section of the documentation.  
How do I debug or detect why and where I’m missing the plugin detection?  
I see my new SQL language (AbstractLanguage extension) debug message in log.  
Here is my plugin context extensions addition:

context.addExtensions(SQLLanguage.class, SQLComplianceSensor.class, SQLQualityProfile.class,  
SQLComplianceRulesDefinition.class, SQLComplianceCheckRegistrar.class);

Question: Does this extension classes addition order has any significance?

1. SQLLanguage.java  
public final class SQLLanguage extends AbstractLanguage {  
…

2. SQLComplianceSensor.java

public class SQLComplianceSensor implements Sensor {  
…

1. SQLQualityProfile.java

public class SQLQualityProfile implements BuiltInQualityProfilesDefinition {  
…

1. SQLComplianceRulesDefinition.java

public class SQLComplianceRulesDefinition implements RulesDefinition {  
…

1. SQLComplianceCheckRegistrar.java

public class SQLComplianceCheckRegistrar implements CheckRegistrar {  
…

Do I have to sign my Plugin Jar before I deploy to sonar extensions/plugins folder?

Appreciate your input and feedback!!

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [September 27, 2024, 12:32pm UTC](https://community.sonarsource.com/t/custom-plugin-development-sensor-extended-class-not-executed/126645/2 "2024-09-27T12:32:09Z")

</div>

Hi,

You’ve presumably declared a new language(?). What file extensions does that language ‘claim’? And are those file extensions present in the project you’re testing on?

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![G5un](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/g5un/32/62346_2.png) [@G5un](https://community.sonarsource.com/u/G5un)\
**Post date:** [October 9, 2024, 4:54pm UTC](https://community.sonarsource.com/t/custom-plugin-development-sensor-extended-class-not-executed/126645/3 "2024-10-09T16:54:02Z")

</div>

Thank you, Ann.

Yes, I declared SQL as my new language. I do have multiple .sql files in my project. Is there a good example or documentation on implementing a new language? Most of the SSLR examples are outdated libraries or implemented with complex grammar or too many interfaces to implement. To answer your second question, yes - my project do have multiple .sql files.

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [October 9, 2024, 5:28pm UTC](https://community.sonarsource.com/t/custom-plugin-development-sensor-extended-class-not-executed/126645/4 "2024-10-09T17:28:54Z")

</div>

Hi,

> [@G5un](#):
>
> Is there a good example or documentation on implementing a new language?

I can only point you to our open source analyzers in [Sonar · GitHub](https://github.com/SonarSource/)

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![G5un](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/g5un/32/62346_2.png) [@G5un](https://community.sonarsource.com/u/G5un)\
**Post date:** [October 18, 2024, 4:12pm UTC](https://community.sonarsource.com/t/custom-plugin-development-sensor-extended-class-not-executed/126645/5 "2024-10-18T16:12:13Z")

</div>

Hi Ann,

Quick clarification. Do we have to write Grammar and Tree visitors as listed in Supporting new languages? Cannot we write a simple parser that does all and invoke from scanner?

I noticed all my custom rules and profiles are being created, but when I test run new project with SQL script file in the project, my sensor or my plugin rules are not triggered.

On a different note, My newly added language is not listed under Languages list from Admin page, but under Rule Profiles I see a language SQL.

([Supporting new languages](https://docs.sonarsource.com/sonarqube/latest/extension-guide/developing-a-plugin/supporting-new-languages/))

# Supporting new languages

The steps to cover a new programming language are:

1. Write the grammar. This is the hardest part.
2. Write a parser (a parser simply parses an input based on your grammar to yield a parse tree).
3. Test your grammar, to ensure it is able to parse real-life language files.
4. Write a few parse tree visitors. Some visitors will compute metrics such as [executable lines](https://docs.sonarsource.com/sonarqube/latest/extension-guide/developing-a-plugin/executable-lines/), while others will enforce [coding rules](https://docs.sonarsource.com/sonarqube/latest/extension-guide/adding-coding-rules/). A dozen or so visitors are sufficient for an initial release.

Thank you for you response and support.

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [October 18, 2024, 4:29pm UTC](https://community.sonarsource.com/t/custom-plugin-development-sensor-extended-class-not-executed/126645/6 "2024-10-18T16:29:40Z")

</div>

Hi,

> [@G5un](#):
>
> when I test run new project with SQL script file in the project, my sensor or my plugin rules are not triggered.
> 
> On a different note, My newly added language is not listed under Languages list from Admin page, but under Rule Profiles I see a language SQL.

I think both of these are unrelated to how you’re analyzing the language, and indicate that your plugin isn’t being registered properly. I would back to to working on just that, using whether or not the language shows up as your indicator of whether or not it’s working.

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![G5un](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/g5un/32/62346_2.png) [@G5un](https://community.sonarsource.com/u/G5un)\
**Post date:** [October 18, 2024, 6:03pm UTC](https://community.sonarsource.com/t/custom-plugin-development-sensor-extended-class-not-executed/126645/7 "2024-10-18T18:03:23Z")

</div>

Thank you, Ann. I’ll continue my investigation on Plugin scanner detection and post my progress.

---

<div class="post-metadata">

**Author:** ![G5un](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/g5un/32/62346_2.png) [@G5un](https://community.sonarsource.com/u/G5un)\
**Post date:** [October 24, 2024, 3:24pm UTC](https://community.sonarsource.com/t/custom-plugin-development-sensor-extended-class-not-executed/126645/8 "2024-10-24T15:24:11Z")

</div>

Hi Ann,

Could you please confirm that, I’m on the right track and why my new PL/SQL or SQL language sensor is not triggered when I validate a new project? I tried to validate local project using maven option.

Here are the key Plugin calls -  
PlSqlPlugin class:  
context.addExtensions(Arrays.asList(  
PropertyDefinition.builder(FILE\_SUFFIXES\_KEY)  
.name(“File Suffixes”)  
.description(“Comma-separated list of suffixes of PL/SQL files to analyze.”)  
.category(“PL/SQL”)  
.onQualifiers(Qualifiers.PROJECT)  
.defaultValue(“sql,pkg,pks,pkb”)  
.build(),

```
    PlSql.class,
    PlSqlProfile.class,
    PlSqlSquidSensor.class, <== Missing log entries for instantiation or any other calls
    PlSqlRuleRepository.class,
    PlSqlCpdMapping.class, <== Missing log entries for instantiation or any other calls
    SonarComponents.class)); <== Missing log entries for instantiation or any other calls

```

Here are the log entries:  
2024.10.24 11:12:26 INFO web[o.s.p.PlSqlPlugin] PlSqlPlugin define() started  
2024.10.24 11:12:26 INFO web[o.s.p.PlSqlPlugin] PlSqlPlugin define() completed

2024.10.24 11:12:28 INFO web[o.s.plsqlopen.PlSql] PlSql() completed

2024.10.24 11:12:33 INFO web[o.s.p.PlSqlRuleRepository] PlSqlRuleRepository() started  
2024.10.24 11:12:33 INFO web[o.s.p.PlSqlRuleRepository] PlSqlRuleRepository() ended

2024.10.24 11:12:58 INFO web[o.s.p.PlSqlProfile] PlSqlProfile define() started  
2024.10.24 11:12:58 INFO web[o.s.p.PlSqlProfile] PlSqlProfile define() completed

2024.10.24 11:13:00 INFO web[o.s.s.q.RegisterQualityProfiles] Update profile plsql/Sonar way

I see no log entries for Sensor, CpdMapping or SonarComponents even when I check/validated project.

I appreciate any guidence on why the sensor is not triggered on SQL files?

Thanks,  
S.

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [October 24, 2024, 4:34pm UTC](https://community.sonarsource.com/t/custom-plugin-development-sensor-extended-class-not-executed/126645/9 "2024-10-24T16:34:00Z")

</div>

Hi,

This really isn’t my area of expertise, and since you’re trying to craft a plugin for a language we support commercially I can’t ask any of the developers to help you. I can only advise you to work from our open source analyzers.

&nbsp;  
Ann
