Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Codan launch modes

I'm using Eclipse 4.6.3, targetting Mars.2 (4.5.2)

Are the problems you tune "codan standard" or customs?

My Codan "problem" are custom, I've defined them in plug-in.xml

I wish declare in XML the launch modes but extensions points doesn't allow declaring launch modes, API are a workaround for me.

Here is my code:

   @Override
   public void initPreferences( IProblemWorkingCopy problem ) {
       super.initPreferences( problem );

       final RootProblemPreference pp = (RootProblemPreference)problem.getPreference();        final LaunchModeProblemPreference lmpp = pp.getLaunchModePreference();
       lmpp.setRunningMode( CheckerLaunchMode.RUN_ON_FULL_BUILD, false );
       lmpp.setRunningMode( CheckerLaunchMode.RUN_ON_INC_BUILD , false );
       lmpp.setRunningMode( CheckerLaunchMode.RUN_ON_DEMAND    , true  );
       lmpp.setRunningMode( CheckerLaunchMode.RUN_ON_FILE_OPEN , false );
       lmpp.setRunningMode( CheckerLaunchMode.RUN_AS_YOU_TYPE  , true  );
       lmpp.setRunningMode( CheckerLaunchMode.RUN_ON_FILE_SAVE , false );

       final SuppressionCommentProblemPreference scp = pp.getSuppressionCommentPreference();
       scp.setValue( "//[[derogations(" + problem.getName() + ")]]" );

       System.out.println( problem.getName() + ": " + problem.getPreference());
   }

When it runs the log is correct but the UI doesn't show these settings, but the default and parsing is made when I open a file.

RAF-LNG-020: [org.eclipse.cdt.codan.core.param.FileScopeProblemPreference@27115d45, [(boolean)RUN_ON_FULL_BUILD=false, (boolean)RUN_ON_INC_BUILD=false, (boolean)RUN_ON_FILE_OPEN=false, (boolean)RUN_ON_FILE_SAVE=false, (boolean)RUN_AS_YOU_TYPE=true, (boolean)RUN_ON_DEMAND=true], (string)suppression_comment=//[[derogations(RAF-LNG-020)]]] RAF-LNG-030: [org.eclipse.cdt.codan.core.param.FileScopeProblemPreference@7789719e, [(boolean)RUN_ON_FULL_BUILD=false, (boolean)RUN_ON_INC_BUILD=false, (boolean)RUN_ON_FILE_OPEN=false, (boolean)RUN_ON_FILE_SAVE=false, (boolean)RUN_AS_YOU_TYPE=true, (boolean)RUN_ON_DEMAND=true], (string)suppression_comment=//[[derogations(RAF-LNG-030)]]] RAF-LNG-040: [org.eclipse.cdt.codan.core.param.FileScopeProblemPreference@5fbb2e1c, [(boolean)RUN_ON_FULL_BUILD=false, (boolean)RUN_ON_INC_BUILD=false, (boolean)RUN_ON_FILE_OPEN=false, (boolean)RUN_ON_FILE_SAVE=false, (boolean)RUN_AS_YOU_TYPE=true, (boolean)RUN_ON_DEMAND=true], (string)suppression_comment=//[[derogations(RAF-LNG-040)]]]...


Window -> Preferences -> C/C++ -> Code Analysis -> CustomizeSelected (button) -> Launching (tab) shows

      [X] Run as you type
      [X] Run on file open
      [ ] Run as file save
      [X] Run on incremental build
      [X] Run on full build
      [ ] Run on demand

And the suppression comment is empty.

Here is a fragment of plug-in.xml

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plug-in>
   <extension point="org.eclipse.cdt.codan.core.checkers"
      id="org.eclipse.cdt.codan.core.categories">
      <category
         id  ="com.xxx.cppchecker.amr"
         name="..." />
      <checker
         id   ="com.xxx.cppchecker.Checker"
         class="com.xxx.cppchecker.Checker"
         name ="...">
         <!--
                  ## 2.1. Langage ##
         -->
         <problem
            category       ="com.xxx.cppchecker.amr"
            id             ="com.xxx.cppchecker.amrules.Raf_Lng_020"
            defaultEnabled ="true"
            defaultSeverity="Error"
            description    ="..."
            messagePattern ="RAF-LNG-020 : ..."
            name           ="RAF-LNG-020" />
...


Le 27/03/2019 à 14:40, Mark B a écrit :

yep, sorry, I'm writing from mobile :) However it works for me but with a fresh workspace.

Il mer 27 mar 2019, 14:38 Aubin Mahé <aubin.mahe@xxxxxxxxxx <mailto:aubin.mahe@xxxxxxxxxx>> ha scritto:

    setLaunchModes isn't a method of LaunchModeProblemPreference
    (codan 4.0.0)

    Would you say setRunningMode?

    With setRunningMode, results are the same: behaviour and preferences
    page are different than settings modified via API.

    It seems only the persistence of user settings - set via UI - is
    taken
    in account.

    API has no effect.

    Le 27/03/2019 à 13:33, Mark B a écrit :
    > I think the code is wrong, to disable them you need to use
    something
    > like that:
    >
    >
    getLaunchModePreference(problem).setLaunchModes(CheckerLaunchMode.<what

    > you want to disable>, false);
    >
    > Il mer 27 mar 2019, 12:42 Aubin Mahé <aubin.mahe@xxxxxxxxxx
    <mailto:aubin.mahe@xxxxxxxxxx>
    > <mailto:aubin.mahe@xxxxxxxxxx <mailto:aubin.mahe@xxxxxxxxxx>>>
    ha scritto:
    >
    >     Hi,
    >
    >     It seems I used correctly the API and XML plug-in extensions.
    >
    >     How can I fill a bug?
    >
    >     It's the first time I've to report a bug for Eclipse/CDT/Codan.
    >
    >     Le 17/03/2019 à 21:09, Aubin Mahé a écrit :
    >     > Even when I deactivate "RUN_AS_YOU_TYPE" and
    "RUN_ON_FILE_OPEN",
    >     > parsing still occurs on file open.
    >     >
    >     > Le 17/03/2019 à 18:47, Nathan Ridge a écrit :
    >     >> Not sure about the first problem, but regarding the
    second: I'm
    >     >> pretty sure "as you type" is a superset of "on file
    open", i.e. it
    >     >> doesn't actually wait for you to type. (Internally it's
    >     implemented
    >     >> using the platform's "reconciler" mechanism.)
    >     >>
    >     >> Hope that helps,
    >     >> Nate
    >     >>
    >     >> ________________________________________
    >     >> From: cdt-dev-bounces@xxxxxxxxxxx
    <mailto:cdt-dev-bounces@xxxxxxxxxxx>
    >     <mailto:cdt-dev-bounces@xxxxxxxxxxx
    <mailto:cdt-dev-bounces@xxxxxxxxxxx>> <cdt-dev-bounces@xxxxxxxxxxx
    <mailto:cdt-dev-bounces@xxxxxxxxxxx>
    >     <mailto:cdt-dev-bounces@xxxxxxxxxxx
    <mailto:cdt-dev-bounces@xxxxxxxxxxx>>> on
    >     >> behalf of Aubin Mahé <aubin.mahe@xxxxxxxxxx
    <mailto:aubin.mahe@xxxxxxxxxx>
    >     <mailto:aubin.mahe@xxxxxxxxxx <mailto:aubin.mahe@xxxxxxxxxx>>>
    >     >> Sent: March 17, 2019 3:40 PM
    >     >> To: cdt-dev@xxxxxxxxxxx
    <mailto:cdt-dev@xxxxxxxxxxx><mailto:cdt-dev@xxxxxxxxxxx
    <mailto:cdt-dev@xxxxxxxxxxx>>
    >     >> Subject: Re: [cdt-dev] Codan launch modes
    >     >>
    >     >> Marc-Andre, your suggestion works well, internal states seems
    >     to be good
    >     >> - traces are the same than mine - but the behaviour and
    the UI
    >     panels
    >     >> are wrong, as shown in my first post.
    >     >>
    >     >> First and second problems remains.
    >     >>
    >     >> Le 17/03/2019 à 15:14, Marc-Andre Laperle wrote :
    >     >>> Hi!
    >     >>>
    >     >>> I don’t remember exactly how this works, but here is an
    >     example from
    >     >>> ProblemBindingChecker.java:
    >     >>>
    >     >>>        @Override
    >     >>>        public void initPreferences(IProblemWorkingCopy
    problem) {
    >     >>> super.initPreferences(problem);
    >     >>>                // This checker should not run on full or
    >     incremental
    >     >>> build
    >     >>>
    >
     getLaunchModePreference(problem).enableInLaunchModes(CheckerLaunchMode.RUN_AS_YOU_TYPE,
    >     >>> CheckerLaunchMode.RUN_ON_DEMAND);
    >     >>>        }
    >     >>>
    >     >>> Maybe you could give this a try?
    >     >>>
    >     >>> Marc-André
    >     >>>
    >     >>>> On Mar 17, 2019, at 10:04 AM, Aubin Mahé
    >     <aubin.mahe@xxxxxxxxxx
    <mailto:aubin.mahe@xxxxxxxxxx><mailto:aubin.mahe@xxxxxxxxxx
    <mailto:aubin.mahe@xxxxxxxxxx>>>
    >     >>>> wrote:
    >     >>>>
    >     >>>> Hello,
    >     >>>>
    >     >>>> I've created a checker plug-in based on CodAn and try
    to set up
    >     >>>> launch modes.
    >     >>>>
    >     >>>> Checker inherits
    >     >>>>
    org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker and
    >     >>>> overrides initPreferences because I haven't found any
    extension
    >     >>>> point dedicated to this usage.
    >     >>>>
    >     >>>>    @Override
    >     >>>>    public void initPreferences( IProblemWorkingCopy
    problem ) {
    >     >>>>        final LaunchModeProblemPreference lmpp =
    >     >>>> getLaunchModePreference( problem );
    >     >>>>        lmpp.addLaunchMode(
    CheckerLaunchMode.RUN_ON_FULL_BUILD,
    >     >>>>            Boolean.FALSE );
    >     >>>>        lmpp.addLaunchMode(
    CheckerLaunchMode.RUN_ON_INC_BUILD ,
    >     >>>>            Boolean.FALSE );
    >     >>>>        lmpp.addLaunchMode(
    CheckerLaunchMode.RUN_ON_DEMAND    ,
    >     >>>>            Boolean.TRUE  );
    >     >>>>        lmpp.addLaunchMode(
    CheckerLaunchMode.RUN_ON_FILE_OPEN ,
    >     >>>>            Boolean.FALSE );
    >     >>>>        lmpp.addLaunchMode(
    CheckerLaunchMode.RUN_AS_YOU_TYPE  ,
    >     >>>>            Boolean.TRUE  );
    >     >>>>        lmpp.addLaunchMode(
    CheckerLaunchMode.RUN_ON_FILE_SAVE ,
    >     >>>>            Boolean.FALSE );
    >     >>>>        System.out.println( problem.getName() + ": "
    >     >>>>            + problem.getPreference());
    >     >>>>    }
    >     >>>>
    >     >>>> At runtime, console shows success of initialization:
    >     >>>>
    >     >>>>      ...
    >     >>>>      RAF-LNG-020:
    >     >>>>
    >
     [org.eclipse.cdt.codan.core.param.FileScopeProblemPreference@4eddffcf,
    >
    >     >>>> [(boolean)RUN_ON_FULL_BUILD=false,
    >     (boolean)RUN_ON_INC_BUILD=false,
    >     >>>> (boolean)RUN_ON_DEMAND=true,
    (boolean)RUN_ON_FILE_OPEN=false,
    >     >>>> (boolean)RUN_AS_YOU_TYPE=true,
    (boolean)RUN_ON_FILE_SAVE=false],
    >     >>>> (string)suppression_comment]
    >     >>>>      RAF-LNG-030:
    >     >>>>
    >
     [org.eclipse.cdt.codan.core.param.FileScopeProblemPreference@25264061,
    >
    >     >>>> [(boolean)RUN_ON_FULL_BUILD=false,
    >     (boolean)RUN_ON_INC_BUILD=false,
    >     >>>> (boolean)RUN_ON_DEMAND=true,
    (boolean)RUN_ON_FILE_OPEN=false,
    >     >>>> (boolean)RUN_AS_YOU_TYPE=true,
    (boolean)RUN_ON_FILE_SAVE=false],
    >     >>>> (string)suppression_comment]
    >     >>>>      ...
    >     >>>>
    >     >>>> First problem:
    >     >>>>
    >     >>>>    Window -> Preferences -> C/C++ -> Code Analysis ->
    Customize
    >     >>>> Selected (button) -> Launching (tab) shows
    >     >>>>
    >     >>>>      [X] Run as you type
    >     >>>>      [ ] Run on file open
    >     >>>>      [ ] Run as file save
    >     >>>>      [X] Run on incremental build
    >     >>>>      [X] Run on full build
    >     >>>>      [X] Run on demand
    >     >>>>
    >     >>>> Second problem:
    >     >>>>
    >     >>>>      When a file is opened my checker is called and report
    >     errors.
    >     >>>>
    >     >>>> How can I really tune launch modes?
    >     >>>> _______________________________________________
    >     >>>> cdt-dev mailing list
    >     >>>> cdt-dev@xxxxxxxxxxx
    <mailto:cdt-dev@xxxxxxxxxxx><mailto:cdt-dev@xxxxxxxxxxx
    <mailto:cdt-dev@xxxxxxxxxxx>>
    >     >>>> To change your delivery options, retrieve your password, or
    >     >>>> unsubscribe from this list, visit
    >     >>>> https://www.eclipse.org/mailman/listinfo/cdt-dev
    >     >>>
    >     >>> _______________________________________________
    >     >>> cdt-dev mailing list
    >     >>> cdt-dev@xxxxxxxxxxx
    <mailto:cdt-dev@xxxxxxxxxxx><mailto:cdt-dev@xxxxxxxxxxx
    <mailto:cdt-dev@xxxxxxxxxxx>>
    >     >>> To change your delivery options, retrieve your password, or
    >     >>> unsubscribe from this list, visit
    >     >>> https://www.eclipse.org/mailman/listinfo/cdt-dev
    >     >>>
    >     >> _______________________________________________
    >     >> cdt-dev mailing list
    >     >> cdt-dev@xxxxxxxxxxx
    <mailto:cdt-dev@xxxxxxxxxxx><mailto:cdt-dev@xxxxxxxxxxx
    <mailto:cdt-dev@xxxxxxxxxxx>>
    >     >> To change your delivery options, retrieve your password, or
    >     >> unsubscribe from this list, visit
    >     >> https://www.eclipse.org/mailman/listinfo/cdt-dev
    >     >>
    >     > _______________________________________________
    >     > cdt-dev mailing list
    >     > cdt-dev@xxxxxxxxxxx
    <mailto:cdt-dev@xxxxxxxxxxx><mailto:cdt-dev@xxxxxxxxxxx
    <mailto:cdt-dev@xxxxxxxxxxx>>
    >     > To change your delivery options, retrieve your password, or
    >     > unsubscribe from this list, visit
    >     > https://www.eclipse.org/mailman/listinfo/cdt-dev
    >     >
    >     _______________________________________________
    >     cdt-dev mailing list
    > cdt-dev@xxxxxxxxxxx
    <mailto:cdt-dev@xxxxxxxxxxx><mailto:cdt-dev@xxxxxxxxxxx
    <mailto:cdt-dev@xxxxxxxxxxx>>
    >     To change your delivery options, retrieve your password, or
    >     unsubscribe from this list, visit
    > https://www.eclipse.org/mailman/listinfo/cdt-dev
    >
    >
    > _______________________________________________
    > cdt-dev mailing list
    > cdt-dev@xxxxxxxxxxx <mailto:cdt-dev@xxxxxxxxxxx>
    > To change your delivery options, retrieve your password, or
    unsubscribe from this list, visit
    > https://www.eclipse.org/mailman/listinfo/cdt-dev
    _______________________________________________
    cdt-dev mailing list
    cdt-dev@xxxxxxxxxxx <mailto:cdt-dev@xxxxxxxxxxx>
    To change your delivery options, retrieve your password, or
    unsubscribe from this list, visit
    https://www.eclipse.org/mailman/listinfo/cdt-dev


_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/cdt-dev


Back to the top