Home
A Language Development Environment for Eclipse
Contents
1. Figure 2 2 Architecture of the Meta Environment using the ToolBus Target architecture using Eclipse for both GUI and editors Eclipse exports many GUI features that can be used to write plugins and also has a built in editor which implements the required Meta Environment text editor interface From an Eclipse point of view it is interesting to be able to reuse the generic language technology offered by the Meta Environment From the Meta Environment point of view it would be interesting to see if Eclipse could be used to implement the GUI and the text editors the dotted rectangle in Figure 2 2 From a TOOLBUS point of view it is interesting to see how a single tool Eclipse in this case can serve as the implementation of multiple components both GUI and text editor 2 3 Implementation In Section 2 3 1 we describe some of the implementation details of the current Meta Environment GUI In the target architecture we replace both the JFC Swing GUI and the external text editors by Eclipse as described in Section 2 3 2 2 3 1 JFC Swing based implementation The TOOLBUS principle to separate functionality leads to a generic implemen tation of the user interface To meet the Meta Environment requirements the user interface only has to implement some basic functionality The JFC Swing implementation extends the Meta Environment with a GUI that supports sev eral components a tree panel graph panel and some informational panels The tr
2. A Language Development File SE D classDect E comment D constructordeci D expressions D Fieladec D interfaces Dax D Javatypes D texicat D methodDeci D Modifiers D Names D statements basic Environment for Eclipse A T Kooiker January 2004 t Run Window Help aaa x Module Explorer x LocalVariableDeclaration gt lt START gt l rator gt LocalVariableDeclaration cons comma VariableDeclarator Id Variablelnitializer CH ClassOrlnterf Ad basic Name gt Identifier D lt identifier Li ClassDecl E Statements El Expressions El Javatypes El Names D Lexical El FieldDecl El Modifiers El MethodDecl El Interfaces E ConstructorDecl El Comment DI Log Status Master s Thesis in Computer Science Programming Research Group Faculty of Science University of Amsterdam Supervisors prof dr P Klint drs H A de Jong Contents Introduction Jul A ara EE A Bath I 1 2 Acknowledgements A Language Development Environment for Eclipse ST Tntroduction s sis a ha a OOH Leali Yee 2 1 1 Eclipse Plugin Technology 2 1 2 Meta Environment Technology 2 2 Architectural considerations 2 3 Implementation a a ane n LEE La eu iaa 2 3 1 JFC Swing b
3. In most cases this is the behavior a user wants to have But in the Meta Environment you want the module to be loaded along with the transitive closure of its imports Because the procedure of opening a file from within the Resource Navigator cannot be interrupted yet this results in a file being loaded in the Meta Plugin text editor but not loaded in the Meta Environment leaving the Meta Environment in an inconsistent state Therefore parsing the file for example results in errors or even worse the Meta Environment stops responding due to its inconsistent state The correct way of opening a module in the Meta Plugin is using the Open Module button in the Meta Plugin toolbar which loads the module selected in 32 CHAPTER 6 ECLIPSE META PLUGIN Module Explorer x gt basic EN E ClassDecl E Statements E Expressions JavaTypes m D Names E Lexical FieldDecl Modifiers MethodDecl Interfaces D ConstructorDecl mm Comment Figure 6 2 Module Explorer the Resource Navigator and the transitive closure of its imports The loaded modules are shown in the Module Explorer which will be described in Sec tion 6 3 2 When all the required modules have been loaded in the Meta Environment a file selected in the Resource Navigator can be edited by opening it from within the Resource Navigator A better way to edit files is to use the functionality of the Module Explorer This ensures that all req
4. snd ack event UE eclipse open modules ModuleList Type snd msg ui event eclipse open modules ModuleList Type rec event UE eclipse open initial module ModuleName snd ack event UE eclipse open initial module ModuleName snd msg ui event eclipse open initial module ModuleName rec event UE eclipse edit term file ModuleName FileName snd ack event UE eclipse edit term file ModuleName FileName snd msg ui event eclipse edit term file ModuleName FileName rec event UE button selected Type ActionEvent snd ack event UE button selected Type ActionEvent snd msg ui event button selected Type ActionEvent rec msg show file dialog Title Path Extension snd eval UE show file dialog Title Path Extension rec value UE file name FileName snd msg ui value file name FileName rec msg show question dialog Title snd eval UE show question dialog Title rec value UE answer Answer snd msg ui value answer Answer rec msg clear history snd do UE clear history rec event UE element selected ModuleName Tree snd ack event UE element selected ModuleName Tree snd msg ui event element selected ModuleName Tree rec event UE node info ModuleName Tree snd ack event UE node info ModuleName Tree snd msg ui event node info ModuleName Tree rec msg update list ModuleName ButtonNames snd do UE update list ModuleName ButtonNames 44 APP
5. snd do value focus B rec do value focus B snd value focus B rec value focus B H 2 E ToolBus Process A TransAdapter M Merged process ToolBus Tool E Eclipse S Stub process TransAdapter M Meta ToolBus process Figure 5 4 Message sequence chart of snd eval Figure 5 3 The letters and numbers in this figure refer to the corresponding letters and numbers in Figure 5 2 Because the TransAdapter A has been implemented as a TOOLBUS tool the first step is the same as for normal tools The Meta Environment process editor hive M sends the message goto 10 to A via 1 The only way a tool can send a message to a TOOLBUS is using an event A will therefore pack the goto 10 message in an event and sends it to the stub process P in the Proxy TooLBus via 2 P will acknowledge this event and forwards the message in the event to the merged process M via 3 M on its turn will send the goto 10 message to Eclipse E via 4 using a snd do primitive As can be seen the message sent to Eclipse by M is the same one as sent by M 5 5 2 Transformation of snd eval When a computation is needed a snd eval message is sent to the tool that does the actual computation After this computation the tool will send the result back Using a TransAdapter see Figure 5 4 the first part of a snd 28CHAPTER 5 CONNECTING ECLIPSE TO THE META ENVIRONMENT M A Ss M E snd event button parse rec event button pars
6. Eclipse Section 2 4 2 2 4 1 Meta Environment issues Complex editor management Before we started integrating the Meta Environment and Eclipse all text editor management was handled in several TOOLBUS processes For each editing session the TOOLBUS invoked a new instance of the system editor This conflicted with Eclipse because Eclipse al ready handles multiple editor instances itself Since the original setup was quite complex we decided to encapsulate this complexity in a separate tool The 12CHAPTER 2 ALANGUAGE DEVELOPMENT ENVIRONMENT FOR ECLIPSE Parser Generator Parser Unparser I O Tool Interpreter Meta ToolBus O Term Store Compiler User Interface Structure Editor Editor Proxy ToolBus Eclipse Figure 2 3 Eclipse as implementation of the GUI and text editors JFC Swing implementation now uses this tool the Eclipse setting handles the editor management inside Eclipse itself 2 4 2 Eclipse issues Most of the Meta Environment functionality present in the JFC Swing version was implemented equally well in the Eclipse version but we did encounter some difficulties which we would hope to see eliminated in a future version of Eclipse No support for File Open dialog An important difference between the current Meta Environment and Eclipse is exposed when we consider how to open new modules The current JFC Swing implementation delegates open module events to the TOOLBUS wh
7. Eclipse editors can ask for that table with keywords before displaying any text By extending the Eclipse editor with the already provided partitioner syntax highlighting in Eclipse can be enabled The basic partitioner consists of a static table with keywords that have to be highlighted But in stead of this static table a TOOLBUS message can be used to provide the partitioner with the keywords found in the SDF specification of the particular module When opening a term over a module the editor first has to ask for the keyword table 7 3 Help Facilities The current Meta Environment does not provide any help facilities which could easily be provided by Eclipse via its built in help functionality Not only can a user manual be added but also help on ASF SDF modules or on grammatical structures of user defined programming languages Help facilities are provided in several ways e in a webbrowser user manual or JavaDoc style help e in an Eclipse view which has to be implemented yet e as tooltips when hovering with a mouse over keywords or grammatical structures 7 4 Other Distributable plugin The Eclipse Meta Plugin is not available for download as a complete and easy to install plugin To make the plugin available it is necessary to determine the packages the plugin depends on and make those available for distribution Depending if the distribution has to include the source files build path and plugin preferences have to be set
8. Environment 3 6 is a programming environments generator given a language definition consisting of a syntax definition gram mar and tool descriptions using rewrite rules a language specific environment is generated A language definition typically includes such features as pretty printing type checking analysis transformation and execution of programs in the target language The Asr SDF Meta Environment is used to create tools for domain specific languages and for the analysis and transformation of soft ware systems As the Eclipse and Meta Environment technologies are to a large extent complementary it is worthwhile to investigate how they can be integrated l Available at www eclipse org cdt 2 Available at www eclipse org cobol 8CHAPTER 2 ALANGUAGE DEVELOPMENT ENVIRONMENT FOR ECLIPSE 2 1 1 Eclipse Plugin Technology The Eclipse Platform is designed for building integrated development environ ments IDEs 7 An IDE can be built by providing the Eclipse Platform with a plugin contributing to an extension point of some other plugin In fact the Eclipse Platform is a number of plugins itself It consists of a small kernel which starts all necessary plugins to run a basic instance of the Eclipse Platform All other functionality is located in plugins which extend these basic plugins In this way Eclipse provides tool providers with a mechanism that leads to seamlessly integrated tools Eclipse plugins are written in JAVA and c
9. The user interface idef handles all messages to and from the user interface part of the Meta Environment All messages to the Meta Environment are directed by using a common wrapper for addressing the right TransAdapter in the case of the user interface process this is ui process UI UE user environment is let Id term Str str Pairs list Mods list FileName str Path str Extension str On term Graph term Info list LayoutedGraph term ModuleName str EnvironmentName str Graphld str ActionEvent term Tree term ButtonNames str ButtonList list Title str Answer term Type term Arguments list ModuleList term in rec msg initialize ui EnvironmentName snd do UE initialize ui EnvironmentName rec msg add status Id Str 41 42 APPENDIX B THE USER INTERFACE IDEF snd do UE add status Id Str rec msg add statusf Id Str Arguments snd do UE add statusf Id Str Arguments rec msg end status Id snd do UE end status Id rec msg error Str snd do UE error Str rec msg errorf Str Arguments snd do UE errorf Str Arguments rec msg warning Str snd do UE warning Str rec msg warningf Str Arguments snd do UE warningf Str Arguments rec msg message Str snd do UE message Str rec msg messagef Str Arguments snd do UE messagef Str Ar
10. back whereafter the message could be sent to the editor process The editor process in its turn takes care of spawning an editor e g gvim or x emacs and setting up a connection with this editor to be able to communicate with it 5 2 1 Editor Manager While using the Meta Environment more than one editing session at a time can be active for editing modules and terms To be able to address each editor a unique identifier is assigned to each editing session Administration of this session identifier is done by the editor manager When communication with a specific editing session is needed a request is sent to the editor manager to return the session identifier This session identifier can be used in the further communication with the editing session In the case that there is no session identifier found a new session identifier will be generated This new identifier will be returned with a message notifying the receiver that a new editor has been spawned for this editing session After an editing session has been closed the editor manager will be notified of the regarding session identifier and takes care of removing this session identifier from the registered identifiers 5 2 2 Editor Hive Orignally each editing session had its own correspoding TOOLBUS process To be able to address each editing session a lot of administration had to be done in the TooLBus This was thought of as a bad habit because the TooLBus itself is primarily meant to d
11. than one process 5 1 Introduction Making a connecting between Eclipse and the Meta Environment consisted of changing the way the Meta Environment made use of editors and creating an interconnection architecture between the Meta Environment and Eclipse This chapter roughly consists of two parts The first part describes the way editors worked and why this had to be changed Section 5 2 whereas the second part describes the interconnection architecture Section 5 3 to provide a middleware solution to connect Eclipse to the Meta Environment 5 2 Editors and the Meta Environment Although one of the goals of this thesis was to make a connection between Eclipse and the Meta Environment without making changes to the Meta Environment there were some pending changes that had to be made before a connection between Eclipse and the Meta Environment could be made Before making the connection with Eclipse the Meta Environment contained an editor manager process which would invoke editor processes when needed For each editing session such an editor process would be spawned and registered with the editor manager The Meta Environment could communicate with a specific editor via a rout ing mechanism A message could be sent to a specific editor by requesting the editor identifier from the editor manager The editor manager would then 21 22CHAPTER 5 CONNECTING ECLIPSE TO THE META ENVIRONMENT lookup the matching editor process and send the result
12. the structure of a graph including its nodes and edges The generated API provides a way to extract the various elements of a graph from messages received from the Meta Environment After extracting 34 CHAPTER 6 ECLIPSE META PLUGIN E MetastudioPlugit X PerspectiveFactory trm MetastudioConnection trm pe Returns the string from the plugin s resource bundle or key if not found wa public static String getResourceString String key ResourceBundle bundle MetastudioPlugin getD efault getResourceBundle try return bundle getString key catch MissingResourceException e return key Returns the plugin s resource bundle ii public ResourceBundle getResourceBundle return resourceBundle public static ImageDescriptor getimageDescriptor String name Sing iconPath icons i try URL installURL getDefault getDescriptor getInstallURL0 URL url new URL installURL iconPath name return ImageDescriptor createFromURL url catch MalformedURLException e I should not happen return ImageDescriptor getMissinglmageDescriptor ci D Figure 6 4 Meta Plugin editor these elements the graph can be drawn on a canvas 6 4 Editor The editor used for editing modules and terms is based on the plain text editor already provided by Eclipse This editor has been extended with methods for setting focus and moving the cursor to provide all functiona
13. tool to multiple TOOLBUS processes 4 4 1 Solution 1 Two JavaAdapters The general solution to connect a tool to the TOOLBUS is using a adapter Because Eclipse is entirely written in JAVA makes the decision to make use of the JavaAdapter an easy one The fact that Eclipse has to replace two tools Editor Hive and User Interface and each tool has to connect to the TOOLBUS via its own adapter results in the use of two JavaAdapters Figure 4 2 shows the result of this setup one tool connects via two JavaAdapters to two processes Unfortunately this design leads to threading problems In Eclipse the user interface runs in its own thread Non user interface methods have to run in their own threads to prevent the user interface from being irresponsive While using one JavaAdapter to connect to one of the processes did work using a second JavaAdapter blocked user interface and TOOLBUS access It became clear that using more than two threads in JAVA leads to problems in Eclipse locking all threads One solution to this problem was using another Java Virtual Machine but we came up with another solution in the form of a proxy between the TOOLBUS and Eclipse 4 4 2 Solution 2 Proxy TooLBus While connecting Eclipse with two JavaAdapters could have worked a more challenging solution is thinking of Eclipse as one tool that has to connect to one process while leaving the Meta Environment intact This solution fits the idea that one tool connects to o
14. ENDIX B rec event UE quit snd msg ui event quit rec disconnect UE shutdown MetaStudio exiting n endlet THE USER INTERFACE IDEF Appendix C The editor hive idef The editor hive idef handles all message to and from the Meta Environment editor hive All messages to the Meta Environment are directed by using eh as wrapper to address the right TransAdapter process Hive UE user environment is let ActionList list EditorId term Editor str FileName str Focus term FocusText str Location int MenuEvent term Message str MouseEvent int in rec msg edit file EditorId Editor FileName snd do UE edit file EditorId Editor FileName rec msg set actions EditorId ActionList snd do UE set actions EditorId ActionList rec msg reread contents EditorId snd do UE reread contents Editorld rec msg set focus EditorId Focus snd do UE set focus EditorId Focus rec msg get contents EditorId Focus snd do UE get contents EditorId Focus rec msg clear focus EditorId snd do UE clear focus EditorId rec msg display message EditorId Message snd do UE display message EditorId Message 45 46 APPENDIX C THE EDITOR HIVE IDEF rec msg set cursor at location EditorId Location snd do UE set cursor at location EditorId Location rec msg set cursor at focus EditorId Focus snd do UE s
15. LBUS coordination processes The coordination between TOOLBUS components tools is orchestrated by pro cesses Each tool connected to the TOOLBUS has its own TOOLBUS process Figure 4 1 shows a schematic view of the TooLBus Circles indicate the various processes whereas squares indicate tools Communication between processes can be done either synchronously or asyn chronously The TOOLBUS script primitive snd msg is used for synchronous 17 18 CHAPTER 4 TOOLBUS Figure 4 1 Schematic view of the TooLBUs communication When using this primitive a process can only send a message to another process when this other process is able to receive the message When there is no process available for receiving this message the sending process will block until it can deliver the message Asynchronous communication can be used if it is not sure that there are receiving processes The primitive snd note must be used to send an asyn chronous message To be able to receive this message a process has to be subscribed to the message Even if there are no receiving processes the sending process will go on after sending its message Communication between processes and tools is bidirectional Processes can send messages to connected tools using the snd do and snd eval primitives A snd eval message sends an evaluation request to a tool After evaluating the message the tool has to return a value in a snd value message A snd do message just notifies th
16. Meta TooLBus and Proxy TOOLBUS startup At this moment the Meta TooLBus and Proxy TOOLBUS are started using a startup script This script ensures the Meta TOOLBUS is initiated with port 8999 and the Proxy TOOLBUS with port 9000 The Eclipse Meta Plugin can be extended with a method start ing these TOOLBUSES at other ports than the ones used in the script By first finding two available ports and passing these ports in the startup parameters of the TOOLBUSES and the connecting TransAdapters the startup script can be eliminated and other ports could be used Bibliography 1 J A Bergstra J Heering and P Klint editors Algebraic Specification ACM Press Addison Wesley 1989 J A Bergstra and P Klint The discrete time ToolBus a software coor dination architecture Science of Computer Programming 31 2 3 205 229 1998 M G J van den Brand A van Deursen J Heering H A de Jong M de Jonge T Kuipers P Klint L Moonen P A Olivier J Scheerder J J Vinju E Visser and J Visser The ASF SDF Meta Environment a Component Based Language Development Environment In R Wilhelm editor Compiler Construction CC 01 volume 2027 of Lecture Notes in Computer Science pages 365 370 Springer Verlag 2001 A van Deursen J Heering and P Klint editors Language Prototyping An Algebraic Specification Approach volume 5 of AMAST Series in Computing World Scientific 1996 H A de Jong and P A Olivier Generation of a
17. a tool sends an event to its corresponding process Figure 5 5 shows the message sequence chart of the rec event primitive When E has send an event to M this process will respond with an ac knowledgement message Hereafter it wraps the event with the message sort event in this case and the correct process identifier The wrapped message will be received by P which passes the message to the TransAdapter A The TransAdapter constructs an event and will send it to M which will return an acknowledgement on its turn Chapter 6 Eclipse Meta Plugin The Eclipse Meta Plugin is the implementation of the graphical user interface of the JFC Swing Meta Environment as an Eclipse plugin This chapter covers all plugin elements and their internals in order of appearance 6 1 Introduction The Eclipse Meta Plugin is a plugin that enables the Eclipse user to make use of the features of the ASF SDF Meta Environment Therefore all graphical user interface GUI elements provided by the Meta Environment had to be imple mented in Eclipse In this chapter we will focus on the several GUI elements of the EclipseMeta Plugin and some of the shortcomings of Eclipse 6 2 Plugin xml The starting point of an Eclipse plugin is the plugin xml file which describes in which way the Eclipse Platform will be extended and provides a way to make your own extension points All GUI elements are listed in this file e g Text Editor Module Explorer and Module Info
18. as well as registered file extensions sdf asf and trm as well as the startup class which will be run when the plugin is started Unfortunately the plugin ml restricts the dynamic behavior of the Eclipse Platform On the one hand it is an easy way to determine which plugins are available at startup of the Eclipse Platform On the other hand it defines the elements of the Eclipse plugin in a static way One of the important things of the Meta Environment is the ability to define your own programming language Most programming languages are associated with their own file extensions which have to be registered in the plugin xml if you want Eclipse to open the corresponding text editor This makes that the user has to know beforehand which programming languages and thus file extensions he or she wants to use in the Meta EnvironmentThose file extensions can then be added to the plugin xml After re starting the Meta Environment plugin Eclipse will use the preferred editor for the newly registered files 29 30 CHAPTER 6 ECLIPSE META PLUGIN 6 3 Meta Environment Perspective After starting Eclipse and selecting the Meta Environment Perspective the per spective extension class as described in the plugin xml file will be started The PerspectiveFactory as this class has been called takes care of initiating the connection with the Proxy TOOLBUS described in Section 5 3 by instatiating an object of type UserInterface The UserInterface
19. ased implementation 2 3 2 Eclipse based implementation 2 4 Lessons learned 2 4 1 Meta Environment issues 2 4 2 Eclipse issues 2 0 CONCLUSIONS peer a Ae ee ee A a a ASF SDF Meta Environment 3 1 Antroduct Otis mai eg aS ee ee ee A Reel pes 3 2 Graphical User Interface and Editors TooLBus 41 Introduction 4 08 6 e AA A eee 4 2 TooLBus coordination processes 4 3 TOOLBUS computation tools 4 4 The TooLBus and Eclipse 4 4 1 Solution 1 Two JavaAdapters 4 4 2 Solution 2 Proxy TOOLBUS Connecting Eclipse to the Meta Environment bd Introduction ses ae Sete hee Bae eh ge hee e Bae 5 2 Editors and the Meta Environment 5 2 1 Editor Manager sot Ze ee PE Owe I 5 22 Editor Hives oda Be ra Ae Ae 0 9 Proxy LOOLBUS 24 i 4 44k a aaa dd 5 31 Stub process iii a eee ALA a e 5 3 2 Merging processes 5 4 Trans Adapter ic ere A L ones Sue ad 15 15 16 17 17 17 18 18 19 19 5 5 TransAdapter protocol 5 5 1 snd do messages 5 5 2 Transformation of snd eval 5 5 3 Transformation of rec event Eclipse Meta Plugin 6 1 Introduction 62 Plugin osare eme da Ba ai 6 3 Meta Environment Perspective 6 3 1 Resource Nav
20. ature from the process it is connected to This signature can be safely ignored as long as Eclipse or any other tool that has to connect to more than one process implements these messages This can be ensured by merging these messages in the merged process and sending the signature of the merged process to Eclipse The delegate side indicated by a boxed 2 in Figure 5 2 of the TransAdapter connects to the Proxy TooLBus A stub process in the Proxy TooLBus will 26CHAPTER 5 CONNECTING ECLIPSE TO THE META ENVIRONMENT M A S M E snd do T goto 10 rec do goto 10 snd event goto 10 rec event T goto 10 snd ack event T goto 10 rec ack event goto 10 snd msg goto 10 rec msg goto 10 snd do E goto 10 rec do goto 10 a ToolBus Process A TransAdapter M Merged process ToolBus Tool E Eclipse S Stub process TransAdapter M Meta ToolBus process Figure 5 3 Message sequence chart of snd do forward all messages from and to the TransAdapter A tool can only send events as initial message and therefore all messages received at the masquerade side of the TransAdapter will be forwarded as events to the stub process in the Proxy TooLBus via the delegate side Events and return values from Eclipse are received at the delegate side The stub process sends them wrapped in a message identifier Depending on this message identifier the TransA dapter will send an event or a return valu
21. bstract programming inter faces from syntax definitions Technical Report SEN R0212 St Centrum voor Wiskunde en Informatica CWI August 2002 To appear in Journal of Logic and Algebraic Programming P Klint A meta environment for generating programming environments ACM Transactions on Software Engineering and Methodology 2 176 201 1993 Eclipse platform technical overview Object Technology International Inc 2003 37 38 BIBLIOGRAPHY Appendix A The merged process The merged process as described in Section 5 3 2 is one of the processes receding in the Proxy TOOLBus described in Chapter 5 For the readers who are known to the TOOLBUS scripting language the TOOLBUS script used for the Eclipse Meta Plugin to be able to handle messages from both the user interface and the editor hive is shown below As described in Chapter 5 the merged process consists of two parts concate nated by the parallel operator Both parts are described as separate processes in their own TOOLBUs idef script see Appendices B and C include stubi tb include stub2 tb include user interface idef include editor hive idef tool user environment is process UE is let UE user environment Pidl int Pid2 int in create STUB1 Pid1 create STUB2 Pid2 rec connect UE UI UE 1 Hive UE endlet toolbus UE 39 40 APPENDIX A THE MERGED PROCESS Appendix B The user interface idef
22. class takes care of setting up and handling all communica tion between the Proxy TooLBus and Eclipse All important communication parameters are stored in an object MetastudioConnection When an Eclipse component needs to communicate with the Meta Environment it does this by creating a MetastudioConnection object and retrieving the needed connection parameters from the UserInterface After creating a UserInterface object the PerspectiveFactory takes care of creating the Meta Environment views Views are the graphical user interface components visible to the user e g Resource Navigator and Module Explorer described in later Sections These views are described in the plugin xml file along with its class and unique name This name is used to lookup the class that implements the view and can be used as a future reference i e for other classes that need access to this view Note that allthough text editors are graphical user interface components they are not views To refer to all graphical user interface components including text editors the word part is used in Eclipse jargon The last thing the PerspectiveFactory takes care of is the creation of the Meta Environment toolbar This toolbar consists of a single button Open Module for opening a selected SDF module Because the PerspectiveFactory will be running as long as the perspective is not closed the PerspectiveFactory is the place to implement accessors for builtin user interface elements O
23. diting capabilities as already provided by the JFC Swing Meta Environment Through the Eclipse user interface all generators of the Meta Environment are available We plan to work on extending each system by integrating functionality from the other one On the one hand Eclipse provides functionality for on line help documentation and error reporting All these can be borrowed by the ASF SDF Meta Environment On the other hand we are currently integrating the Meta Environment s graph viewer into Eclipse Other useful functionality is APIGEN 5 which gener ates application program interfaces in C and JAVA from a grammar definition This might make Eclipse further open for non JAVA tools The integration experiment we described in this paper shows that the com bination Eclipse Asr SDF Meta Environment creates a versatile experimenta tion platform for programming language research Chapter 3 ASF SDF Meta Environment The ASF SDF Meta Environment is an interactive development environment for the automatic generation of interactive systems for the construction of lan guage definitions Understanding what this means and what can be done with the ASF SDF Meta Environment is needed to make integration with Eclipse possible 3 1 Introduction The Asr SDF Meta Environment is an interactive development environment for the automatic generation of interactive systems for the construction of lan guage definitions After a language definition ha
24. e snd ack event button parse rec ack event button parse snd msg s event button parse rec msg s event button parse snd do event button parse rec do event button parse snd event button parse rec event button parse snd ack event button parse rec ack event button parse 1 2 3 4 ToolBus Process A TransAdapter M Merged process ToolBus Tool E Eclipse S Stub process TransAdapter M Meta ToolBus process Figure 5 5 Message sequence chart of snd event eval message is handled the same as a snd do When the tool E returns the result it sends a snd value message to M M has to construct a message in such a way that the result value will be sent back to the process that asked for the computation Therefore the received value will be wrapped in a message identifier and a process identifier The message identifier indicates the sort of the message i e an event or a return value The message sort is in this case a returned valued Process P is connected to the TransAdapter A and therefore can only send messages that can be received by a tool The result value will be sent in a snd do message In the last step the TransAdapter will send the received value from P to M in a snd value message 5 5 3 Transformation of rec event While the abovementioned transformations were about sending messages to a tool rec event happens when
25. e tool and does not expect a return value Tools can also initialize communication by using the snd event primitive After receiving an event the process has to acknowledge this by sending a snd ack event message 4 3 TOOLBUS computation tools Tools can be written in any programming language for which a TooLBus adapter exists Connection to the TOOLBUS is provided by a language spe cific adapter In the first stage of establishing a connection between a tool and the TooLBUs the tool receives the signature of the process it is connecting to The signature consists of all messages the tool has to implement in order to function as supposed Depending on rejection or acceptation of the signature the tool will send a message stating it cannot handle the messages provided in the signature or will be functional and do its job 4 4 The TooLBus and Eclipse While investigating how to make a connection between Eclipse and the Meta Environment two possibilities came up First Eclipse could be connected directly 4 4 THE TOOLBUS AND ECLIPSE 19 Parser Generator I O Tool CH Interpreter Meta ToolBus e Term Store Compiler Structure Text Editor User Interface Editor Eclipse Parser Unparser Figure 4 2 Eclipse connected via 2 JavaAdapters to the TOOLBUS using JavaAdapters The second solution connects Eclipse via a proxy to the TooLBus The advantage of this solution is that it provides a generic way of connecting one
26. e via the masquerade side to the original TOOLBus Below follows a description of the protocol used to send messages from the original TOOLBUS to Eclipse via the TransAdapter and Proxy TOOLBUS and events and return values from Eclipse to the original TOOLBUS 5 5 TransAdapter protocol In this section we will describe the protocol used for communication between Eclipse and the Asr SDF Meta Environment via the TransAdapter and the Proxy TOOLBus Each TOOLBUS primitive snd do snd eval and snd event will be described by a simple example 5 5 1 snd do messages Suppose we have a SDF specification with some error After invoking the parser with this specification we will receive an error from the parser and a linenumber where the error has occurred To help the user fix the error we want the cursor to go to that specific line Therefore we have to send a message with the linenumber to Eclipse In Figure 5 2 that message follows the path from the boxed 1 to the boxed 4 Each step will be described using the message sequence chart in 5 5 TRANSADAPTER PROTOCOL 27 M A S M E snd eval T getfocus A rec eval getfocus A snd event getfocus A rec event T getfocus A snd ack event T getfocus A rec ack event getfocus A snd msg getfocus A rec msg getfocus A snd eval E getfocus A rec eval getfocus A snd value focus B rec value focus B snd msg s value focus B rec msg s value focus B
27. ee and graph panels provide the user with a representation of opened and imported modules in a textual and graphical way respectively Status messages and information about selected modules are displayed in dedicated informa tional panels Each of these GUI elements is dumb it is capable of presenting a graphical representation of its data and it communicates events e g a mouse click to the TOOLBUS but it abstracts from the details of these events The 2 4 LESSONS LEARNED 11 actual implementation of an event e g performing a refactoring operation on a selected module is handled elsewhere in the Meta Environment The provided basic framework can be extended dynamically with user inter face elements by means of TOOLBUS messages sent to the user interface These messages contain the type of user interface element to be added e g menu tool bar button the caption to be displayed and the action that has to be performed when selecting this user interface element This setup ensures that the user interface does not know about any functionality implemented in the Meta Environment Text editing functionality is provided by means of external text editors as described before In general the choice of text editor is free as long as it is capable of adding menus and methods for displaying a focus After connection with the TOOLBUS is established it will receive its specific menus menu items and corresponding actions 2 3 2 Eclipse based impl
28. ee bundle gen import org ey if not found e ng public ciel public static String getResourceStrina String key Name gt ClassOrinterfaceType cons Name Identifier gt VariableDeclaratorid cons Identifier1 Fal Usa ResourceBundle bundle NetastudioPlugin getiefaul Se getResourceBundiet pri return bundle getStringckey prj 3 catch MissingResourceException e identifier gt Name cons Identifier p lt Identifier LEX gt gt Identifier Fa retu publ _ 3 LI gt e CH pe TE ai Returns the plugin s resource bundle SA public ResourceBundle getResoureetundl ee E ri return resourceBundle lt identifier LEX gt gt Identifier ad 3 Jwa public static o getImagebescriptor String name info imports fimported by ai String iconPath icons Comment ad ry i Statements 3 bet installURL getdefault0 CECI io Sa MethodDecl URL url new URLCinstalTURL iconPath FieldDec di pril Zeie ImageDescriptor ECO ConstructorDect H 3 catch ee e 3 should not ROSE return Imagedeseriptor getttissingInagedescriptor pull 3 3 la El Focus symbol LocaTVariableneclaration pe Bess RIM V 73 30 Bot 3 private void definePartHandlers l page 1 1 Top Figure 2 1 The Meta Environment GUI 2 2 Architectural considerations The Meta Environment consists of about 20 cooperating components including a parsetable generator a parser and unparser a term store for cachi
29. efinitely added to the generic design of the Meta Environment One example is that the original JFC Swing Meta Environment used evaluation requests to ask for a filename using a file open dialog It might be better to use a snd do snd event pair so the used user interface implementation can use its own method to open files Another big advantage is that all cluttered windows are gone There is one main window where all open modules and graphs recede While the Eclipse Meta plugin does make generic language technology avail able to Eclipse it is just a mimic of the original JFC Swing environment The following sections describe some of the future work that can be done to let the Meta Environment benefit more from the integration with Eclipse 35 36 CHAPTER 7 CONCLUSIONS AND FUTURE WORK 7 2 Syntax Highlighting While the Meta Environment does not provide any form of syntax highlighting at this moment it is possible to extend the Meta Environment in such a way that it provides a basic form of syntax highlighting When a module has been loaded and parsed a table of keywords declared in the SDF specification of that module can be generated By implementing a message in the editor hive that enables an editor to ask for the generated table the syntax highlighting algorithm can be initialized Editors that do not have syntax highlighting possibilities can easily ignore this message Editors that can be programmed to use syntax highlighting such as
30. ementation In order to use Eclipse for the implementation of the Meta Environment GUI and text editor we adapt the Meta Environment architecture as shown in Fig ure 2 3 Ina TOOLBUS setting external tools such as a GUI and text editor are rigorously separated components which never directly communicate with each other but always do so via the TOOLBus In order to connect Eclipse a single operating system level component to the Meta Environment we use a second TooLBus which acts as a proxy between the Meta Environment on one side and the actual implementations of the GUI and text editor in Eclipse on the other This second TOOLBUS together with two instances of a transparent stub one for the GUI and one for the text editor takes care of any de marshalling and forwarding from the Meta Environment to Eclipse and back The Eclipse Meta plugin is implemented as an Eclipse perspective contain ing extensions of an explorer to display the modules several views e g to display status messages and instances of an extension of the built in editor The perspective itself takes care of setting up a connection to the TOOLBUS before instantiating the other Eclipse view parts which receive their operational details from the TOOLBus Figure 2 4 shows the Eclipse user interface of the Meta Environment 2 4 Lessons learned We have identified several opportunities for improvement in both the JFC Swing Meta Environment Section 2 4 1 as well as in
31. ere other processes subsequently ask for the instantiation in the GUI of a File Open dialog to ask the user for the name of the module to be opened Because Eclipse does not have such a dialog we had to implement the opening of modules quite differently The user first selects a file in the module explorer and then hits the open module button This causes the order of user interaction in Eclipse select file hit button to be the opposite of the original order in JFC Swing hit button select file No access to files outside workspace Eclipse only allows access to files residing in the workspace Files outside the workspace first need to be im ported into the workspace before they can be used However when the Meta Environment uses a module it also needs the transitive closure of its imported 2 4 LESSONS LEARNED 13 hd MetaStudio MetastudioPlugin trm Eclipse Platform File Edit Navigate Search Project Actions Move Actions Move Actions Move Run Window Help IS LIGEIA e x P PerspectiveFactory trm MetastudioConnection trm E O Module Explorer Returns the string from the plugin s resource bundle or key if not found A public static String getResourceString String key E ClassDecl B Statements E Expressions ResourceBundle bundle MetastudioPlugin getDefault getResourceBundle E JavaTypes try En return bundle getString key z Ga catch MissingResou
32. et cursor at focus EditorId Focus rec msg editor to front EditorId snd do UE editor to front EditorId rec msg kill editor EditorId snd do UE kill editor EditorId rec event UE contents changed EditorId snd ack event UE contents changed EditorId snd msg hive event contents changed EditorId rec event UE mouse event EditorId MouseEvent snd ack event UE mouse event EditorId MouseEvent snd msg hive event mouse event EditorId MouseEvent rec event UE menu event EditorId MenuEvent snd ack event UE menu event Editorld MenuEvent snd msg hive event menu event EditorId MenuEvent rec event UE contents EditorId FocusText snd ack event UE contents EditorId FocusText snd msg hive event contents EditorId FocusText rec event UE editor disconnected EditorId snd ack event UE editor disconnected Editorld snd msg hive event editor disconnected EditorId delta endlet
33. etween each developed language and the Meta Environment plugin editor has to be inserted in the manifest manually Workbench state management too Eclipse centric Eclipse keeps track of the state of the workbench There is no flexibility when an external tool also needs to maintain a portion of this state This interferes with the way the Meta Environment operates Upon Eclipse startup views from a previous session are still present in the workbench but they do not have the state from the previous session Most notably any connection to the TOOLBUS is lost and in fact the rest of the Meta Environment components may not even have been started yet A Perspective close method not yet available as other plugin writers have noted in the Eclipse newsgroups would already have been useful as it would have allowed us to simply close any view that is managed by the Meta Environment 14CHAPTER 2 A LANGUAGE DEVELOPMENT ENVIRONMENT FOR ECLIPSE 2 5 Conclusions The main contributions of this work are as follows e A proof of concept connection between Eclipse and the Meta Environment this extends Eclipse with language definition tools and extends the Meta Environment with richer user interface functionality e The TooLBus provides a general mechanism for connecting non JAVA tools to Eclipse e We have pinpointed several issues of possible improvement in both sys tems The presented Eclipse Meta Plugin consists of a user interface and text e
34. gain this shows that although Eclipse is advertised as being dynamic it lacks some dynamics in the implementation A click of the second mouse button goes along with displaying a popup menu The click itself cannot be intercepted neither can a popup menu be displayed on command 6 3 3 Graph Views The Meta Environment provides the user with two graph views One of these views shows an import graph consisting of all modules loaded and their relation ships to each other This view has been implemented in Eclipse as the Import Graph View Because the Import Graph View is a visualization of the Module Explorer the same set of commands on modules is available for the user Click ing a module in the graph reveals a popup menu containing the same items as the popup menu showing up when clicking a module in the Module Explorer The other graph the Meta Environment provides is a parsetree of a selection in one of the editors The Parse Tree View in the Eclipse Meta Plugin is the implementation of this Meta Environment element The Parse Tree View can only be shown when a specification has been parsed and some part has been selected The actual implementation of both views depends heavily on the graph datastructure already provided by the Meta Environment The graph datas tructure is given in annotated data type ADT format and serves as input for APIGEN 5 APIGEN generates an API for JAVA based on the given ADT The graph datastructure ADT describes
35. guments delta rec msg display graph GraphId Graph snd do UE display graph GraphId Graph rec msg delete modules Mods snd do UE delete modules Mods rec event UE get module info ModuleName snd ack event UE get module info ModuleName snd msg ui event get module info ModuleName rec msg module info ModuleName Info snd do UE module info ModuleName Info rec event UE clear all snd ack event UE clear all snd msg ui event clear al1 rec event UE debugging On snd ack event UE debugging On snd msg ui event debugging 0n rec msg new graph Pairs snd do UE new graph Pairs rec event UE layout graph GraphId Graph snd ack event UE layout graph GraphId Graph snd msg ui event layout graph GraphId Graph 43 rec msg graph layouted Graphld LayoutedGraph snd do UE graph layouted GraphId LayoutedGraph rec event UE get buttons Type ModuleName snd ack event UE get buttons Type ModuleName snd msg ui event get buttons Type ModuleName rec msg buttons found Type ModuleName ButtonList snd do UE buttons found Type ModuleName ButtonList rec event UE button selected Type ModuleName ActionEvent snd ack event UE button selected Type ModuleName ActionEvent snd msg ui event button selected Type ModuleName ActionEvent rec event UE eclipse open modules ModuleList Type
36. igator 6 3 2 Module Explorer 6 3 3 Graph Views 6 4 Editor 47 hee bb LE a da Conclusions and Future Work CT Conclusions see ici rado ass 7 2 Syntax Highlighting 7 3 Help Facilities A CHE tt ee ME a el Aa A The merged process The user interface idef C The editor hive idef CONTENTS Chapter 1 Introduction 1 1 General The Asr 5SDF Meta Environment is an interactive development environment with an graphical user interface written in JFC Swing A typical session in this environment results in an overwhelming amount of windows presenting the Meta Environment itself next to lots of editors all trying to catch the attention of the user Although the described scene is a little bit exaggerated the several open windows and JFC Swing graphical user interface were the reasons to take a look into Eclipse Eclipse is a framework for creating programming environments wherefore currently versions are available for C C JAVA and Cobol Each version ad dresses a specific programming language with its own set of tools commands and screen layout Because Eclipse is a well developed environment the ASF SDF Meta Environment could benefit from integration with Eclipse Eclipse offers the possibility to make your own perspective which is a screen layout consisting of tree views editors and other kind of views all in one place Eclipse on the other side can benef
37. it from the integration with the Meta Environment because the Meta Environment brings generic language technol ogy to Eclipse Instead of developing a development environment for each pro gramming language one development environment for the Meta Environment is enough to provide tools for every programming language developed in the Meta Environment Chapter 2 covers the results of the integration of the Meta Environment with Eclipse This chapter has been presented at the Eclipse workshop at OOPSLA 2004 and is being published in the ACM Digital Libraryt To be able to un derstand what has to be done to integrate the Meta Environment with Eclipse a brief introduction to both the Meta Environment see Chapter 3 and the underlying TooLBus technology see Chapter 4 will be given The technical details of the Eclipse Meta Plugin will be explained in Chapters 5 and 6 l Available at portal acm org dl cfm 6 CHAPTER 1 INTRODUCTION 1 2 Acknowledgements Writing a thesis is not an everyday task you can do on your own Therefore 1 would like to thank the following people My parents for supporting me during all these years and giving me the chance to study Computer Science Wendy although telling me that I did the job she was the one that made me realize I had to finish it Paul Klint for giving me the possibility to work in a nice research environment with friendly colleagues and for letting me visit the OOPSLA 2003 conference in Los A
38. lipse does not distinguish between these messages and sends them all to the merged process From here on it is known which message belongs to which process and by wrapping it with a ui for user interface or an eh for editor hive string it is directed to the right stub process The stub process will on its turn send the message to the TransAdapter which will deliver it to the Meta Environment process it is connected to The merging of the user interface and editor hive messages was a manual process although it can be done automatically By using ASF SDF it is possible to collect all messages send to and received by a tool For events and evaluation messages it is also needed to search for the return messages acknowledgement of events and return values Hereafter a namespace algorithm has to be used after which the sets are placed in parallel as described before 5 4 TransAdapter To be able to connect two TOOLBUSES a generic TransAdapter has been devel oped The TransAdapter behaves like a tool that connects to two TooLBUSES and therefore consists of a masquerade and a delegate side The masquerade side indicated by a boxed 1 in Figure 5 2 provides a connection with the original TOOLBUS process It therefore simulates the tool this process expects to be connected to The toolname it has to provide to this process is one of the startup parameters of the TransAdapter Because the TransAdapter connects to the TOOLBUS as a tool it receives a sign
39. lity needed by the Meta Environment The support for more than one editor in the JFC Swing Meta Environment is provided by the Editor Hive as described in Section 5 2 2 Eclipse supports multiple editors by default Each editor in Eclipse has its own identifier which is registered by an editor manager The editor manager maps an Eclipse editor identifier to a Meta Environment editor identifier Chapter 7 Conclusions and Future Work The Eclipse Meta plugin sofar mimics the JFC Swing user interface of the orig inal Meta Environment While all basic functionality of the graphical user inter face of the Meta Environment has been implemented in an Eclipse plugin there are possibilities of extending the Eclipse Meta Plugin with technologies provided by Eclipse 7 1 Conclusions Writing a plugin for Eclipse was far from trivial at first sight but after a steep learning curve it has been possible to create a connection between the Meta Environment and Eclipse Both Eclipse and the Meta Environment have had their benefits from inte grating both technologies Eclipse has had the most benefits by making generic language technology available to the platform Whereas other Eclipse plug ins are focussed on one target programming language the Eclipse Meta plugin makes it possible to create and edit language specifications and editing and parsing terms over these specifications in Eclipse Creating a new user interface for the Meta Environment d
40. ne of this builtin user interface elements is the statusbar The statusbar is used in the Meta Environment to display warnings errors and status messages The statusbar is accessed through its manager which can be retrieved from the PerspectiveFactory in the same way as every other user interface component But there is something special with this status bar manager There is a different statusbar for views and for text editors The text editor statusbar overlays the view statusbar and therefore it is important to know which part needs access to the statusbar 6 3 1 Resource Navigator The first view created in the PerspectiveFactory is the Resource Navigator as shown in Figure 6 1 The Resource Navigator is one of the main parts of the Eclipse Platform Each user has a workspace in which all project data e g project metadata files are stored The Resource Navigator represents the workspace in the form of a tree view All projects and their corresponding files are listed in the tree pane of the Resource Navigator To be able to use files in Eclipse these files have to be present in the workspace because that is the only way Eclipse can get access to these files This setup leads to the following problem One of the elements of the ASF SDF Meta Environment is the library Library modules are stored on a path in the installation directory of the Meta Environment To be able to 6 3 META ENVIRONMENT PERSPECTIVE 31 Es Navigator gt fl
41. ne process and the idea of separation of concerns Because Eclipse will now be connected as one tool to one process a middleware alike solution is needed to redirect messages from the two Meta Environment processes editor hive and user interface to the process that connects Eclipse and vice versa This middleware was already present in the form of the TOOL Bus To distinguish between the TOOLBUS used in the Meta Environment and 20 CHAPTER 4 TOOLBUS Parser Generator Parser Unparser IO Tool Interpreter Meta ToolBus O Text Editor Term Store Compiler User Interface Structure Editor Proxy ToolBus Eclipse Figure 4 3 Eclipse architecture with Proxy TOOLBUS this middleware TOOLBUS in the remainder of this thesis the first one is referred to as Meta TooLBus while the second one is referred to as Proxy TOOLBUS see Figure 4 3 Chapter 5 Connecting Eclipse to the Meta Environment Before a connection between the Meta Environment and Eclipse could be made a connection architecture had to be setup Part of this connection architecture is the Editor Hive which is a tool that takes care of spawning communicating and administrating editors Another part of the connection architecture is the Proxy TooLBUS which is the interconnection TOOLBUS that orchestrates com munication between Eclipse and the Meta Environment TOOLBUS and provides a generic way to connect one tool to more
42. ng results and an interpreter and compiler Also a graphical user interface and a number of text editors such as GNU Emacs and Vim as well as a structure editor are connected to the Meta Environment These allow user interaction with the system and in particular allow users to edit syntax equations and terms Figure 2 2 is a simplified view showing these components connected to the TooLBus Current architecture using JFC Swing and external editors Fig ure 2 2 shows the current implementation with separate components for the GUI and the various text editors Currently the GUI is implemented in JFC Swing Each time a text editing session is requested by the user a new instance of one of the supported system editors is executed to take care of the editing session These text editors need only implement a minimal interface to be usable by the Meta Environment Some form of operating system level communication chan nel is needed e g socket pipe The editor then needs to be able to receive and execute commands to add a menu to the menu bar set the cursor at a specific location and highlight or select a region of text 3 Available at www gnu org software emacs 4 Available at www vim org 10CHAPTER 2 A LANGUAGE DEVELOPMENT ENVIRONMENT FOR ECLIPSE Parser Generator Meta ToolBus e Parser Unparser I O Tool Interpreter Term Store Compiler User Interface Structure Editor Text Editor Eclipse
43. ngeles It was a great experience Hayco for sharing lots of fun next to some serious pair programming and supporting me in The States which was needed especially after someone said the nice 25 person room changed that morning to a room for 80 people Furthermore thanks to Mark van den Brand and Jurgen Vinju for answering all questions I had One fool can ask more than Mark and Jurgen can answer Chapter 2 A Language Development Environment for Eclipse The ASF SDF Meta Environment provides a collection of tools for the gen eration of programming environments We show how Eclipse can be extended with these generic language tools By integrating the GUI and text editor of the Meta Environment with Eclipse using TOOLBUS technology we demonstrate the integration of third party non JAVA software in Eclipse By doing so we create an experimentation framework for further programming language research We describe our experiences and sketch future work 2 1 Introduction Eclipse 7 is an open source framework for creating programming environments Currently versions exist for C C JAVA and Cobol New tools and lan guages can be added by writing JAVA applications that perform parsing type checking and the like for a new language Eclipse provides a rich set of tools oriented toward user interface construction and JAVA compilation The level of automation for building environments for new languages is however low The AsF SDF Meta
44. nt see Section 3 2 3 2 Graphical User Interface and Editors Part of integrating the Meta Environment with Eclipse is creating a graphical user interface in Eclipse that matches the user interface of the original Meta Environment In this section a description of the several parts of the Meta Environment user interface will be given The main window of the Meta Environment consists of the following parts e A menubar containing menus to import and edit modules e A toolbar showing the most common functions e g New Module Open Module e An import pane showing all opened modules as an import tree e An graph pane showing a graphical representation of the import tree men tioned above e An information pane showing parents and children of the selected module and its location e A message pane showing the message errors and warnings history e A status bar that shows the current activity of the Meta Environment e g idle parsing focus symbol Because the Meta Environment does not provide any editing functionality editing modules is done using separate editors e g gvim or GNU Emacs Any editor can be used as long as the editor of choice can be externally operated to offer menus and functionality related to the module being edited Chapter 4 TOOLBUS The TOOLBUS coordination architecture plays an important role in the connec tion between Eclipse and the ASF SDF Meta Environment We first give a brief introduction
45. o coordination not computation Besides this ethical problem it also meant that Eclipse had to connect to an undefined number of processes For each editing session a TransAdapter would be needed but also a stub process adjusted to receive messages for that specific editing session from the merged process The main problem arises in this merged process For each editing session this process has to be extended with an extra set of messages for that editing session Suppose the merged process already consists of 1 S2 When the user requests a new editing session a new editor process would be invoked The only way the merged process can address this editor process is by introducing a new set of messages 3 in parallel with S1 52 resulting in S1 S 2 53 A TooLBus process can never be extended dynamically so the aforementioned method can not be used To ban all computation from the TOOLBUS the editor hive was introduced The editor hive tool takes care of invoking and administrating editors Now only one process handling editing sessions is needed Figure 5 1 shows the editor hive tool and its according TOOLBUS process As can be seen a whole range of editors can be used as long as these editors comply with the given framework This framework consists of the set of messages an editor has to implement and an adapter to connect the editor to the editor hive Herefore the editor has to be externally managable 5 3 PROXY TOOLBUS 23 ToolBus Edit
46. onsist of a manifest file and JAVA classes in a JAR archive The manifest file declares the extension points of the plugin and which other plugins it extends On start up the Eclipse Platform discovers which plugins are available and it generates a plugin registry The plugin itself is loaded when it actually needs to be run 2 1 2 Meta Environment Technology The ASF SDF formalism 1 4 is used for the definition of syntactic as well as semantic aspects of a language It can be used for the definition of a range of languages for programming writing specifications querying databases text processing or other applications In addition it can be used for the formal specification of a wide variety of problems ASF SDF can be characterized as a modular rewriting based specification formalism in which syntax and semantics are completely integrated The AsF SDF Meta Environment is both a programming environment for ASF SDF specifications and a programming environment generator which uses an ASF SDF specification for some programming language L to generate a stand alone environment for L The design of the Meta Environment is based on openness reuse and extensibility The Meta Environment offers syntax directed editing of ASF SDF specifications as well as compilation of ASF SDF specifications into dedicated interactive stand alone environments containing various tools such as a parser unparser syntax directed editor debugger and interpreter
47. or Hive gvim GNU Emacs Figure 5 1 Schematic view of the editor hive 5 3 Proxy TOOLBUS The Proxy TOOLBUS provides a connection to the Meta Environment on the one side and an connection to Eclipse on the other side Every process in the Meta Environment that has to be connected to Eclipse has a stub process in the Proxy TooLBus For the connection with Eclipse there is one process that consists of all messages Eclipse has to implement The set of messages Eclipse has to implement is a merge of the sets of messages of the several processes Eclipse has to connect to in this case the set of messages of the user interface and editor hive processes Finally the connection between the Meta TOOLBUS and the Proxy TOOLBUS is established by using a TransAdapter indicated by the letter A in Figure 5 2 This tool connects to both TOOLBUSES and forwards any message from one TOOLBUs to the other The working of this tool will be discussed in Section 5 4 5 3 1 Stub process The stub process P see Figure 5 2 running in the Proxy TOOLBUS forwards all incoming messages from the TransAdapter to the merged process and the other way around An example stub process for the user interface process is shown below tool stub is process STUB is let S stubl Event term Message term in rec connect S rec event S Event 24CHAPTER 5 CONNECTING ECLIPSE TO THE META ENVIRONMENT Parser Generator Parser Unparser IO Tool In
48. or compiler Figure 2 1 shows the user interface developed using JFC Swing This figure shows the modular structure of the specification Each node in the graph can be clicked and allows the invocation of a syntax equation or term editor The various types of editors are decorated with different pull down menus All editors have functionality to invoke the parser view the parse tree of the focus as graph and to move the focus Term editors may have language specific pull down menus In order to achieve a strict separation between coordination and computation we use the TOOLBUS coordination architecture 2 a programmable software bus based on process algebra Coordination is expressed by a formal description of the cooperation protocol between components while computation is expressed in components that may be written in any language We thus obtain interop erability of heterogeneous components in a possibly distributed system The components are not allowed to communicate directly with each other but only via the TooLBus This leads to a rigorous separation of concerns 2 2 ARCHITECTURAL CONSIDERATIONS 9 e Metastudio Connection java wo n metastudio META KOOIKER 19442 0x File Edit Tools Syntax Buffers Window Actions Move Help auna 99 Xi HH RAAB SSA TODA x Meustudiopluginjava METSKOOKER 1923 BE Blackage nl cwi sen metastudio File Edit Tools Syntax Buffers Window Actions Move Help import _metas
49. rceException e RE return key EE FieldDecl E Modifiers E MethodDecl po B Interfaces Returns the plugin s resource bundle E ConstructorDecl E Comment public ResourceBundle getResourceBundle return resourceBundle public static ImageDescriptor getimageDescriptor String name String iconPath icons try URL installURL getDefault getDescriptor getinstallURL URL url new URL installURL iconPath name return ImageDescriptor createFromURL url catch MalformedURLException e A should not happen return ImageDescriptor getMissinglmageDescriptor Module Info x Property value path Jufs kooikerfruntime workspace Java E si Status Module Info Module Imports Module Parents J Figure 2 4 The Meta Environment in Eclipse modules which are not necessarily located in the workspace they could be any where on the file system As a consequence a user cannot edit any module that is not part of the workspace Plugin configurability too rigid The plugin manifest file is not usually edited by plugin users One of the things that is hard coded in this mani fest is the link between file extension and corresponding editor to be used in Eclipse when such a file needs to be edited Because the Meta Environment has no fixed language and file extensions are often associated with a particu lar new language an explicit link b
50. s been constructed tools for this language can be generated e g parser type checker and compiler A language definition typically consists of a syntax SDF and a semantics ASF definition The AsF SDF Meta Environment can help in e Writing a formal specification for some problem where interactive support is needed e Developing programming languages and creating an interactive environ ment for it e Analyzing or transforming programs in some existing programming lan guage Using the Meta Environment new specifications can be made specifications can be modified and using terms existing specifications can be tested A language specification consists of modules which can be edited by invoking an external editor These modules consist on their turn of the aforementioned syntax and semantics equations part The ASF SDF Meta Environment consists of about 25 components that are connected via the TOOLBUS which will be discussed in Chapter 4 Figure 3 1 shows the basic architecture with some of the most important components 15 16 CHAPTER 3 ASF SDF META ENVIRONMENT Parser CES Generator I O Tool Interpreter ToolBus Term Store Compiler Structure En Figure 3 1 Basic architecture of the ASF SpF Meta Environment Because this thesis is about integrating the Meta Environment with Eclipse we will not further discuss the technology used in the Meta Environment but focus on the user interface of the Meta Environme
51. t of S2 5 4 TRANSADAPTER 25 of messages from the editor hive the merged process becomes S1 52 see also Appendix A Sending a message to Eclipse has no effects on the implementation of the message in the merged process as long as every message from the originating processes is unique If the user interface and editor hive processes implemented the same messages a namespace should be introduced To be able to send a message from Eclipse to the Meta Environment some changes had to be made to the original messages The fact that Eclipse com municates with one process the merged process M in Figure 5 2 means that these messages are not directed to the user interface or editor hive process Be cause all messages are unique we can distinguish the messages that have to be send to the user interface process from the messages that have to be send to the editor hive process After receiving a message from Eclipse it is wrapped with a message identifier and a process identifier The message identifier is used to distinguish return values from events When a computation has been done a return value is sent back By wrapping the message with a value string the TransAdapter knows it has to return a value to the Meta Environment Otherwise the message will be wrapped with an event string and the TransA dapter will send an event to the Meta Environment The process identifier is used to distinguish between user interface and editor hive messages Ec
52. terpreter Meta ToolBus O Term Store Compiler User Interface Structure Editor Eclipse E Figure 5 2 Eclipse architecture with Proxy TOOLBUS snd ack event S Event snd msg Event rec msg ui Message snd do S fun Message delta endlet After a connection with the TransAdapter has been established two things can happen The TransAdapter can forward a message from the Meta TooLBus which will be received as an event by the stub process This event is then forwarded to the merged process The second part handles incoming messages addressed to the userinferface process in the Meta TOOLBUS and forwards these to the TransAdapter connected to the user interface process The stub process has been designed as generic as possible The only ex ception is that it has to provide a method to be able to address the right stub process for a message sent from the merged process Therefore received mes sages has to be wrapped with an identifier in this case ui for the user interface process 5 3 2 Merging processes Merging the user interface and editor hive processes means taking out all mes sages sent to or received from the user interface and editor hive tools and copying these in a new TOOLBUS script Because the user interface and editors can be used in parallel the two sets of messages have to be implemented in parallel too If you have a set S1 of messages from the user interface and a se
53. to the working of the TooLBUs Thereafter we show the possibili ties to connect Eclipse to the Meta Environment whereafter the final solution using a second TOOLBUS will be described in detail 4 1 Introduction The TOOLBUS coordination architecture is the interconnection architecture used in the Meta Environment The TOOLBUS can be compared with a hardware communication bus except it is entirely software based Processes described by process algebra scripts provide the coordination between the various com ponents These components or tools can be written in any language The fact that these tools are not allowed to communicate directly with each other leads to a rigorous separation of coordination and computation The TooLBus architecture will be briefly described in Section 4 2 and Section 4 3 The two major processes with respect to Eclipse are the user interface and editor hive processes These processes form the core of the graphical user in terface of the Meta Environment The goal is to connect Eclipse to these two processes which is slightly different than connecting other tools to the Meta Environment Under normal circumstances tools are never connected to more than one process without violating the idea of separation of concerns In this chapter we will describe the architecture used to connect Eclipse to the Meta Environment in such a way that it does not affect the functionality of the original JFC Swing environment 4 2 TOO
54. tudio graph MetaGraphFactory au BE GC HH RARE SSR renz AASF SDF Meta Environment Sixlitornataracton 3 x pe EE puplic void shutdomO n z File Edit Tod MetastudioConnection connection UserInterface getconnection B A 100 vj SM Smection getsridge send vent connection getPureFactory parsec quit 3 3 Backage m Gimport parsetree Ep e Le META icons LotalVariableDect ration gt STARTS CH import Jav is Returns the shared instance D expressions import nl d palle sigle fee ali dig getDefaultC E D FisidOeci n la H Ly intertaces Type VariableDeclarator gt LocalVariableDeclaration cons comma Mess SCH e import oral Sd import org Returns the workspace instance JavaTypes import org ef Di texica ReferenceType gt Type cons ReferenceType VariableDeclarator import org public static IWorkspace getWorkspace D MethodDeci d import oral _ return ResourcesPlugin getWorkspace 3 D modifiers D Naes 7 r loo Daemon ClassOrinterfaceT ype gt ReferenceType cons ClassOrinterfaceType VariableDeclaratorid Variablelnitializer gt Pork ora ns the string fron the plugin s r
55. uired modules are loaded 6 3 2 Module Explorer The Module Explorer Figure 6 2 provides a tree view on modules loaded in the Meta Environment It looks like the Resource Navigator but it does not show files but in stead shows the modules loaded by the Meta Environment The Module Explorer consists mainly of two parts The visual part is the treeview the user sees when using the Eclipse Meta Plugin Data displayed in the visual part is stored in a tree datastructure Changes to this structure are noticed by the visual part of the Module Explorer by using listeners The visual part of the Module Explorer is never changed directly by others but only by changing the datastructure The Module Explorer view is implemented in the ModuleExplorerPart class This class is also responsible for creating the tree datastructure By instantiating an object of the ModuleExplorerContentProvider a listener is created that notifies the ModuleExplorerPart when the tree datastructure changes The ModuleExplorerPart invokes the ModuleExplorerLabelProvider to retrieve the names to be shown in the treeview from the tree datastructure and eventually adds icons to the different kinds of nodes of the tree i e file icons or folder icons to distinguish between modules and directories Finally there is a mouse listener ModuleExplorerMouseListener which takes care of retrieving module information or showing a popup menu depending on the mouse button clicked The retrie
56. ved module information will be displayed in the Module Info view The popup menu is context sensitive and shows the options that can be used with the selected file To make the popup menu show the items corresponding to the file selected Eclipse supports last minute changes to the items of the 6 3 META ENVIRONMENT PERSPECTIVE 33 Graph Tree ij E LocalVariableDeclaration gt lt START gt type VariableDeclarator gt LocalVariableDeclaration cons comma ReferenceType gt Type cons ReferenceType VariableDeclarator A ClassOrinterfaceType gt ReferenceType cons ClassOrinterfaceType VariableDeclaratorld Variablelnitializer Name gt ClassOrinterfaceType cons Name Identifier gt VariableDeclaratorld cons Identifier1 Identifier gt Name cons Identifier p lt Identifier LEX gt gt Identifier lt Identifier LEX gt gt Identifier al Hal Graph Import Graph Tree Figure 6 3 Graph View of import tree popup menu before showing it by the menuAboutToShow method Problem is that menu items have to be known at the time the menuAboutToShow is called but Eclipse has to ask the Meta Environment for the right items Therefore we stay in a loop as long as we have not received these items and set a boolean as we have received them Unfortunately a
57. y wf x Y 1 Java project ClassDecl sdf Comment sdf ConstructorDecl sdf D 3 mm vele re rm Expressions sdf FieldDecl sdf Interfaces sdf Java sdf JavaTypes sdf Layout sdf Lexical sdf Main sdf MetastudioConnection trm MetastudioPlugin trm MethodDecl sdf Modifiers sdf Names sdf E PerspectiveFactory trm E Statements sdf E Syntax sdf b t Pico gt gt TomTest Navigator Outline Figure 6 1 Resource Navigator edit library modules these modules should be imported in a separate project in the Eclipse workspace After editing a module it has to be put back to its original location in the library Another solution could be to redirect the loca tion of the library in the Meta Environment to the path of the workspace of the Eclipse installation When a user opens a SDF module in the JFC Swing Meta Environment a file open dialog will be shown The module selected by the user will be loaded along with the transitive closure of its imports All opened modules and libraries will be shown in a tree view Clicking on a module results in a menu popping up whereafter the user can choose to edit the syntax or equations of the module or opening a term over that module In Eclipse opening a SDF module is a little bit different When the user opens a file in the Resource Navigator Eclipse will open this file in the text editor registered with the file s extension
Download Pdf Manuals
Related Search
Related Contents
Compuertas cortafuego Serie FKR-EU FKR-EU/DE/ES/es 5,1 Yamaha Electronic Keyboard deyboard stand User's Manual TI5400A 400Hz Manual - Tesla™ Industries Inc KIPOR POWER PRODUCTS CO., LTD. IG2000/IG2000P/IG2000S sony chassis FE-1-32015-05-09 01:345.7 MB - Wiki Karat CompactRIO cRIO-9002/9004 Operating Instructions LED LENSER®* Furuno FR-8251 Marine RADAR User Manual N DigitalTalk MAX™ 2100 Manual del usuario Lenovo ThinkCentre E73 Copyright © All rights reserved.
Failed to retrieve file