clemos / haxe-sublime-bundle

Sublime Text bundle for Haxe programming language
Apache License 2.0
235 stars 86 forks source link

Code generation for properties doesn't work correctly #239

Closed rkachowski closed 9 years ago

rkachowski commented 9 years ago

When trying to generate variables and properties as shown in the generate property page, the command is unresponsive and I get the following error in the console.

Traceback (most recent call last):
  File "./sublime_plugin.py", line 356, in run_
  File "./features/haxe_generate_field.py", line 23, in run
  File "./features/haxe_generate_code_helper.py", line 213, in set_pos
Boost.Python.ArgumentError: Python argument types in
    Region.__init__(Region, float, float)
did not match C++ signature:
    __init__(_object*, long long)
    __init__(_object*, long long, long long, double)
    __init__(_object*, long long, long long)

The file I'm using is here

package;
import game.Card;
import game.Card.Pip;
import game.Card.Suite.Clubs;
import game.Hand;
import game.rules.Valuator;

import haxe.unit.TestCase ;

class ValuatorTest extends TestCase {
        //try to invoke "New var _testHand" here via ctrl+shift+1
    var testHand(get, set):Hand = new Hand();
    public var testCards:Array<Card>;

    override public function setup()
    {
        testHand = new Hand();
        testCards = new Array<Card>();
    }

    public function testBasic()
    {
        testHand.addCard(new Card(Clubs,Pip.TWO));
        testHand.addCard(new Card(Clubs,Pip.TWO));

        assertEquals(4, Valuator.getValue(testHand));
    }
}

I'm running OSX 10.10.3 Sublime Text 2 2.0.2.2221 Haxe Plugin (no version info?? latest as of 23/6/15)

ghost commented 9 years ago

I could not reproduce the issue. But the last commit can fix it. Please check.

rkachowski commented 9 years ago

@r3a1ay I've tried your patch but it leads to another signature mismatch error elsewhere in the code

Traceback (most recent call last):
  File "./sublime_plugin.py", line 356, in run_
  File "./features/haxe_generate_field.py", line 62, in run
Boost.Python.ArgumentError: Python argument types in
    View.full_line(View, float)
did not match C++ signature:
    full_line(SP<TextBufferView>, SelectionRegion)
    full_line(SP<TextBufferView>, long long)

it seems like all these float / long values should already be cast correctly, and presumably they are working on other platforms?

ghost commented 9 years ago

On linux ST2 and ST3 all working fine. Can you try to add this line in haxe_generate_field.py after line 47?

pos = int(pos)
...
class HaxeGenerateFieldEdit(sublime_plugin.TextCommand):

    def run(self, edit, text=None, pos=0, move=True):
        if text is None:
            return

        view = self.view
        pos = int(pos) # here
...
ghost commented 9 years ago

It seems that you have the same issue in promote local var feature. Please try that feature.

ghost commented 9 years ago

Please try the latest version.

rkachowski commented 9 years ago

This problem also occurs in the latest version.

error: A plugin (HaxeComplete) may be making Sublime Text unresponsive by taking too long (3.784049s) in its on_activated callback.

This message can be disabled via the detect_slow_plugins setting
./features/haxe_generate_code_helper.py:31: DeprecationWarning: integer argument expected, got float
./features/haxe_generate_code_helper.py:38: DeprecationWarning: integer argument expected, got float
Traceback (most recent call last):
  File "./sublime_plugin.py", line 356, in run_
  File "./features/haxe_generate_field.py", line 62, in run
Boost.Python.ArgumentError: Python argument types in
    View.full_line(View, float)
did not match C++ signature:
    full_line(SP<TextBufferView>, SelectionRegion)
    full_line(SP<TextBufferView>, long long)
ghost commented 9 years ago

It seems that you aren't using the latest version of the package. Try to reinstall the package (via Package Control). Or download the archive, unpack it to Packages folder and rename haxe-sublime-bundle-master folder to Haxe.

ghost commented 9 years ago

Let me know if that doesn't help.