GentleMen,
above Topic is a place holder for similar questions
and here is the question.
use Namespace.Namespace
1)
what class would catch above statement i assumed it would be UsingStmt class
but is it?? when i move mouse over something it is telling what it is. i have captured
all members,statements and exprs classes through visitation moving over above statement
is not producing anything. something wrong with my code or it is another class
2)what would catch @args in the code file and similar @compiler instructions within the file.
Thanking_you
RIGHT_THEN
Forums
Code File Visitation What Class Catches What
13 posts
• Page 1 of 2 • 1, 2
Re: Code File Visitation What Class Catches What
1)
It's UseDirective found in CobraWorkspace/Source/NameSpace.cobra.
The UsingStmt is for the "using" statement found in code blocks:
2)
These are handled by "def compilerDirective" in CobraWorkspace/Source/CobraParser.cobra. You'll note that none of the handling for @foo creates a node. Instead the parser handles each directive with whatever specific actions the directive requires, right away.
It's UseDirective found in CobraWorkspace/Source/NameSpace.cobra.
The UsingStmt is for the "using" statement found in code blocks:
class A
def foo
using tw = File.createText('foo.txt')
tw.writeLine('Hello')
2)
These are handled by "def compilerDirective" in CobraWorkspace/Source/CobraParser.cobra. You'll note that none of the handling for @foo creates a node. Instead the parser handles each directive with whatever specific actions the directive requires, right away.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: Code File Visitation What Class Catches What
Thanks for the info charles
but what would cause Usedirective to be caught
declsinorder of namespace,box,class,cobramodule nothing seems to catch it
SyntaxNode never seems to be called , NamedNode does get called thou.
namespace has addusedirective() but none specific to retrieve it.
2) AsExpr the object that follows it what would catch it i mean directly
like in dotexpr left and right seem to work i mean there is nothing explicit about
AsExpr then!! one would have to calculate what is being As(ed) to what is it??
Thanking_You
RIGHT_THEN
but what would cause Usedirective to be caught
declsinorder of namespace,box,class,cobramodule nothing seems to catch it
SyntaxNode never seems to be called , NamedNode does get called thou.
namespace has addusedirective() but none specific to retrieve it.
2) AsExpr the object that follows it what would catch it i mean directly
like in dotexpr left and right seem to work i mean there is nothing explicit about
AsExpr then!! one would have to calculate what is being As(ed) to what is it??
Thanking_You
RIGHT_THEN
- RIGHT_THEN
- Posts: 99
Re: Code File Visitation What Class Catches What
The following code would create two UseDirectives:
I'm not sure if I understand your question about AsExpr. This code would create one AsExpr:
Note that AsExpr inherits NameExpr (as does IdentifierExpr) which provides a name and a definition. A doc string there about the definition says that the definiton may include:
* Class, Struct, Interface
* NameSpace, EnumDecl
* ClassVar, LocalVar, Param
In the case above, the definition would be a LocalVar.
HTH. Ask again if you need more information.
use System.Reflection
use System.Threading
I'm not sure if I understand your question about AsExpr. This code would create one AsExpr:
class A
def main
s as String = 'foo'
trace s
Note that AsExpr inherits NameExpr (as does IdentifierExpr) which provides a name and a definition. A doc string there about the definition says that the definiton may include:
* Class, Struct, Interface
* NameSpace, EnumDecl
* ClassVar, LocalVar, Param
In the case above, the definition would be a LocalVar.
HTH. Ask again if you need more information.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: Code File Visitation What Class Catches What
Charles
yes that is how i create use directive in code my Question is can it be caught while visitation
is it there is the nodes somewhere.so that i can record it like
all of the above can be recorded while visitation when i loop the CobraModule
through various Visit Functions.
it is how i thought i would catch it and store it. it is never being called.if usedirective belongs to the namespace then this method should be called while visiting Namspace elements.
like "def classone" belongs to "class One" while visiting class members "def classone" would pop up i am catching it in Visit Methods() i think. how to get hold of usedirective or is it like
compiler directives stored somewhere but not in the node.
althou i see that it does not implement INamespacemember
so either i make
or write a method/prop in Namespace class that gets _useDirectives;
Thanking_You
RIGHT_THEN
use System.Reflection
use System.Threading
yes that is how i create use directive in code my Question is can it be caught while visitation
is it there is the nodes somewhere.so that i can record it like
class One
def classFunc
Console.writeline("In Func")
all of the above can be recorded while visitation when i loop the CobraModule
through various Visit Functions.
public virtual void Visit([CobraLangInternal.NotNull] UseDirective item)
{
System.Diagnostics.StackFrame gh = new System.Diagnostics.StackFrame();
/*writeToFile(gh.GetMethod().GetParameters()[0].ParameterType.Name);*/
if (item.ShallowString != null)
{
writeToFile(" UseDirective ---->" + item.ShallowString);
}
BgTok.Add(new BagOfVisitedNodes(_VisitedItem: item, _TypeOfVisitedItem: item.GetType()));
}
it is how i thought i would catch it and store it. it is never being called.if usedirective belongs to the namespace then this method should be called while visiting Namspace elements.
like "def classone" belongs to "class One" while visiting class members "def classone" would pop up i am catching it in Visit Methods() i think. how to get hold of usedirective or is it like
compiler directives stored somewhere but not in the node.
althou i see that it does not implement INamespacemember
so either i make
protected System.Collections.Generic.List<UseDirective> _useDirectives = null; to
public System.Collections.Generic.List<UseDirective> _useDirectives = null;
Thanking_You
RIGHT_THEN
- RIGHT_THEN
- Posts: 99
Re: Code File Visitation What Class Catches What
I see now. The directives are stored by NameSpace, but in their own list rather than as a declaration. I have just now added a public property for this which exposes them in changset:2489. Where you are handling namespaces, you will want to invoke .dispatch on "ns.useDirectives".
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: Code File Visitation What Class Catches What
Thanks Charles it works now
Thanking_You
RIGHT_THEN
Thanking_You
RIGHT_THEN
- RIGHT_THEN
- Posts: 99
Re: Code File Visitation What Class Catches What
Charles
When one wants to navigate to the constructor of the Class. how does one find its location
i dont find it anywhere. I checked the deepstring of the PostCallExpr but couldn`t find.
For localVar and other stuff that i am Charting through i am able to find them in shallow or deepstring and then i can naviagte to there Location of defination.
But Constructor is becoming a problem.
Thanking_You
RIGHT_THEN
When one wants to navigate to the constructor of the Class. how does one find its location
i dont find it anywhere. I checked the deepstring of the PostCallExpr but couldn`t find.
For localVar and other stuff that i am Charting through i am able to find them in shallow or deepstring and then i can naviagte to there Location of defination.
But Constructor is becoming a problem.
Thanking_You
RIGHT_THEN
- RIGHT_THEN
- Posts: 99
Re: Code File Visitation What Class Catches What
Do you really need to see it in the deep string? Why not loop through the decls or something?
# untested
for decl in someClass.declsInOrder
trace decl
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: Code File Visitation What Class Catches What
yes i am finding out about locations through visitation only
your for loop i will check too.
this is the senario
that is to clarify that i am not parsing deepstring to get hold of things thankfully Yet!.
Thanking_You
RIGHT_THEN
your for loop i will check too.
this is the senario
x = One() #<--- when user clicks GotoDefination the visitation expr happens to be
#PostCallExpr
#and when i dont find things i want, i print its deepString to see how to
#get hold of it. so the Deepstring of this PostCallExpr does not show its
#location of origin
Thanking_You
RIGHT_THEN
- RIGHT_THEN
- Posts: 99
13 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 58 guests