Re: [Vala] access static method

2019-03-26 Thread Miguel Miranda via vala-list
Namespace static method:

Namespace.staticmethodname ()

Class method:

Namespace.class.staticmethodname ()

On Tue, Mar 26, 2019, 15:25 Wolfgang Mauer 
wrote:

> How can i access a static method(Methods in Namespace are static?!) from
> a method inside a class that contains a method with the same name?
>
> namespace valaDevelop
> {
>  public string get_text(TextBuffer buffer, bool include_hidden_chars
> = true)
>  {
>  ...
>  }
>
>  public class abc
>  {
>  public void mymethod()
>  {
>  > //now i want to access the static method above not
> the one inside the class
>  }
> public string get_text()
> {
> ...
> }
>
>  }
>
> }
>
> I have already tried a few options, but it did not work
> "global.get_text", "valaDevelop.get_text", "::get_text" :-(
>
>
> Thanks for Help
> Wolfgang
>
>
>
>
> ___
> vala-list mailing list
> vala-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/vala-list
>
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] access static method

2019-03-26 Thread Wolfgang Mauer

Thanks for your answer...
That's what i thought
but if i try to use "valaDevelop.get_text" inside method mymethod in 
class abc

the compiler say:
/home/wolfgang/Projekte/vDevelop/valaDevelop/completion_provider.vala:59.80-59.99: 
error: The name `get_text' does not exist in the context of 
`valaDevelop.valaDevelop'
            _symbol_match = 
_symbol_finder.find_symbol_by_name(word.strip(), _fullpath, 
valaDevelop.get_text((SourceBuffer)currentIter.get_buffer()), 
currentIter.get_line()+1, currentIter.get_line_offset());


Can that be a Bug?
:-(


Am 26.03.19 um 16:56 schrieb Miguel Miranda:

Namespace static method:

Namespace.staticmethodname ()

Class method:

Namespace.class.staticmethodname ()

On Tue, Mar 26, 2019, 15:25 Wolfgang Mauer 
mailto:wolfgang.ma...@kabelmail.de>> wrote:


How can i access a static method(Methods in Namespace are
static?!) from
a method inside a class that contains a method with the same name?

namespace valaDevelop
{
 public string get_text(TextBuffer buffer, bool
include_hidden_chars
= true)
 {
 ...
 }

 public class abc
 {
     public void mymethod()
     {
         > //now i want to access the static method above not
the one inside the class
     }
public string get_text()
{
...
}

 }

}

I have already tried a few options, but it did not work
"global.get_text", "valaDevelop.get_text", "::get_text" :-(


Thanks for Help
Wolfgang




___
vala-list mailing list
vala-list@gnome.org 
https://mail.gnome.org/mailman/listinfo/vala-list


___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] access static method

2019-03-26 Thread Miguel Miranda via vala-list
namespace MyNamespace {

public static void static_method () {
print ("This is the namespace static method\n");
}

public class MyClass : Object {

public static void static_method () {
print ("This is the class method\n");
}

public void some_method () {
static_method ();
MyNamespace.static_method ();
MyNamespace.MyClass.static_method ();
}


public static void main () {
var a = new MyClass ();

a.some_method ();
}
}
}


After running:

This is the class method
This is the namespace static method
This is the class method

It seems to work fine, it even follows the implicit hierarchy of invoking
the class method when no namespace or class is mentioned.



On Tue, Mar 26, 2019 at 4:07 PM Wolfgang Mauer 
wrote:

> Thanks for your answer...
> That's what i thought
> but if i try to use "valaDevelop.get_text" inside method mymethod in class
> abc
> the compiler say:
> /home/wolfgang/Projekte/vDevelop/valaDevelop/completion_provider.vala:59.80-59.99:
> error: The name `get_text' does not exist in the context of
> `valaDevelop.valaDevelop'
> _symbol_match =
> _symbol_finder.find_symbol_by_name(word.strip(), _fullpath,
> valaDevelop.get_text((SourceBuffer)currentIter.get_buffer()),
> currentIter.get_line()+1, currentIter.get_line_offset());
>
>
> 
> Can that be a Bug?
> :-(
>
>
> Am 26.03.19 um 16:56 schrieb Miguel Miranda:
>
> Namespace static method:
>
> Namespace.staticmethodname ()
>
> Class method:
>
> Namespace.class.staticmethodname ()
>
> On Tue, Mar 26, 2019, 15:25 Wolfgang Mauer 
> wrote:
>
>> How can i access a static method(Methods in Namespace are static?!) from
>> a method inside a class that contains a method with the same name?
>>
>> namespace valaDevelop
>> {
>>  public string get_text(TextBuffer buffer, bool include_hidden_chars
>> = true)
>>  {
>>  ...
>>  }
>>
>>  public class abc
>>  {
>>  public void mymethod()
>>  {
>>  > //now i want to access the static method above not
>> the one inside the class
>>  }
>> public string get_text()
>> {
>> ...
>> }
>>
>>  }
>>
>> }
>>
>> I have already tried a few options, but it did not work
>> "global.get_text", "valaDevelop.get_text", "::get_text" :-(
>>
>>
>> Thanks for Help
>> Wolfgang
>>
>>
>>
>>
>> ___
>> vala-list mailing list
>> vala-list@gnome.org
>> https://mail.gnome.org/mailman/listinfo/vala-list
>>
>
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] access static method

2019-03-26 Thread Wolfgang Mauer
Thanks a lot, the only different i see is that my method inside the 
class is NOT static


Is this still working if you change from

public static void static_method () {
    print ("This is the class method\n");
    }

to

public void static_method () {
    print ("This is the class method\n");
    }


Thank you very much for help!!!


Am 26.03.19 um 17:21 schrieb Miguel Miranda:

namespace MyNamespace {

    public static void static_method () {
    print ("This is the namespace static method\n");
    }

    public class MyClass : Object {

    public static void static_method () {
    print ("This is the class method\n");
    }

    public void some_method () {
    static_method ();
    MyNamespace.static_method ();
    MyNamespace.MyClass.static_method ();
    }


    public static void main () {
    var a = new MyClass ();

    a.some_method ();
    }
    }
}


After running:

This is the class method
This is the namespace static method
This is the class method

It seems to work fine, it even follows the implicit hierarchy of 
invoking the class method when no namespace or class is mentioned.




On Tue, Mar 26, 2019 at 4:07 PM Wolfgang Mauer 
mailto:wolfgang.ma...@kabelmail.de>> wrote:


Thanks for your answer...
That's what i thought
but if i try to use "valaDevelop.get_text" inside method mymethod
in class abc
the compiler say:

/home/wolfgang/Projekte/vDevelop/valaDevelop/completion_provider.vala:59.80-59.99:
error: The name `get_text' does not exist in the context of
`valaDevelop.valaDevelop'
            _symbol_match =
_symbol_finder.find_symbol_by_name(word.strip(), _fullpath,
valaDevelop.get_text((SourceBuffer)currentIter.get_buffer()),
currentIter.get_line()+1, currentIter.get_line_offset());

Can that be a Bug?
:-(


Am 26.03.19 um 16:56 schrieb Miguel Miranda:

Namespace static method:

Namespace.staticmethodname ()

Class method:

Namespace.class.staticmethodname ()

On Tue, Mar 26, 2019, 15:25 Wolfgang Mauer
mailto:wolfgang.ma...@kabelmail.de>> wrote:

How can i access a static method(Methods in Namespace are
static?!) from
a method inside a class that contains a method with the same
name?

namespace valaDevelop
{
 public string get_text(TextBuffer buffer, bool
include_hidden_chars
= true)
 {
 ...
 }

 public class abc
 {
     public void mymethod()
     {
         > //now i want to access the static method
above not
the one inside the class
     }
public string get_text()
{
...
}

 }

}

I have already tried a few options, but it did not work
"global.get_text", "valaDevelop.get_text", "::get_text" :-(


Thanks for Help
Wolfgang




___
vala-list mailing list
vala-list@gnome.org 
https://mail.gnome.org/mailman/listinfo/vala-list


___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] access static method

2019-03-26 Thread Wolfgang Mauer
I can not explain why that does not work for me, I have renamed the 
static method now Nevertheless many thanks...



Am 26.03.19 um 17:26 schrieb Wolfgang Mauer:

namespace MyNamespace {

    public static void static_method () {
    print ("This is the namespace static method\n");
    }

    public class MyClass : Object {

    public static void static_method () {
    print ("This is the class method\n");
    }

    public void some_method () {
    static_method ();
    MyNamespace.static_method ();
    MyNamespace.MyClass.static_method ();
    }


    public static void main () {
    var a = new MyClass ();

    a.some_method ();
    }
    }
}

___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] access static method

2019-03-26 Thread Miguel Miranda via vala-list
I bit busy atm. Result without static keyword in the namespace is the same.

gl

On Tue, Mar 26, 2019, 16:49 Wolfgang Mauer 
wrote:

> I can not explain why that does not work for me, I have renamed the static 
> method nowNevertheless many thanks...
>
>
> Am 26.03.19 um 17:26 schrieb Wolfgang Mauer:
>
> namespace MyNamespace {
>
> public static void static_method () {
> print ("This is the namespace static method\n");
> }
>
> public class MyClass : Object {
>
> public static void static_method () {
> print ("This is the class method\n");
> }
>
> public void some_method () {
> static_method ();
> MyNamespace.static_method ();
> MyNamespace.MyClass.static_method ();
> }
>
>
> public static void main () {
> var a = new MyClass ();
>
> a.some_method ();
> }
> }
> }
>
>
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] access static method

2019-03-30 Thread Abderrahim Kitouni via vala-list

Hi,

It seems you solved your issue, but here is the answer to your question.
On ث, مارس 26, 2019 at 5:07 م, Wolfgang Mauer 
 wrote:

Thanks for your answer...
That's what i thought
but if i try to use "valaDevelop.get_text" inside method mymethod in 
class abc

the compiler say:
/home/wolfgang/Projekte/vDevelop/valaDevelop/completion_provider.vala:59.80-59.99: 
error: The name `get_text' does not exist in the context of 
`valaDevelop.valaDevelop'


This means that it's trying to lookup the get_text method in the 
valaDevelop class which is inside the valaDevelop namespace.


There is a construct in vala for accessing this anyway, IIRC 
global::valaDevelop.get_text should get to the method you want.


However, I think the real solution is to use sensible names for your 
classes/methods and not have to figure out which of the similarly named 
things the symbol resolver is going to pick. For instance, your 
valaDevelop class could be named Main.


HTH,
Abderrahim


___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] access static method

2019-03-30 Thread Wolfgang Mauer

Thank you very much!

"global::" That's what i'm looking for...


Am 30.03.19 um 23:32 schrieb Abderrahim Kitouni:

Hi,

It seems you solved your issue, but here is the answer to your question.
On ث, مارس 26, 2019 at 5:07 م, Wolfgang Mauer 
 wrote:

Thanks for your answer...
That's what i thought
but if i try to use "valaDevelop.get_text" inside method mymethod in 
class abc

the compiler say:
/home/wolfgang/Projekte/vDevelop/valaDevelop/completion_provider.vala:59.80-59.99: 
error: The name `get_text' does not exist in the context of 
`valaDevelop.valaDevelop'


This means that it's trying to lookup the get_text method in the 
valaDevelop class which is inside the valaDevelop namespace.


There is a construct in vala for accessing this anyway, IIRC 
global::valaDevelop.get_text should get to the method you want.


However, I think the real solution is to use sensible names for your 
classes/methods and not have to figure out which of the similarly 
named things the symbol resolver is going to pick. For instance, your 
valaDevelop class could be named Main.


HTH,
Abderrahim




___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list