Skip to content

Commit

Permalink
Fix ScopeTree query for global user functions (#66)
Browse files Browse the repository at this point in the history
* Update polserver to bd06c58

* Add tests
  • Loading branch information
KevinEady authored Nov 7, 2024
1 parent cd6e814 commit 6a40dbf
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion native/polserver
Submodule polserver updated 94 files
+4 −0 .github/workflows/armbuild.yml_
+4 −0 .github/workflows/build.yml
+4 −0 .github/workflows/buildmacos.yml
+4 −0 .github/workflows/buildsan.yml
+4 −0 .github/workflows/buildwinnopch.yml
+4 −0 .github/workflows/clang-format.yml
+4 −0 .github/workflows/coverage.yml
+62 −48 docs/docs.polserver.com/pol100/configfiles.xml
+27 −1 docs/docs.polserver.com/pol100/corechanges.xml
+10 −1 docs/docs.polserver.com/pol100/objref.xml
+3 −1 pol-core/bscript/compiler/model/ScopeTree.cpp
+5 −0 pol-core/bscript/objaccess.cpp
+6 −1 pol-core/bscript/objmembers.h
+17 −0 pol-core/doc/core-changes.txt
+17 −8 pol-core/ecompile/ECompileMain.cpp
+3 −0 pol-core/plib/CMakeSources.cmake
+230 −0 pol-core/plib/objtype.h
+179 −0 pol-core/plib/polcfg.cpp
+119 −0 pol-core/plib/polcfg.h
+1 −1 pol-core/plib/systemstate.cpp
+2 −2 pol-core/plib/systemstate.h
+1 −1 pol-core/plib/tiles.cpp
+1 −1 pol-core/plib/uofile00.cpp
+0 −3 pol-core/pol/CMakeSources.cmake
+0 −1 pol-core/pol/accounts/account.cpp
+2 −3 pol-core/pol/accounts/acscrobj.cpp
+0 −1 pol-core/pol/cfgrepos.cpp
+77 −0 pol-core/pol/core.cpp
+2 −3 pol-core/pol/core.h
+1 −2 pol-core/pol/create.cpp
+1 −1 pol-core/pol/dblclick.cpp
+0 −1 pol-core/pol/decay.cpp
+1 −2 pol-core/pol/dropitem.cpp
+101 −95 pol-core/pol/dynproperties.h
+0 −1 pol-core/pol/exscrobj.cpp
+2 −8 pol-core/pol/globals/object_storage.cpp
+0 −5 pol-core/pol/globals/object_storage.h
+20 −2 pol-core/pol/globals/uvars.cpp
+1 −1 pol-core/pol/globals/uvars.h
+14 −2 pol-core/pol/item/item.cpp
+11 −4 pol-core/pol/item/itemcr.cpp
+20 −0 pol-core/pol/item/itemdesc.cpp
+4 −0 pol-core/pol/item/itemdesc.h
+18 −6 pol-core/pol/item/weapon.cpp
+0 −73 pol-core/pol/loaddata.cpp
+0 −6 pol-core/pol/loaddata.h
+4 −3 pol-core/pol/loadunld.cpp
+0 −1 pol-core/pol/login.cpp
+1 −8 pol-core/pol/miscmsg.cpp
+65 −4 pol-core/pol/mobile/charactr.cpp
+2 −0 pol-core/pol/mobile/charactr.h
+20 −0 pol-core/pol/mobile/npc.cpp
+2 −0 pol-core/pol/mobile/npc.h
+1 −1 pol-core/pol/mobile/wornitems.cpp
+1 −1 pol-core/pol/module/npcmod.cpp
+0 −1 pol-core/pol/module/osmod.cpp
+0 −1 pol-core/pol/module/polsystemmod.cpp
+2 −19 pol-core/pol/module/uomod.cpp
+1 −1 pol-core/pol/module/uomod2.cpp
+3 −1 pol-core/pol/network/cgdata.cpp
+2 −0 pol-core/pol/network/cgdata.h
+54 −3 pol-core/pol/network/client.cpp
+4 −1 pol-core/pol/network/client.h
+0 −1 pol-core/pol/network/clientthread.cpp
+1 −2 pol-core/pol/partyscrobj.cpp
+3 −14 pol-core/pol/pol.cpp
+0 −1 pol-core/pol/polwww.cpp
+0 −1 pol-core/pol/proplist.cpp
+1 −1 pol-core/pol/realms/realmfunc.cpp
+0 −1 pol-core/pol/regions/resource.cpp
+520 −212 pol-core/pol/savedata.cpp
+1 −5 pol-core/pol/savedata.h
+0 −1 pol-core/pol/scrstore.cpp
+6 −0 pol-core/pol/ssopt.cpp
+5 −1 pol-core/pol/ssopt.h
+0 −8 pol-core/pol/storage.cpp
+3 −5 pol-core/pol/storage.h
+28 −0 pol-core/pol/tasks.cpp
+3 −2 pol-core/pol/tasks.h
+1 −2 pol-core/pol/ufunc.cpp
+0 −621 pol-core/pol/uimport.cpp
+2 −3 pol-core/pol/uimport.h
+13 −2 pol-core/pol/uobject.cpp
+4 −0 pol-core/pol/uobject.h
+0 −1 pol-core/pol/uoexec.cpp
+72 −0 pol-core/pol/uoscrobj.cpp
+26 −0 pol-core/poltool/baredistrofiles.cpp
+0 −1 pol-core/runecl/RunEclMain.cpp
+1 −1 pol-core/uoconvert/UoConvertMain.cpp
+1 −1 pol-core/uotool/UoToolMain.cpp
+44 −2 testsuite/pol/testpkgs/attack/test_npc_attack.src
+41 −12 testsuite/pol/testpkgs/client/test_client_range.src
+10 −1 testsuite/testclient/pyuo/pyuo/client.py
+19 −4 testsuite/testclient/pyuo/pyuo/packets.py
40 changes: 37 additions & 3 deletions native/test/native.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,16 @@ describe('Hover - SRC', () => {
const hover = getHover('class Foo() function Foo( this ) this.foo := "foo"; this.parent_method_func(); endfunction function parent_method_func( this ) this.foo; endfunction endclass class Bar( Foo ) function Bar( this ) super(); this.bar := "bar"; this.child_method_func(); endfunction function child_method_func( this ) this.foo; this.bar; this.parent_method_func(); endfunction endclass Bar::Bar();', 236);
expect(hover).toEqual(escriptdoc('(class method) Bar::child_method_func( this )'))
});

it('Can hover global functions without specifying query prefix', () => {
const hover = getHover('function StaticFunction(a0) endfunction class Foo() function Foo(this) StaticFunction(0); endfunction endclass StaticFunction("");', 74)
expect(hover).toEqual(escriptdoc('(user function) StaticFunction( a0 )'))
});

it('Can hover global functions with specifying query prefix', () => {
const hover = getHover('function StaticFunction(a0) endfunction class Foo() function Foo(this) ::StaticFunction(0); endfunction endclass StaticFunction("");', 76)
expect(hover).toEqual(escriptdoc('(user function) StaticFunction( a0 )'))
});
});

describe('Hover - Classes', () => {
Expand Down Expand Up @@ -611,9 +621,9 @@ describe('Definition - SRC', () => {
};

const expectColumnRange = (definition: ReturnType<typeof getDefinition>, start: number, end: number) => {
expect(definition).toBeDefined();
expect(definition?.range.start.character).toEqual(start);
expect(definition?.range.end.character).toEqual(end);
toBeDefined(definition);
expect(definition.range.start.character).toEqual(start);
expect(definition.range.end.character).toEqual(end);
};

it('Can define variable', () => {
Expand Down Expand Up @@ -733,6 +743,16 @@ describe('Definition - SRC', () => {
const definition = getDefinition('class Foo() function Foo( this ) this.foo := "foo"; this.parent_method_func(); endfunction function parent_method_func( this ) this.foo; endfunction endclass class Bar( Foo ) function Bar( this ) super(); this.bar := "bar"; this.child_method_func(); endfunction function child_method_func( this ) this.foo; this.bar; this.parent_method_func(); endfunction endclass Bar::Bar();', 236);
expectColumnRange(definition, 262, 355);
});

it('Can define global functions without specifying query prefix', () => {
const definition = getDefinition('function StaticFunction(a0) endfunction class Foo() function Foo(this) StaticFunction(0); endfunction endclass StaticFunction("");', 74)
expectColumnRange(definition, 0, 39);
});

it('Can define global functions with specifying query prefix', () => {
const definition = getDefinition('function StaticFunction(a0) endfunction class Foo() function Foo(this) ::StaticFunction(0); endfunction endclass StaticFunction("");', 76)
expectColumnRange(definition, 0, 39);
});
});


Expand Down Expand Up @@ -958,6 +978,20 @@ describe('Completion', () => {
{ label: 'foo', kind: 5 }
]);
});

it('Can complete global functions without specifying query prefix', () => {
const completion = getCompletion('function StaticFunction(a0) endfunction class Foo() function Foo(this) Sta endfunction endclass StaticFunction("");', 74)
expect(completion).toEqual([
{ label: 'StaticFunction', kind: 3 },
]);
});

it('Can complete global functions with specifying query prefix', () => {
const completion = getCompletion('function StaticFunction(a0) endfunction class Foo() function Foo(this) ::Sta endfunction endclass StaticFunction("");', 76)
expect(completion).toEqual([
{ label: 'StaticFunction', kind: 3 },
]);
});
});

describe('Signature Help', () => {
Expand Down

0 comments on commit 6a40dbf

Please sign in to comment.