Ignore:
Timestamp:
02/23/06 21:29:38 (19 years ago)
Author:
boris
Message:
  • implement code completion based in unqualified imports, boowaa !
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/org.modelica.mdt.test/src/org/modelica/mdt/test/TestModelicaCompletionProcessor.java

    r370 r372  
    215215                foundModelicaMechanicsProp);
    216216
    217         /* overwrite 'Modelica.M' with 'Modelica.Math.' */
     217        /* type 'Mechanics.Rotational.Sp' inside import_rich_model */
     218        editor.doRevertToSaved();
     219        doc.replace(383, 0, "Mechanics.Rotational.Sp");
     220
     221        /* get proposals at the end of 'Modelica.M' */
     222        props = compProc.computeCompletionProposals(textViewer,
     223                383 + "Mechanics.Rotational.Sp".length());
     224
     225        /*
     226         * we are expecting a proposal for the Mechanics.Rotational.Speed and
     227         * Mechanics.Rotational.Spring packages
     228         */
     229        boolean foundSpeedProp = false;
     230        boolean foundSpringDamperProp = false;
     231       
     232        for (ICompletionProposal proposal : props)
     233        {
     234            if (proposal.getDisplayString().startsWith("Speed"))
     235            {
     236                proposal.apply(doc);
     237                result = doc.get(383, "Mechanics.Rotational.Speed".length());
     238                assertEquals("unexpected result of applying proposal",
     239                        "Mechanics.Rotational.Speed", result);
     240                foundSpeedProp = true;
     241                undoManager.undo();
     242            }
     243            else if (proposal.getDisplayString().startsWith("SpringDamper"))
     244            {
     245                proposal.apply(doc);
     246                result = doc.get(383,
     247                        "Mechanics.Rotational.SpringDamper".length());
     248                assertEquals("unexpected result of applying proposal",
     249                        "Mechanics.Rotational.SpringDamper", result);
     250                foundSpringDamperProp = true;
     251                undoManager.undo();
     252            }
     253        }
     254        assertTrue("did not found proposal for the Mechanics.Rotational.Speed",
     255                foundSpeedProp);
     256        assertTrue("did not found proposal for the Mechanics.Rotational.SpringDamper",
     257                foundSpringDamperProp);
     258       
     259       
     260        /* type 'Modelica.Math.' */
    218261        editor.doRevertToSaved();
    219262        doc.replace(383, 0, "Modelica.Math.");
     
    284327        assertTrue("did not found proposal for the 'Modelica.Math.log'",
    285328                foundModelicaMathLogProp);
     329       
     330        /*
     331         * test completion proposals in 'the middle of nowhere'
     332         * in a place where the prefix will be empty (the '' string)
     333         */
     334        editor.doRevertToSaved();
     335        props = compProc.computeCompletionProposals(textViewer, 383);
     336
     337        /*
     338         * we are expecting a proposal for among others Blocks,
     339         * Icons and hehehe
     340         */
     341        boolean foundBlocksProp = false;
     342        boolean foundIconsProp = false;
     343        boolean foundHeheheProp = false;
     344       
     345        for (ICompletionProposal proposal : props)
     346        {
     347           
     348            if (proposal.getDisplayString().startsWith("Blocks"))
     349            {
     350                proposal.apply(doc);
     351                result = doc.get(383, "Blocks".length());
     352                assertEquals("unexpected result of applying proposal",
     353                        "Blocks", result);
     354                foundBlocksProp = true;
     355                undoManager.undo();
     356            }
     357            else if (proposal.getDisplayString().startsWith("Icons"))
     358            {
     359                /* must be Modelica.Math.cos proposal */
     360                proposal.apply(doc);
     361                result = doc.get(383, "Icons".length());
     362                assertEquals("unexpected result of applying proposal",
     363                        "Icons", result);
     364                foundIconsProp = true;
     365                undoManager.undo();
     366            }
     367            else if (proposal.getDisplayString().startsWith("hehehe"))
     368            {
     369                /* must be Modelica.Math.exp proposal */
     370                proposal.apply(doc);
     371                result = doc.get(383, "hehehe".length());
     372                assertEquals("unexpected result of applying proposal",
     373                        "hehehe", result);
     374                foundHeheheProp = true;
     375                undoManager.undo();
     376            }           
     377        }
     378       
     379        assertTrue("did not found proposal for the 'Blocks'",
     380                foundBlocksProp);
     381        assertTrue("did not found proposal for the 'Icons'",
     382                foundIconsProp);
     383        assertTrue("did not found proposal for the 'hehehe'",
     384                foundHeheheProp);
    286385       
    287386        /* type 'm' inside import_rich_model */
Note: See TracChangeset for help on using the changeset viewer.