Ignore:
Timestamp:
02/23/06 15:06:51 (19 years ago)
Author:
remar
Message:
  • added a new kind of problem marker; unexpected namespace marker. This marker is added to a file if the classes defined in the file don't exist in the namespace that is expected (given the file hierarchy and so)
  • files with namespace problems (missing or bad within statement) will not have their contents shown
  • the Type parser now throws an IllegalTypeException? if it can't parse the type
  • class definitions inside the package definition of package.mo is now placed as direct children of package.mo in the project tree
  • improved OMC status log messages (hopefully more clear)
File:
1 edited

Legend:

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

    r340 r363  
    5353import org.eclipse.core.runtime.Platform;
    5454import org.modelica.mdt.core.IModelicaClass;
     55import org.modelica.mdt.core.IllegalTypeException;
    5556import org.modelica.mdt.core.List;
    5657import org.modelica.mdt.core.ListElement;
     
    178179        }
    179180       
    180         logOMCStatus("will look for OMC object reference in '"
    181                 + fileName + "'");
     181        logOMCStatus("Will look for OMC object reference in '"
     182                + fileName + "'.");
    182183       
    183184        return fileName;
     
    200201            final String m = "Environment variable OPENMODELICAHOME not set";
    201202            logOMCStatus("Environment variable OPENMODELICAHOME not set,"+
    202                     " don't know how to start OMC");
     203                    " don't know how to start OMC.");
    203204            throw new ConnectException(m);
    204205        }
     
    221222        if(f.exists())
    222223        {
    223             logOMCStatus("removing old OMC object reference file");
     224            logOMCStatus("Removing old OMC object reference file.");
    224225            f.delete();
    225226        }
     
    228229        try
    229230        {
    230             logOMCStatus("running command " + command[0] + " " + command[1]);
     231            logOMCStatus("Running command " + command[0] + " " + command[1]);
    231232            Runtime.getRuntime().exec(command);
    232             logOMCStatus("command run successfully");
     233            logOMCStatus("Command run successfully.");
    233234        }
    234235        catch(IOException e)
     
    239240             * source). Try starting OMC from this secondary location.
    240241             */
    241             logOMCStatus("error running command " + e.getMessage()
    242                     + "\ntrying allternative path to the binary");
     242            logOMCStatus("Error running command " + e.getMessage()
     243                    + ", trying alternative path to the binary.");
    243244            String secondaryPathToOmc = null;
    244245            try
     
    255256                command =
    256257                    new String[]{secondaryPathToOmc, "+d=interactiveCorba"};
    257                 logOMCStatus("running command "
     258                logOMCStatus("Running command "
    258259                        + command[0] + " " + command[1]);
    259260                Runtime.getRuntime().exec(command);
    260                 logOMCStatus("command run successfully");
     261                logOMCStatus("Command run successfully.");
    261262            }
    262263            catch(IOException ex)
    263264            {
    264                 logOMCStatus("error running command, giving up");
     265                logOMCStatus("Unable to start OMC, giving up.");
    265266                throw new ConnectException
    266                     ("Unable to start Open Modelica Compiler. "
     267                    ("Unable to start the OpenModelica Compiler. "
    267268                     + "Tried starting " + pathToOmc
    268269                     + " and " + secondaryPathToOmc);
     
    270271        }
    271272
     273        logOMCStatus("Wait for OMC CORBA object reference to appear on disk.");
     274       
    272275        /*
    273276         * Wait until the object exists on disk, but if it takes longer than
     
    290293            if(ticks > 50)
    291294            {
    292                 logOMCStatus("no OMC object reference file created after " +
    293                         "approximatly 5 seconds\n" +
    294                         "it seems OMC does not want to come up, giving up");
     295                logOMCStatus("No OMC object reference file created after " +
     296                        "approximately 5 seconds.");
     297                logOMCStatus("It seems OMC does not want to come up, giving " +
     298                        "up.");
    295299                throw new ConnectException
    296300                    ("Unable to start the Open Modelica Compiler. Waited for 5"
     
    298302            }
    299303        }
     304        logOMCStatus("OMC object reference found.");
    300305    }
    301306   
     
    363368        {
    364369            /* If a server isn't running, start it */
    365             logOMCStatus("no OMC object reference found");
     370            logOMCStatus("No OMC object reference found, starting server.");
    366371            startServer();
    367372        }
    368373        else
    369374        {
    370             logOMCStatus("OMC object reference present," +
    371                     " assuming OMC is running");
     375            logOMCStatus("Old OMC CORBA object reference present," +
     376                    " assuming OMC is running.");
    372377        }
    373378       
     
    389394             * catch an exception and try starting a server.
    390395             */
    391             logOMCStatus("trying to send expression to OMC");
     396            logOMCStatus("Trying to send expression to OMC.");
    392397            omcc.sendExpression("1+1");
    393             logOMCStatus("expression send successfully");
     398            logOMCStatus("Expression sent successfully.");
    394399        }
    395400        catch(org.omg.CORBA.COMM_FAILURE e)
    396401        {
    397402            /* Start server and set up omcc */
    398             logOMCStatus("failed sending expression");
     403            logOMCStatus("Failed sending expression, will try to start OMC.");
    399404            startServer();
    400405            stringifiedObjectReference = readObjectFromFile();
     
    406411                 * time it's time to send back an exception to the caller of
    407412                 * this function. */
    408                 logOMCStatus("trying to send expression to OMC");
     413                logOMCStatus("Trying to send expression to OMC.");
    409414                omcc.sendExpression("1+1");
    410                 logOMCStatus("expression send successfully");
     415                logOMCStatus("Expression sent successfully.");
    411416            }
    412417            catch(org.omg.CORBA.COMM_FAILURE x)
    413418            {
    414                 logOMCStatus("failed sending expression, giving up");
     419                logOMCStatus("Failed sending expression, giving up.");
    415420                throw new ConnectException("Unable to start the OpenModelica"
    416421                        +" Compiler.");
     
    450455        catch(org.omg.CORBA.COMM_FAILURE x)
    451456        {
     457            logOMCCallError("Error while sending expression " + exp + " ["+x+"]");
    452458            /* lost connection to OMC or something */
    453459            throw new ConnectException("Couldn't send expression to the "+
     
    471477        }
    472478        System.out.println(">> " + expression);
     479    }
     480   
     481    /**
     482     * outputs the message about a call error that occured
     483     * when communicating with omc
     484     * @param message the message to log
     485     */
     486    private static void logOMCCallError(String message)
     487    {
     488        if(!traceOMCCalls)
     489        {
     490            return;
     491        }
     492        System.out.println(message);
    473493    }
    474494   
     
    542562     */
    543563    public IModelicaClass.Type getRestrictionType(String className)
    544         throws ConnectException
     564        throws ConnectException, UnexpectedReplyException
    545565    {
    546566        String reply =
    547567            sendExpression("getClassRestriction(" + className + ")");
    548        
     568
    549569        /* remove " around the reply */
    550570        reply = reply.trim();
     571       
     572        if(reply.equals(""))
     573        {
     574            throw new UnexpectedReplyException("getClassRestriction("+className
     575                    +") returned an empty result");
     576        }
     577       
    551578        reply = reply.substring(1, reply.length()-1);
    552579       
     
    554581        getErrorString();
    555582       
    556         return IModelicaClass.Type.parse(reply);
     583        IModelicaClass.Type type = null;
     584        try
     585        {
     586            type = IModelicaClass.Type.parse(reply);
     587        }
     588        catch(IllegalTypeException e)
     589        {
     590            throw new UnexpectedReplyException("Illegal type: "
     591                    + e.getMessage());
     592        }
     593       
     594        return type;
    557595    }
    558596   
     
    604642        if(retval.toLowerCase().contains("error") || retval.equals("{}"))
    605643        {           
    606             res.setCompileErrors
    607                 (OMCParser.parseErrorString(getErrorString()));
     644            res.setCompileErrors(OMCParser.parseErrorString(getErrorString()));
    608645            res.setClassNames(new List());
    609646        }
Note: See TracChangeset for help on using the changeset viewer.