www.rjsoftware.se Forum Index www.rjsoftware.se
Discuss software found at the RJ Software site.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

JScript syntax file: common class member lists

 
Post new topic   Reply to topic   TextEd Homesite »  www.rjsoftware.se Forum Index -> Syntax files
View previous topic :: View next topic  
Author Message
Marcus



Joined: 23 Jan 2010
Posts: 23

PostPosted: Sun Feb 21, 2010 1:10 pm    Post subject: JScript syntax file: common class member lists Reply with quote

Hi everyone,

First of all, I wish make my personal congratualtions to Rickard for the x[index].member implementation: with this feature, writing JScritp code, with a well defined JScript syntax file, has become very very easy and funny!

Yesterday, I started to add a lot of class and class member to the JScript syntax file. During this activity I see that more member lists are common to many class. For example: the
Code:
HTMLElement
members (properties, methods, events and arrays) are applyed to
Code:
anchors
,
Code:
forms
ecc.
So, for the
Code:
document.anchors[].
array I have to define the specific members for the anchor class and then add the members of the
Code:
HTMLElement
class (beacuse anchor is actually an object of
Code:
HTMLElement
class). In the same mode, I have define the specific members for the
Code:
form
class (of the array
Code:
document.forms[].
) and then add all the members for
Code:
HTMLElement
to the form class.

I think that is possible to reduce a lot of work if we can define "virtual" class and use that as item in the class member list. A "virtual" class in not a part of class list (allow autocompletion to distinguish real class from virtual class), but is a specific list. Then, when we build the class members list, we can add specific class items and add all the members of a "virtual" class, simply specifing the name of the virtual class.
For example, in the
Code:
document.anchors[].
class I add
Code:
href
as proper member and, adding
Code:
HTMLElement
as "virual" class, I can automatically add all the member of that "virtual" class to the
Code:
document.anchors[].
!

Do you think that is a reasonable/praticable solutions?

Thankyou in advance for your comments
_________________
Marcus
Back to top
View user's profile Send private message
Rickard Johansson
Site Admin


Joined: 19 Jul 2006
Posts: 1950

PostPosted: Sun Feb 21, 2010 1:30 pm    Post subject: Reply with quote

Maybe something like this?

Code:

[AutoComplete]
@BaseClass=members common in most classes
FooClass=@BaseClass|other members not in the BaseClass list


I guess we could add @Class lists in its own section e.g.

[BaseClassLists]
@BaseClass=...
Back to top
View user's profile Send private message Send e-mail
Marcus



Joined: 23 Jan 2010
Posts: 23

PostPosted: Mon Feb 22, 2010 8:22 pm    Post subject: Reply with quote

Oh Yes Rickard, it will works fine.
I think that is better to leave the [AutoComplete] section as it is and add a new [BaseClassList] section.
Please, take a look to the following real case

Code:
[AutoComplete]
document.archors[].=href|href+p##@HTMLElement##

[BaseClassList]
HTMLElement=name|name+p##@attributes[].|attributes[]+n##@childNodes[].|childNodes[]+n##setAttribute()|setAttribute+m##getAttribute()|getAttribute()+m##...
attributes[].=name|name+p##value|value+p##nodeValue|nodeValue+p
childNodes[].=@HTMLElement


-- 1st case --
we write the following code

Code:
document.anchors[x].


we looking for document.anchors[]. in the [AutoComplete] section, finding realted match.
The list in the autocomplete pop-up window will show href and the "expansion" of @HTMLElement, that

href
name
attributes[]
childNodes[]
setAttribute()
getAttribute()
...

-- 2 case --
we write the code

Code:
document.anchors[x].attributes[y].


We looking for document.archors[].attributes[]. in the [AutoComplete] section, finding no match.
We can stripping-out the last part of the class chain (attributes[].) obtaining document.anchors[]. that exists in the [AutoComplete] section.
Expangin @HTMLElement, and selecting only the members starting with the '@' character, we obtain attributes[]. and childNodes[].; we can combine these two with the starting code, obtaining

document.anchors[].attributes[].
document.anchors[].childNodes[].

Does any of these match the starting code? Yes: we have document.archors[].attributes[]. !!
So we can list the member of attributes[]. in the [BaseClassList] section, obtain the following items to show in the autocomplete pop-up window.

name
value
nodeValue

-- 3rd case --
we write the code

Code:
document.anchors[x].childNodes[y].


So, we looking for document.anchors[].childNodes[]. in the [AutoComplete] section, finding no match.
Again, we can stripping-out the last part of the code and looking for document.anchors[]. in the [AutoComplete] section.
Expanding the @HTMLElement, only for the members that start with the '@' character, we have attributes[]. and childNodes[].; combine these members with the starting code, we can have

document.anchors[].attributes[].
document.anchors[].childNodes[].

The second item, match the code of the 3rd case, so we can search the childNodes[]. in the [BaseClassList] section and expand the @HTMLElement, obtaining the follogin items to show in the autocomplete pop-up window

name
attributes[]
childNodes[]
getAttribute()
setAttribute()
...

What do you think about?
_________________
Marcus
Back to top
View user's profile Send private message
Rickard Johansson
Site Admin


Joined: 19 Jul 2006
Posts: 1950

PostPosted: Tue Feb 23, 2010 11:08 am    Post subject: Reply with quote

It's a bit to complicated. I want it to be rather simple and the [BaseClassList] , or whatever I decide to call it, should just be a list of variables with a member list.

Code:

[BaseClassList]
@HTMLElement=name|name+p##attributes[]|attributes[]+n##childNodes[]|childNodes[]+n##setAttribute()|setAttribute+m##getAttribute()|getAttribute()+m##...

[AutoComplete]
document.archors[].=href|href+p##@HTMLElement##
document.archors[].attributes[].=name|name+p##value|value+p##nodeValue|nodeValue+p
document.archors[].childNodes[].=@HTMLElement
Back to top
View user's profile Send private message Send e-mail
Marcus



Joined: 23 Jan 2010
Posts: 23

PostPosted: Tue Feb 23, 2010 1:00 pm    Post subject: Reply with quote

Yes Rickard, simplify is always right!

Please note that attributes[]. and childNodes[]. (like other base class) could be base-class themself, because could be use in other class (some class could use only attributes[]., some other class could use only childNodes).
But this is only an example!

Thank-you very much for your support.
_________________
Marcus
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    www.rjsoftware.se Forum Index -> Syntax files All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group