Ignore:
Timestamp:
12/13/05 10:44:11 (19 years ago)
Author:
boris
Message:
  • added support for browsing class components
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/org.modelica.mdt/src/org/modelica/mdt/internal/omcproxy/OMCProxy.java

    r204 r210  
    5454import org.modelica.mdt.core.IModelicaClass;
    5555import org.modelica.mdt.core.IModelicaClass.Type;
     56import org.modelica.mdt.internal.core.ElementLocation;
    5657import org.omg.CORBA.ORB;
    5758
     
    5960 * The OMCProxy is the glue between the OpenModelica Compiler and MDT.
    6061 * It uses the interactive API of OMC to get information about classes
    61  * and to load classes into OMC.
     62 * and to load classes into OMC.
     63 *
    6264 * @author Andreas Remar
    63  *
    6465 */
    6566public class OMCProxy
     
    708709
    709710        String[] tokens = ProxyParser.parseSimpleList(retval);
    710         int line, column;
     711        int line;
    711712
    712713        try
    713714        {
    714715            line = Integer.parseInt(tokens[1]);
    715             column = Integer.parseInt(tokens[2]);
    716716        }
    717717        catch (NumberFormatException e)
     
    721721        }
    722722       
    723         return new ElementLocation(tokens[0], line, column);
     723        return new ElementLocation(tokens[0], line);
    724724    }
    725725   
     
    739739   
    740740    /**
    741      * NOT IMPLEMENTED
    742      * This function returns the info about this element that getElementsInfo
    743      * returns.. somehow
    744741     * @param className
    745742     * @return
    746743     * @throws ConnectionException
    747      */
    748     public static ElementsInfo getElementsInfo(String className)
    749         throws ConnectionException
    750     {
    751         // TODO actually return real elements info..
     744     * @throws InvocationError
     745     * @throws UnexpectedReplyException
     746     */
     747    public static Vector<Object> getElementsInfo(String className)
     748        throws ConnectionException, InvocationError, UnexpectedReplyException
     749    {
    752750        String retval = sendExpression("getElementsInfo("+ className +")");
    753         Vector<Object> v = ProxyParser.parseList(retval);
    754         System.out.println(v);
    755        
    756         return new ElementsInfo();
     751       
     752        /*
     753         * we need a efficient way to check if the result is
     754         * humongosly huge list or 'Error' or maybe 'error'
     755         */
     756        for (int i = 0; i < retval.length(); i++)
     757        {
     758            if (retval.charAt(i) == '{')
     759            {
     760                /* we found the begining of the list, let's hope for the best */
     761                return ProxyParser.parseList(retval);       
     762            }
     763            else if (retval.charAt(i) == 'E' || retval.charAt(i) == 'e')
     764            {
     765                /*
     766                 * this is the unreadable way to check if the retval
     767                 * equals 'Error' or 'error'
     768                 */
     769                if (retval.substring(i+1,i+5).equals("rror"))
     770                {
     771                    throw new InvocationError("getElementsInfo("+ className +")" +
     772                        " replays 'error'");
     773                }
     774                else
     775                {
     776                    /* OMC returned someting wierd, panic mode ! */
     777                    break;
     778                }
     779            }
     780        }
     781        /* we have no idea what OMC returned */
     782        throw new UnexpectedReplyException("getElementsInfo("+ className +")" +
     783                        "replays:'" + retval + "'");
     784       
    757785    }
    758786}
Note: See TracChangeset for help on using the changeset viewer.