Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Writing an editor
Writing an editor [message #196819] Wed, 28 February 2007 04:43 Go to next message
Carl Manaster is currently offline Carl ManasterFriend
Messages: 23
Registered: July 2009
Junior Member
Hi,

I'm trying to write an editor plugin for Eclipse, for my own tiny toy
language, to get to know the plugin architecture and to explore some ideas
on TDD. For a look at the
language:<http://www.flickr.com/photos/carlmanaster/9322576/>. I've got
several questions; I hope someone here can help me get up to speed more
quickly than I've managed thus far on my own, with Gamma & Beck's book and
a lot of online reading.

I want to write this as test-first as possible, and I want it to fit
nicely into Eclipse's architecture, and I'm running into some trouble
figuring out how to write the tests. For example, I want to divide the
subject code up into partitions for faster and more scalable processing -
also because it just seems to make sense; when one function is edited,
that's the only one that will need reformatting and re-parsing (with a
couple of caveats - since one of the things I want to do is correctness
coloring, if editing f1 causes f2 to start or stop passing its tests, then
f2 needs reformatting, and if I ever do multiline comments, then
introducing a comment start can affect downstream functions). But I
digress.

Here's a tiny example of code:

1 one:
2 expect returns 1
3 return 1
4 two:
5 expect returns 2
6 return 2

(the line numbers and initial space are just for reference and easier
reading). There are, here, two functions, one() which extends from lines
1 through 3 and two() which extends from lines 4 through line 6. So I
want to tell Eclipse that those are my partitions, so I want my
PartitionScanner to make that designation.

Now, it's no problem to find the boundaries of the functions. Expressed
in harder-to-read format, here's where the partition breaks are:

{START}one:\n\texpect returns 1\n\treturn 1\n{BREAK}one:\n\texpect returns
1\n\treturn 1\n{BREAK}

(or put the breaks before the newlines; whichever). So here's question 1:
what would be a good first test for such a PartitionScanner? I don't have
a good sense of what the caller of my PartitionScanner is expecting.

----

Just as with the partition scanner, I want to know how to write a good
test for a function scanner. I wrote a little extension of
RuleBasedScanner with a simple WordRule and my three keywords, returning a
color token (based on the XMLScanner), and when I plug it into the
configuration I get color keywords. Cool. But there's a lot I don't
understand here - like, for one, how to write a test for this; and for
two, why I'm injecting color tokens into the stream. I mean, I think the
function scanner should be classifying tokens as, for example, keywords,
instead of classifying them as blue. OAOO tells me I shouldn't be
identifying keywords in two places, and I'm going to want to identify the
keywords wherever it is I wind up building my AST.

----

Which brings me to my next question: what's the point (extension point?)
at which I should hook in the code that builds my AST? I want this to
happen essentially whenever the code changes, but all of this partition
and function scanning from the XML example seems to be purely about
presentation. Is there some other hook for parsing the semantics?

----

Thanks for any help on this; I'm sorry the questions are kind of
ill-focussed, but I just don't have enough understanding of the system yet
to know what questions to ask. I'm sure I may be making some fundamental
misunderstandings here (like, maybe it's wrong to partition by function;
maybe scanners aren't the right approach; etc.) and please don't hesitate
to point that out.

Peace,
--Carl
Re: Writing an editor [message #196889 is a reply to message #196819] Wed, 28 February 2007 08:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nugaee.SPAMtlen.pl

Carl Manaster wrote:
> Hi,
>
> I'm trying to write an editor plugin for Eclipse, for my own tiny toy
> language, to get to know the plugin architecture and to explore some
> ideas on TDD.

i've never explore this problem deeply, but once I've found
The Eightbol Tutorial : http://www.eightbol.org/index.html


you can also try to search for your answers in Eclipse FAQ:
http://wiki.eclipse.org/index.php/The_Official_Eclipse_FAQs# Implementing_Support_for_Your_Own_Language
http://wiki.eclipse.org/index.php/FAQ_How_do_I_write_an_edit or_for_my_own_language%3F

hope this helps
bartek michalik
Re: Writing an editor [message #196972 is a reply to message #196819] Wed, 28 February 2007 11:59 Go to previous message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Carl Manaster wrote:

> Hi,
>
> I'm trying to write an editor plugin for Eclipse, for my own tiny toy
> language, to get to know the plugin architecture and to explore some
> ideas on TDD. For a look at the
> language:<http://www.flickr.com/photos/carlmanaster/9322576/>. I've
> got several questions; I hope someone here can help me get up to speed
> more quickly than I've managed thus far on my own, with Gamma & Beck's
> book and a lot of online reading.
>
> I want to write this as test-first as possible, and I want it to fit
> nicely into Eclipse's architecture, and I'm running into some trouble
> figuring out how to write the tests. For example, I want to divide
> the subject code up into partitions for faster and more scalable
> processing - also because it just seems to make sense; when one
> function is edited, that's the only one that will need reformatting
> and re-parsing (with a couple of caveats - since one of the things I
> want to do is correctness coloring, if editing f1 causes f2 to start
> or stop passing its tests, then f2 needs reformatting, and if I ever
> do multiline comments, then introducing a comment start can affect
> downstream functions). But I digress.
>
> Here's a tiny example of code:
>
> 1 one:
> 2 expect returns 1
> 3 return 1
> 4 two:
> 5 expect returns 2
> 6 return 2
>
> (the line numbers and initial space are just for reference and easier
> reading). There are, here, two functions, one() which extends from
> lines 1 through 3 and two() which extends from lines 4 through line
> 6. So I want to tell Eclipse that those are my partitions, so I want
> my PartitionScanner to make that designation.

Partitions are intended to be different (content) types in the document,
e.g. Javadoc, code, single line comment. The idea is that you can then
contribute features per such document content typem e.g. content assist
for the code partition. the partition scanner is used to create the
partitions. You can also contribute different presentation reconcilers
per document content type.

>
> Now, it's no problem to find the boundaries of the functions.
> Expressed in harder-to-read format, here's where the partition breaks
> are:
>
> {START}one:\n\texpect returns 1\n\treturn 1\n{BREAK}one:\n\texpect
> returns 1\n\treturn 1\n{BREAK}
>
> (or put the breaks before the newlines; whichever). So here's
> question 1: what would be a good first test for such a
> PartitionScanner? I don't have a good sense of what the caller of my
> PartitionScanner is expecting.
>
> ----
>
> Just as with the partition scanner, I want to know how to write a good
> test for a function scanner. I wrote a little extension of
> RuleBasedScanner with a simple WordRule and my three keywords,
> returning a color token (based on the XMLScanner), and when I plug it
> into the configuration I get color keywords. Cool. But there's a lot
> I don't understand here - like, for one, how to write a test for this;
> and for two, why I'm injecting color tokens into the stream. I mean,
> I think the function scanner should be classifying tokens as, for
> example, keywords, instead of classifying them as blue. OAOO tells me
> I shouldn't be identifying keywords in two places, and I'm going to
> want to identify the keywords wherever it is I wind up building my AST.
>
> ----
>
> Which brings me to my next question: what's the point (extension
> point?) at which I should hook in the code that builds my AST? I want
> this to happen essentially whenever the code changes, but all of this
> partition and function scanning from the XML example seems to be
> purely about presentation. Is there some other hook for parsing the
> semantics?

Take a look at the normal reconciler (see
SourceViewerConfiguration.getReconciler(...)).

Dani

>
> ----
>
> Thanks for any help on this; I'm sorry the questions are kind of
> ill-focussed, but I just don't have enough understanding of the system
> yet to know what questions to ask. I'm sure I may be making some
> fundamental misunderstandings here (like, maybe it's wrong to
> partition by function; maybe scanners aren't the right approach; etc.)
> and please don't hesitate to point that out.
>
> Peace,
> --Carl
>
Previous Topic:writing a Unicode View
Next Topic:Compiler warnings in eclipse
Goto Forum:
  


Current Time: Sat Apr 20 04:07:24 GMT 2024

Powered by FUDForum. Page generated in 0.10620 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top