* test/lisp/cedet/semantic-utest-ia.el (ert, ert-x): Require.
(cedet-utest-directory, semantic-utest-test-directory): Remove
variables.
(semantic-utest-ia-doublens.cpp, semantic-utest-ia-subclass.cpp)
(semantic-utest-ia-typedefs.cpp, semantic-utest-ia-struct.cpp)
(semantic-utest-ia-templates.cpp, semantic-utest-ia-using.cpp)
(semantic-utest-ia-nsp.cpp, semantic-utest-ia-localvars.cpp)
(semantic-utest-ia-namespace.cpp)
(semantic-utest-ia-sppcomplete.c, semantic-utest-ia-varnames.c)
(semantic-utest-ia-javacomp.java)
(semantic-utest-ia-varnames.java, semantic-utest-ia-wisent.wy)
(semantic-utest-ia-texi, semantic-utest-ia-make)
(semantic-utest-ia-srecoder): Use 'ert-resource-file'. Don't
check if file exists; we can assume that it does.
* test/manual/cedet/tests/testjavacomp.java:
* test/manual/cedet/tests/testlocalvars.cpp:
* test/manual/cedet/tests/testnsp.cpp:
* test/manual/cedet/tests/testsppcomplete.c:
* test/manual/cedet/tests/teststruct.cpp:
* test/manual/cedet/tests/testsubclass.cpp:
* test/manual/cedet/tests/testsubclass.hh:
* test/manual/cedet/tests/testtemplates.cpp:
* test/manual/cedet/tests/testtypedefs.cpp:
* test/manual/cedet/tests/testusing.cpp:
* test/manual/cedet/tests/testusing.hh:
* test/manual/cedet/tests/testvarnames.c:
* test/manual/cedet/tests/testvarnames.java:
* test/manual/cedet/tests/testwisent.wy: Move from here...
* test/lisp/cedet/semantic-utest-ia-resources/testjavacomp.java:
* test/lisp/cedet/semantic-utest-ia-resources/testlocalvars.cpp:
* test/lisp/cedet/semantic-utest-ia-resources/testnsp.cpp:
* test/lisp/cedet/semantic-utest-ia-resources/testsppcomplete.c:
* test/lisp/cedet/semantic-utest-ia-resources/teststruct.cpp:
* test/lisp/cedet/semantic-utest-ia-resources/testsubclass.cpp:
* test/lisp/cedet/semantic-utest-ia-resources/testsubclass.hh:
* test/lisp/cedet/semantic-utest-ia-resources/testtemplates.cpp:
* test/lisp/cedet/semantic-utest-ia-resources/testtypedefs.cpp:
* test/lisp/cedet/semantic-utest-ia-resources/testusing.cpp:
* test/lisp/cedet/semantic-utest-ia-resources/testusing.hh:
* test/lisp/cedet/semantic-utest-ia-resources/testvarnames.c:
* test/lisp/cedet/semantic-utest-ia-resources/testvarnames.java:
* test/lisp/cedet/semantic-utest-ia-resources/testwisent.wy:
...to here.
--- /dev/null
+# A Test Makefile. -*-makefile-*-
+
+# This test is for a file in this test directory. Just a random one.
+FILES=testdoub # -1-
+# #1# ("testdoublens.cpp" "testdoublens.hpp" )
+
+all: optional
+
+# This one completes on a variable name.
+optional: $FIL # -2-
+ # #2# ("FILES")
+ compile $@
+
+notoptional: opt # -3-
+ # #3# ("optional")
+ echo "Done."
+
+#end
--- /dev/null
+;; test.srt --- unit test support file for semantic-utest-ia
+
+;; Copyright (C) 2008-2021 Free Software Foundation, Inc.
+
+;; Author: Eric M. Ludlam <zappo@gnu.org>
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+;;
+
+set mode "c++-mode"
+set escape_start "{{"
+set escape_end "}}"
+
+context file
+
+template class :blank
+"A test template for emacs lisp"
+----
+----
+
+template classic :blank
+"A test template for emacs lisp"
+----
+----
+
+template variable :blank
+"A test template for emacs lisp"
+----
+----
+
+template function :blank
+"A test template for emacs lisp"
+----
+----
+
+template testarea :blank
+"A test template for emacs lisp"
+----
+{{<A:cla}} -1-
+ }} #1# ( "class" "classic" )
+ {{^}}
+
+{{/A}}
+----
+
+;; This is a bad hack - In order for the text to parse, but also get a completion
+;; moniker into the right spot, we need to pretend a comment is the same as the
+;; escape_end.
+;; Local variables:
+;; comment-start-skip: "}}"
+;; End:
--- /dev/null
+\input texinfo
+@setfilename test.info
+@set TITLE TEST
+@set AUTHOR Eric Ludlam
+@settitle @value{TITLE}
+
+@ifinfo
+@format
+START-INFO-DIR-ENTRY
+* test: (test). TEST
+END-INFO-DIR-ENTRY
+@end format
+@end ifinfo
+
+@titlepage
+@sp 10
+@center @titlefont{test}
+@vskip 0pt plus 1 fill
+Copyright @copyright{} 2015 Eric Ludlam
+@end titlepage
+
+@node Top
+@top @value{TITLE}
+
+This is a simple manual filled with stuff that should test completion in texinfo mode.
+
+@m@c -1-
+@c #1# ( "@majorheading" "@macro" "@menu" "@multitable" )
+
+@menu
+* Index::
+@end menu
+
+
+@node Index
+@chapter Index
+
+@contents
+
+@bye
--- /dev/null
+// testdoublens.cpp --- semantic-ia-utest completion engine unit tests
+
+// Copyright (C) 2008-2021 Free Software Foundation, Inc.
+
+// Author: Eric M. Ludlam <zappo@gnu.org>
+
+// This file is part of GNU Emacs.
+
+// GNU Emacs is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// GNU Emacs is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+#include "testdoublens.hpp"
+
+namespace Name1 {
+ namespace Name2 {
+
+ Foo::Foo()
+ {
+ p// -1-
+ // #1# ( "pMumble" "publishStuff" )
+ ;
+ }
+
+ int Foo::get() // ^1^
+ {
+ p// -2-
+ // #2# ( "pMumble" "publishStuff" )
+ ;
+ return 0;
+ }
+
+ void Foo::publishStuff(int a, int b) // ^2^
+ {
+ int foo = a;
+ int bar = b;
+ }
+
+ // Test polymorphism on arg types. Note that order is
+ // mixed to maximize failure cases
+ void Foo::publishStuff(char a, char b) // ^4^
+ {
+ int foo = a;
+ int bar = b;
+ }
+
+ void Foo::sendStuff(int a, int b) // ^3^
+ {
+ int foo = a;
+ int bar = b;
+
+ Foo::publishStuff(1,2)
+
+ }
+
+ } // namespace Name2
+} // namespace Name1
+
+// Test multiple levels of metatype expansion
+int test_fcn () {
+ stage3_Foo MyFoo;
+
+ MyFoo.// -3-
+ // #3# ( "Mumble" "get" )
+ ;
+
+ Name1::Name2::F//-4-
+ // #4# ( "Foo" )
+ ;
+
+ // @TODO - get this working...
+ Name1::stage2_Foo::M//-5-
+ /// #5# ( "Mumble" )
+ ;
+}
+
+stage3_Foo foo_fcn() {
+ // Can we go "up" to foo with senator-go-to-up-reference?
+}
+
+
+// Second test from Ravikiran Rajagopal
+
+namespace A {
+ class foo {
+ public:
+ void aa();
+ void bb();
+ };
+}
+namespace A {
+ class bar {
+ public:
+ void xx();
+ public:
+ foo myFoo;
+ };
+
+ void bar::xx()
+ {
+ myFoo.// -6- <--- cursor is here after the dot
+ // #6# ( "aa" "bb" )
+ ;
+ }
+}
+
+// Double namespace example from Hannu Koivisto
+//
+// This is tricky because the parent class "Foo" is found within the
+// scope of B, so the scope calculation needs to put that together
+// before searching for parents in scope.
+namespace a {
+ namespace b {
+
+ class Bar : public Foo
+ {
+ int baz();
+ };
+
+ int Bar::baz()
+ {
+ return dum// -7-
+ // #7# ( "dumdum" )
+ ;
+ }
+
+ } // namespace b
+} // namespace a
+
+// Three namespace example from Hannu Koivisto
+//
+// This one is special in that the name e::Foo, where "e" is in
+// the scope, and not referenced from the global namespace. This
+// wasn't previously handled, so the fullscope needed to be added
+// to the list of things searched when in split-name decent search mode
+// for scopes.
+
+namespace d {
+ namespace e {
+
+ class Foo
+ {
+ public:
+ int write();
+ };
+
+ } // namespace d
+} // namespace e
+
+
+namespace d {
+ namespace f {
+
+ class Bar
+ {
+ public:
+ int baz();
+
+ private:
+ e::Foo &foo;
+ };
+
+ int Bar::baz()
+ {
+ return foo.w// -8-
+ // #8# ( "write" )
+ ;
+ }
+
+ } // namespace f
+} // namespace d
+
+// Fully qualified const struct function arguments
+class ContainsStruct
+{
+ struct TheStruct
+ {
+ int memberOne;
+ int memberTwo;
+ };
+};
+
+void someFunc(const struct ContainsStruct::TheStruct *foo)
+{
+ foo->// -9-
+ // #9# ("memberOne" "memberTwo")
+}
+
+// Class with structure tag
+class ContainsNamedStruct
+{
+ struct _fooStruct
+ {
+ int memberOne;
+ int memberTwo;
+ } member;
+};
+
+void someOtherFunc(void)
+{
+ ContainsNamedStruct *someClass;
+ // This has to find ContainsNamedStruct::_fooStruct
+ someClass->member.// -10-
+ // #10# ("memberOne" "memberTwo")
+}
--- /dev/null
+// testdoublens.hpp --- Header file used in one of the Semantic tests
+
+// Copyright (C) 2008-2021 Free Software Foundation, Inc.
+
+// Author: Eric M. Ludlam <zappo@gnu.org>
+
+// This file is part of GNU Emacs.
+
+// GNU Emacs is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// GNU Emacs is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+namespace Name1 {
+ namespace Name2 {
+
+ class Foo
+ {
+ typedef unsigned int Mumble;
+ public:
+ Foo();
+ ~Foo();
+ int get();
+
+ private:
+ void publishStuff(char /* a */, char /* b */);
+
+ void publishStuff(int q, int r); // Purposely different names.
+
+ void sendStuff(int a, int b);
+
+ Mumble* pMumble;
+ };
+
+ typedef Foo stage1_Foo;
+
+ } // namespace Name2
+
+ typedef Name2::stage1_Foo stage2_Foo;
+
+ typedef Name2::Foo decl_stage1_Foo;
+
+} // namespace Name1
+
+typedef Name1::stage2_Foo stage3_Foo;
+
+
+// Double namespace from Hannu Koivisto
+namespace a {
+ namespace b {
+
+ class Foo
+ {
+ struct Dum {
+ int diDum;
+ };
+
+ protected:
+ mutable a::b::Foo::Dum dumdum;
+ };
+
+ } // namespace b
+} // namespace a
--- /dev/null
+// Test parsing of friends and how they are used in completion.
+/*
+ >> Thanks Damien Profeta for the nice example.
+ >
+ > I paste a small example.
+ > It would be great if friend can be well parsed and even greater if
+ > class B can access to all the members of A.
+*/
+
+class Af // %2% ( ( "testfriends.cpp" ) ( "Af" "B::testB" ) )
+{
+public:
+ int pubVar;
+private:
+ int privateVar;
+
+ friend class B;
+
+};
+
+class B
+{
+public:
+ int testB();
+ int testAB();
+
+};
+
+
+int B::testB() {
+ Af classA;
+ classA.//-1-
+ ; //#1# ( "privateVar" "pubVar" )
+}
+
+int B::testAB() { // %1% ( ( "testfriends.cpp" ) ( "B" "B::testAB" ) )
+}
--- /dev/null
+// testjavacomp.java --- Semantic unit test for Java
+
+// Copyright (C) 2009-2021 Free Software Foundation, Inc.
+
+// Author: Eric M. Ludlam <zappo@gnu.org>
+
+// This file is part of GNU Emacs.
+
+// GNU Emacs is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// GNU Emacs is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+package tests.testjavacomp;
+
+class secondClass {
+ private void scFuncOne() { }
+ public void scFuncOne() { }
+
+ int package_protected_field;
+ public int public_protected_field;
+ private int private_protected_field;
+}
+
+
+public class testjavacomp {
+
+ private int funcOne() { }
+ private int funcTwo() { }
+ private char funcThree() { }
+
+ class nestedClass {
+ private void ncFuncOne() { }
+ public void ncFuncOne() { }
+ }
+
+ public void publicFunc() {
+
+ int i;
+
+ i = fu// -1-
+ // #1# ( "funcOne" "funcTwo" )
+ ;
+
+ fu// -2-
+ // #2# ( "funcOne" "funcThree" "funcTwo" )
+ ;
+
+ secondClass SC;
+
+ SC.s//-3-
+ // #3# ( "scFuncOne" )
+ ;
+
+ // @TODO - to make this test complete, we need an import
+ // with a package protected field that is excluded
+ // from the completion list.
+ SC.p//-4-
+ // #4# ( "package_protected_field" "public_protected_field" )
+
+ nestedClass NC;
+
+ // @todo - need to fix this? I don't know if this is legal java.
+ NC.// - 5-
+ // #5# ( "ncFuncOne" )
+ ;
+ }
+
+} // testjavacomp
--- /dev/null
+// testlocalvars.java --- Semantic unit test for Java
+
+// Copyright (C) 2009-2021 Free Software Foundation, Inc.
+
+// Author: Eric M. Ludlam <zappo@gnu.org>
+
+// This file is part of GNU Emacs.
+
+// GNU Emacs is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// GNU Emacs is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+
+class foo {
+ foo *member;
+ char anArray[10];
+};
+
+void func()
+{
+ foo local1;
+ foo* local2 = localvar.member;
+ foo* local3 = new foo();
+ foo local4[10];
+ char local5[5] = {'1','2','3','4','5'};
+ char *local6 = "12345";
+ char local7 = local.anArray[0];
+ char local8 = true ? 10 : 11 ;
+
+ // Check that all of the above was parsed
+ local//-1-
+ ; //#1# ("local1" "local2" "local3" "local4" "local5" "local6" "local7" "local8" )
+
+ local1.//-2-
+ ; //#2# ("anArray" "member")
+
+ local2->//-3-
+ ; //#3# ("anArray" "member")
+
+ local3->//-4-
+ ; //#4# ("anArray" "member")
+
+ local4[0].//-5-
+ ; //#5# ("anArray" "member")
+}
--- /dev/null
+/* testnsp.cpp --- semantic-ia-utest completion engine unit tests
+
+ Copyright (C) 2008-2021 Free Software Foundation, Inc.
+
+ Author: Eric M. Ludlam <zappo@gnu.org>
+
+ This file is part of GNU Emacs.
+
+ GNU Emacs is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ GNU Emacs is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+*/
+
+namespace nsp {
+
+ class rootclass {
+ public:
+ int fromroot() {};
+ };
+
+}
+
+namespace nsp {
+ class childclass : public rootclass {
+ public:
+ int fromchild() {};
+ };
+}
+
+void myfcn_not_in_ns (void) {
+ nsp::childclass test;
+
+ test.// -1-
+ ; // #1# ( "fromchild" "fromroot" )
+}
+
+// Test a class declared in a class, where the contents
+// are in a qualified name.
+//
+// Thanks Michael Reiher for the concise example.
+
+class AAA
+{
+public:
+ AAA();
+
+ void aaa();
+
+private:
+ class Private;
+ Private * const d;
+};
+
+class AAA::Private
+{
+ Private() : bbb(0) {
+ }
+
+ BBB* bbb;
+};
+
+void AAA::aaa()
+{
+ d->// -2-
+ ; // #2# ( "bbb" )
+}
+
+// #include files inside a namespace
+// David Engster <deng@randomsample.de>
+// See revisions 8034-8037 which implement this.
+
+namespace another {
+ #include "testdoublens.hpp"
+}
+
+void foo(void) {
+
+ another::// -3-
+ ; // #3# ( "Name1" "a" "stage3_Foo" )
+
+ another::Name1::Name2::Foo a;
+
+ a.// -4-
+ ; // #4# ( "Mumble" "get" )
+}
+
+// What happens if a type your looking for is scoped within a type,
+// but you are one level into the completion so the originating scope
+// excludes the type of the variable you are completing through?
+// Thanks Martin Stein for this nice example.
+
+namespace ms_structs
+{
+ struct ms_aaa
+ {
+ int xx;
+ };
+
+ struct ms_bbb
+ {
+ struct ms_aaa yy;
+ };
+};
+
+int fun()
+{
+ using namespace ms_structs;
+ struct ms_bbb mszz;
+ int uu = mszz.// -5-
+ ; // #5# ( "yy" )
+ int kk = mszz.yy.// - 6- @TODO - bring in patch from SF
+ ; // #6# ( "xx" )
+}
--- /dev/null
+/* testesppcomplete.cpp --- semantic-ia-utest completion engine unit tests
+
+ Copyright (C) 2008-2021 Free Software Foundation, Inc.
+
+ Author: Eric M. Ludlam <zappo@gnu.org>
+
+ This file is part of GNU Emacs.
+
+ GNU Emacs is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ GNU Emacs is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+*/
+
+/* Example provided by Hannes Janetzek */
+
+struct Test { int test; };
+
+#define BLA(_type) \
+ _type *bla = (_type*) malloc(sizeof(_type));
+
+#define BLUB(_type) \
+ (_type*)malloc(sizeof(_type));
+
+#define FOO(_type) \
+ _type *foo = BLUB(_type);
+
+#define BAR(_type) \
+ _type *bar = (*_type)BLUB(_type);
+
+int main(int argc, char *argv[]) {
+ BLA(Test);
+ bla->// -1-
+ ; // #1# ( "test" )
+
+ FOO(Test);
+ foo->// -2-
+ ; // #2# ( "test" )
+
+ BAR(Test);
+ bar->// -3-
+ ; // #3# ( "test" )
+}
+
+/* Test symref and macros together. */
+
+// This function exists only so we can have a comment in a tag with this name.
+void function_with_macro_name ()
+// %1% ( ( "testsppcomplete.c" ) ( "function_with_macro_name" "function_with_macro_name" "use_macro") )
+// Note: fwmn is in twice, once for function, and once for the constant macro below.
+{
+}
+
+#define function_with_macro_name 1
+
+int use_macro () {
+ int a = function_with_macro_name;
+}
--- /dev/null
+// teststruct.cpp --- semantic-ia-utest completion engine unit tests
+
+// Copyright (C) 2008-2021 Free Software Foundation, Inc.
+
+// Author: Eric M. Ludlam <zappo@gnu.org>
+
+// This file is part of GNU Emacs.
+
+// GNU Emacs is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// GNU Emacs is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+
+// Note: initially provided by by Alex Ott.
+
+template <typename DerivedT>
+struct grammar {
+public:
+ typedef grammar<DerivedT> self_t;
+ typedef DerivedT const& embed_t;
+ grammar() {}
+ ~grammar() { }
+ void use_parser() const { }
+ void test1() { }
+};
+
+struct PDFbool_parser : public grammar<PDFbool_parser> {
+ PDFbool_parser() {}
+ template <typename scannerT> struct definition {
+ typedef typename scannerT::iterator_t iterator_t;
+ int top;
+ definition(const PDFbool_parser& /*self*/) {
+ return ;
+ }
+ const int start() const {
+ return top;
+ }
+ };
+};
+
+int main(void) {
+ PDFbool_parser PDFbool_p = PDFbool_parser();
+ PDFbool_p.//-1-
+ ;
+ // #1# ("definition" "embed_t" "self_t" "test1" "use_parser")
+}
+
+// ----------------------------------------------------------------------
+
+template <class Derived> struct Base {
+public:
+ void interface()
+ {
+ // ...
+ static_cast<Derived*>(this)->implementation();
+ // ...
+ }
+
+ static void static_func()
+ {
+ // ...
+ Derived::static_sub_func();
+ // ...
+ }
+};
+
+struct Derived : Base<Derived> {
+ void implementation() { }
+ static void static_sub_func() { }
+};
+
+int foo () {
+ Derived d;
+ d.//-2-
+ ;
+ // #2# ("implementation" "interface" "static_func" "static_sub_func")
+}
--- /dev/null
+// testsubclass.cpp --- unit test for analyzer and complex C++ inheritance
+
+// Copyright (C) 2007-2021 Free Software Foundation, Inc.
+
+// Author: Eric M. Ludlam <zappo@gnu.org>
+
+// This file is part of GNU Emacs.
+
+// GNU Emacs is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// GNU Emacs is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+//#include <iostream>
+#include "testsubclass.hh"
+
+void animal::moose::setFeet(int numfeet) //^1^
+{
+ if (numfeet > 4) {
+ std::cerr << "Why would a moose have more than 4 feet?" << std::endl;
+ return;
+ }
+
+ fFeet = numfeet;
+}
+
+int animal::moose::getFeet() //^2^
+{
+ return fFeet;
+}
+
+void animal::moose::doNothing() //^3^
+{
+ animal::moose foo();
+
+ fFeet = N// -15-
+ ; // #15# ( "NAME1" "NAME2" "NAME3" )
+}
+
+
+void deer::moose::setAntlers(bool have_antlers) //^4^
+{
+ fAntlers = have_antlers;
+}
+
+bool deer::moose::getAntlers() //^5^
+// %1% ( ( "testsubclass.cpp" "testsubclass.hh" ) ( "deer::moose::doSomething" "deer::moose::getAntlers" "moose" ) )
+{
+ return fAntlers;
+}
+
+bool i_dont_have_symrefs()
+// %2% ( ("testsubclass.cpp" ) ("i_dont_have_symrefs"))
+{
+}
+
+void deer::moose::doSomething() //^6^
+{
+ // All these functions should be identified by semantic analyzer.
+ getAntlers();
+ setAntlers(true);
+
+ getFeet();
+ setFeet(true);
+
+ doNothing();
+
+ fSomeField = true;
+
+ fIsValid = true;
+}
+
+void deer::alces::setLatin(bool l) {
+ fLatin = l;
+}
+
+bool deer::alces::getLatin() {
+ return fLatin;
+}
+
+void deer::alces::doLatinStuff(moose moosein) {
+ // All these functions should be identified by semantic analyzer.
+ getFeet();
+ setFeet(true);
+
+ getLatin();
+ setLatin(true);
+
+ doNothing();
+
+ deer::moose foo();
+
+
+}
+
+moose deer::alces::createMoose()
+{
+ moose MooseVariableName;
+ bool tmp;
+ int itmp;
+ bool fool;
+ int fast;
+
+ MooseVariableName = createMoose();
+
+ doLatinStuff(MooseVariableName);
+
+ tmp = this.f// -1-
+ // #1# ( "fAlcesBool" "fIsValid" "fLatin" )
+ ;
+
+ itmp = this.f// -2-
+ // #2# ( "fAlcesInt" "fGreek" "fIsProtectedInt" )
+ ;
+
+ tmp = f// -3-
+ // #3# ( "fAlcesBool" "fIsValid" "fLatin" "fool" )
+ ;
+
+ itmp = f// -4-
+ // #4# ( "fAlcesInt" "fGreek" "fIsProtectedInt" "fast" )
+ ;
+
+ MooseVariableName = m// -5-
+ // #5# ( "moose" )
+
+ return MooseVariableName;
+}
+
+/** Test Scope Changes
+ *
+ * This function is rigged to make sure the scope changes to account
+ * for different locations in local variable parsing.
+ */
+int someFunction(int mPickle)
+{
+ moose mMoose = deer::alces::createMoose();
+
+ if (mPickle == 1) {
+
+ int mOption1 = 2;
+
+ m// -5-
+ // #5# ( "mMoose" "mOption1" "mPickle" )
+ ;
+
+ } else {
+
+ int mOption2 = 2;
+
+ m// -6-
+ // #6# ( "mMoose" "mOption2" "mPickle" )
+ ;
+ }
+
+}
+
+// Thanks Ming-Wei Chang for this next example.
+
+namespace pub_priv {
+
+ class A{
+ private:
+ void private_a(){}
+ public:
+ void public_a();
+ };
+
+ void A::public_a() {
+ A other_a;
+
+ other_a.p// -7-
+ // #7# ( "private_a" "public_a" )
+ ;
+ }
+
+ int some_regular_function(){
+ A a;
+ a.p// -8-
+ // #8# ( "public_a" )
+ ;
+ return 0;
+ }
+
+}
+
+
+/** Test Scope w/in a function (non-method) with classes using
+ * different levels of inheritance.
+ */
+int otherFunction()
+{
+ sneaky::antelope Antelope(1);
+ sneaky::jackalope Jackalope(1);
+ sneaky::bugalope Bugalope(1);
+
+ Antelope.// -9-
+ // #9# ( "fAntyPublic" "fQuadPublic" "testAccess")
+ ;
+
+ Jackalope.// -10-
+ // #10# ( "fBunnyPublic" "testAccess")
+ ;
+
+ Jackalope// @1@ 6
+ ;
+ Jackalope;
+ Jackalope;
+ Jackalope;
+
+ Bugalope.// -11-
+ // #11# ( "fBugPublic" "testAccess")
+ ;
+ Bugalope// @2@ 3
+ ;
+}
+
+/** Test methods within each class for types of access to the baseclass.
+ */
+
+bool sneaky::antelope::testAccess() //^7^
+{
+ this.// -12-
+ // #12# ( "fAntyPrivate" "fAntyProtected" "fAntyPublic" "fQuadProtected" "fQuadPublic" "testAccess" )
+ ;
+}
+
+bool sneaky::jackalope::testAccess() //^8^
+{
+ this.// -13-
+ // #13# ( "fBunnyPrivate" "fBunnyProtected" "fBunnyPublic" "fQuadProtected" "fQuadPublic" "testAccess" )
+ ;
+}
+
+bool sneaky::bugalope::testAccess() //^9^
+{
+ this.// -14-
+ // #14# ( "fBugPrivate" "fBugProtected" "fBugPublic" "fQuadPublic" "testAccess" )
+ ;
+}
--- /dev/null
+// testsubclass.hh --- unit test for analyzer and complex C++ inheritance
+
+// Copyright (C) 2007-2021 Free Software Foundation, Inc.
+
+// Author: Eric M. Ludlam <zappo@gnu.org>
+
+// This file is part of GNU Emacs.
+
+// GNU Emacs is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// GNU Emacs is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+//#include <cmath>
+// #include <stdio.h>
+
+#ifndef TESTSUBCLASS_HH
+#define TESTSUBCLASS_HH
+
+namespace animal {
+
+ class moose {
+ public:
+ moose() : fFeet(0),
+ fIsValid(false)
+ { }
+
+ virtual void setFeet(int);
+ int getFeet();
+
+ void doNothing();
+
+ enum moose_enum {
+ NAME1, NAME2, NAME3 };
+
+
+ protected:
+
+ bool fIsValid;
+ int fIsProtectedInt;
+
+ private:
+ int fFeet; // Usually 2 or 4.
+ bool fIsPrivateBool;
+
+ }; // moose
+
+ int two_prototypes();
+ int two_prototypes();
+
+ class quadruped {
+ public:
+ quadruped(int a) : fQuadPrivate(a)
+ { }
+
+ int fQuadPublic;
+
+ protected:
+ int fQuadProtected;
+
+ private:
+ int fQuadPrivate;
+
+ };
+
+}
+
+
+namespace deer {
+
+ class moose : public animal::moose {
+ public:
+ moose() : fAntlers(false)
+ { }
+
+ void setAntlers(bool);
+ bool getAntlers();
+
+ void doSomething();
+
+ protected:
+
+ bool fSomeField;
+
+ private:
+ bool fAntlers;
+
+ };
+
+} // deer
+
+// A second namespace of the same name will test the
+// namespace merging needed to resolve deer::alces
+namespace deer {
+
+ class alces : public animal::moose {
+ public:
+ alces(int lat) : fLatin(lat)
+ { }
+
+ void setLatin(bool);
+ bool getLatin();
+
+ void doLatinStuff(moose moosein); // for completion testing
+
+ moose createMoose(); // for completion testing.
+
+ protected:
+ bool fAlcesBool;
+ int fAlcesInt;
+
+ private:
+ bool fLatin;
+ int fGreek;
+ };
+
+};
+
+// A third namespace with classes that does protected and private inheritance.
+namespace sneaky {
+
+ class antelope : public animal::quadruped {
+
+ public:
+ antelope(int a) : animal::quadruped(),
+ fAntyProtected(a)
+ {}
+
+ int fAntyPublic;
+
+ bool testAccess();
+
+ protected:
+ int fAntyProtected;
+
+ private :
+ int fAntyPrivate;
+
+ };
+
+ class jackalope : protected animal::quadruped {
+
+ public:
+ jackalope(int a) : animal::quadruped(),
+ fBunny(a)
+ {}
+
+ int fBunnyPublic;
+
+ bool testAccess();
+
+ protected:
+ bool fBunnyProtected;
+
+ private :
+ bool fBunnyPrivate;
+
+ };
+
+ // Nothing specified means private.
+ class bugalope : /* private*/ animal::quadruped {
+
+ public:
+ bugalope(int a) : animal::quadruped(),
+ fBug(a)
+ {}
+
+ int fBugPublic;
+
+ bool testAccess();
+ protected:
+ bool fBugProtected;
+
+ private :
+ bool fBugPrivate;
+
+ };
+
+
+};
+
+#endif
--- /dev/null
+// testtemplates.cpp --- semantic-ia-utest completion engine unit tests
+
+// Copyright (C) 2008-2021 Free Software Foundation, Inc.
+
+// Author: Eric M. Ludlam <zappo@gnu.org>
+
+// This file is part of GNU Emacs.
+
+// GNU Emacs is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// GNU Emacs is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+
+// TODO - this probably means can't be part of emacs, as I don't know who this guy is.
+// Written by 'Raf'
+
+template <class T, int U, class V>
+class read_ref {
+public:
+ const T* read_ref_member_one( T);
+ const V* read_ref_member_two();
+};
+
+namespace NS {
+ template <class T, int U, class V>
+ class ref {
+ public:
+ read_ref<T,10,V> operator->() {
+ m_// -1-
+ ;
+ // #1# ( "m_datas" )
+ }
+
+ private:
+ T m_datas[U];
+ };
+
+}
+
+class FooOne {
+public:
+ int fooOneMember();
+};
+
+class FooTwo {
+public:
+ int fooTwoMember();
+};
+
+class FooThree {
+public:
+ int fooThreeMember();
+
+ FooOne * operator->();
+};
+
+typedef ref<FooOne, 10,FooTwo> Test;
+
+using NS;
+
+void
+main(void) {
+ ref<FooOne, 10, FooTwo> v;
+
+ v->read_ref_member_one()-> // -2-
+ ;
+ // #2# ( "fooOneMember" )
+
+ v->read_ref_member_two()-> // -3-
+ ;
+ // #3# ( "fooTwoMember" )
+
+ v-> // -4-
+ ;
+ // #4# ( "read_ref_member_one" "read_ref_member_two" )
+
+ Test t;
+
+ t->read_ref_member_two()-> // -5-
+ ;
+ // #5# ( "fooTwoMember" )
+
+ ref<FooOne, 10, FooThree> v2;
+
+ v2->read_ref_member_two()-> // -6-
+ ;
+ // #6# ( "fooOneMember" )
+
+ /* Try all these things by also specifying the namespace in the name. */
+ NS::ref<FooOne, 10, FooTwo> v3;
+
+ v3->read_ref_member_one()-> // -7-
+ ;
+ // #7# ( "fooOneMember" )
+
+ v3->read_ref_member_two()-> // -8-
+ ;
+ // #8# ( "fooTwoMember" )
+
+ v3->read_ref_member_two// @1@ 5
+ ;
+
+}
+
+// More Namespace Magic using member constants.
+
+template<typename T>
+struct isFooLike {
+ static const bool value = false;
+};
+
+template <>
+struct isFooLike<int> {
+ static const bool value = true;
+};
+
+
+template <typename T, bool isFoo>
+class A {
+public:
+ A();
+ void foo() {};
+};
+
+
+template <typename T>
+class FooFour : public A<T, isPodLike<T>::value> {
+public:
+ bool bar() {}
+};
+
+
+int main2() {
+
+ FooFour<int> ff;
+
+ ff.// - 9- @ TODO - bring over patch from SF
+ ; // #9# ( "bar" "foo" );
+
+}
--- /dev/null
+// testtypedefs.cpp --- Sample with some fake bits out of std::string
+
+// Copyright (C) 2008-2021 Free Software Foundation, Inc.
+
+// Author: Eric M. Ludlam <zappo@gnu.org>
+
+// This file is part of GNU Emacs.
+
+// GNU Emacs is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// GNU Emacs is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+// Thanks Ming-Wei Chang for these examples.
+
+namespace std {
+ template <T>class basic_string {
+ public:
+ void resize(int);
+ };
+}
+
+typedef std::basic_string<char> mstring;
+
+using namespace std;
+typedef basic_string<char> bstring;
+
+int main(){
+ mstring a;
+ a.// -1-
+ ;
+ // #1# ( "resize" )
+ bstring b;
+ // It doesn't work here.
+ b.// -2-
+ ;
+ // #2# ( "resize" )
+ return 0;
+}
+
+// ------------------
+
+class Bar
+{
+public:
+ void someFunc() {}
+};
+
+typedef Bar new_Bar;
+
+template <class mytype>
+class TBar
+{
+public:
+ void otherFunc() {}
+};
+
+typedef TBar<char> new_TBar;
+
+int main()
+{
+ new_Bar nb;
+ new_TBar ntb;
+
+ nb.// -3-
+ ;
+ // #3# ("someFunc")
+ ntb.// -4-
+ ;
+ // #4# ("otherFunc")
+
+ return 0;
+}
+
+// ------------------
+// Example from Yupeng.
+
+typedef struct epd_info {
+ int a;
+} epd_info_t;
+
+static int epd_probe(struct platform_device *pdev)
+{
+ struct epd_info *db;
+ epd_info_t db1;
+
+ db.// -5-
+ ; // #5# ("a")
+ db1.// -6-
+ ;// #6# ("a")
+
+ return 1;
+}
+
+// ------------------
+// Example from Michel LAFON-PUYO
+
+typedef enum
+{
+ ENUM1,
+ ENUM2
+} e_toto;
+
+typedef struct
+{
+ int field_a;
+ int field_b;
+} t_toto;
+
+// Note: Error condition from anonymous types in a typedef
+// was that the first (ie - the enum) would be used in
+// place of the struct.
+int func(void)
+{
+ t_toto t;
+ t. // -7-
+ ; // #7# ( "field_a" "field_b" )
+ return 0;
+}
+
+
+// ------------------
+// Example from Dixon Ryan
+
+
+namespace NS2 {
+ class MyClass {
+
+ public:
+ void myFunction() { }
+ };
+}
+
+typedef class NS2::MyClass* MyClassHandle;
+
+int dixon ( void ) {
+ MyClassHandle mch = getMyClassHandle();
+ NS2::MyClass* mcptr = getMyClassHandle();
+
+ mcptr-> // -8-
+ ; // #8# ( "myFunction" )
+ mch-> // - 9- TODO bring over patch from SF
+ ; // #9# ( "myFunction" )
+ deleteMyClassHandle(mch);
+
+ return 0;
+}
--- /dev/null
+// testusing.cpp --- semantic-ia-utest completion engine unit tests
+
+// Copyright (C) 2008-2021 Free Software Foundation, Inc.
+
+// Author: Eric M. Ludlam <zappo@gnu.org>
+
+// This file is part of GNU Emacs.
+
+// GNU Emacs is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// GNU Emacs is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+
+#include <adstdio.h>
+
+#include <testusing.hh>
+
+namespace moose {
+
+ class MyClass;
+ class Point;
+
+ typedef MyClass snerk;
+}
+
+namespace moose {
+
+ class Point;
+ class MyClass;
+
+}
+
+namespace {
+
+ int global_variable = 0;
+
+};
+
+using moose::MyClass;
+
+void someFcn() {
+
+ MyClass f;
+
+ f.//-1-
+ ; //#1# ( "getVal" "setVal" )
+
+}
+
+// Code from Zhiqiu Kong
+
+namespace panda {
+
+ using namespace bread_name;
+
+ int func()
+ {
+ bread test;
+ test.//-2-
+ ;// #2# ( "geta" )
+ return 0;
+ }
+}
+
+namespace togglemoose {
+
+ MyOtherClass::testToggle1() { //^1^
+ // Impl for testToggle1
+ }
+}
+
+togglemoose::MyOtherClass::testToggle2() { //^3^
+ // Impl for testToggle2
+}
+
+using togglemoose;
+
+MyOtherClass::testToggle3() { //^3^
+ // Impl for testToggle3
+}
+
+// Local using statements and aliased types
+// Code from David Engster
+
+void func2()
+{
+ using namespace somestuff;
+ OneClass f;
+ f.//-3-
+ ; //#3# ( "aFunc" "anInt" )
+}
+
+void func3()
+{
+ using somestuff::OneClass;
+ OneClass f;
+ f.//-4-
+ ; //#4# ( "aFunc" "anInt" )
+}
+
+// Dereferencing alias types created through 'using' statements
+
+// Alias with fully qualified name
+void func4()
+{
+ otherstuff::OneClass f;
+ f. //-5-
+ ; //#5# ( "aFunc" "anInt" )
+}
+
+// Alias through namespace directive
+void func5()
+{
+ using namespace otherstuff;
+ OneClass f;
+ f. //-6-
+ ; //#6# ( "aFunc" "anInt" )
+}
+
+// Check name hiding
+void func6()
+{
+ using namespace morestuff;
+ OneClass f; // Alias for somestuff::OneClass
+ f. //-7-
+ ; //#7# ( "aFunc" "anInt" )
+ aStruct g; // This however is morestuff::aStruct !
+ g. //-8-
+ ; //#8# ( "anotherBar" "anotherFoo" )
+}
+
+// Alias of an alias
+// Currently doesn't work interactively for some reason.
+void func6()
+{
+ using namespace evenmorestuff;
+ OneClass f;
+ f. //-7-
+ ; //#7# ( "aFunc" "anInt" )
+}
+
+// Alias for struct in nested namespace, fully qualified
+void func7()
+{
+ outer::StructNested f;
+ f.//-8-
+ ; //#8# ( "one" "two" )
+}
+
+// Alias for nested namespace
+void func8()
+{
+ using namespace outerinner;
+ StructNested f;
+ AnotherStruct g;
+ f.//-9-
+ ; //#9# ( "one" "two" )
+ g.//-10-
+ ; //#10# ( "four" "three" )
+}
+
+// Check conventional namespace aliases
+// - fully qualified -
+void func9()
+{
+ alias_for_somestuff::OneClass c;
+ c.//-11-
+ ; //#11# ( "aFunc" "anInt" )
+ alias_for_outerinner::AnotherStruct s;
+ s. //-12-
+ ; //#12# ( "four" "three" )
+}
+
+// - unqualified -
+void func10()
+{
+ using namespace alias_for_somestuff;
+ OneClass c2;
+ c2.//-13-
+ ; //#13# ( "aFunc" "anInt" )
+ using namespace alias_for_outerinner;
+ AnotherStruct s2;
+ s2.//-14-
+ ; //#14# ( "four" "three" )
+}
+
+// Completion on namespace aliases
+void func11()
+{
+ alias_for_somestuff:://-15-
+ ; //#15# ( "OneClass" "aStruct")
+ alias_for_outerinner:://-16-
+ ; //#16# ( "AnotherStruct" "StructNested" )
+}
+
+// make sure unfound using statements don't crash stuff.
+using something::cantbe::Found;
+
+void unfoundfunc()
+{
+ NotFound notfound; // Variable can't be found.
+
+ notfound.//-17-
+ ; //#17# ( ) Nothing here since this is an undefined class
+
+}
+
+// Using statements can depend on previous ones...
+
+void acc_using()
+{
+ using namespace outer;
+ // This is effectively like 'using namespace outer::inner'
+ using namespace inner;
+
+ StructNested sn;
+ sn.//-18-
+ ; //#18# ( "one" "two" )
+}
+
+// Check the same outside of function scope
+
+using namespace outer;
+using namespace inner;
+
+void acc_using2()
+{
+ StructNested sn;
+ sn.//-19-
+ ; //#19# ( "one" "two" )
+}
+
+// Check if scope gets correctly generated, i.e., without us providing any
+// hints in the form of an existing type
+
+void check_scope()
+{
+ using namespace first;
+ AAA//-20-
+ ; //#20# ( "AAA1" "AAA2" )
+}
+
+void check_scope2()
+{
+ using namespace third;
+ AAA//-21-
+ ; //#21# ( "AAA1" "AAA2" "AAA3" )
+}
+
+// Make sure this also works not only in functions
+
+namespace check_scope3 {
+ using namespace first;
+ AAA//-22-
+ ; //#22# ( "AAA1" "AAA2" )
+}
--- /dev/null
+// testusing.hh --- semantic-ia-utest completion engine unit tests
+
+// Copyright (C) 2008-2021 Free Software Foundation, Inc.
+
+// Author: Eric M. Ludlam <zappo@gnu.org>
+
+// This file is part of GNU Emacs.
+
+// GNU Emacs is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// GNU Emacs is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+namespace moose {
+
+ class Point;
+
+ class MyClass;
+
+}
+
+
+namespace moose {
+
+ class Point;
+
+ class MyClass {
+ public:
+ MyClass() : fVal(0) {
+ }
+
+ ~MyClass() {};
+
+ /**
+ * fVal Accessors
+ * @{
+ */
+ int getVal() const {
+ return fVal;
+ }
+ void setVal(int Val) const {
+ fVal = Val;
+ }
+ /**
+ * @}
+ */
+
+ private:
+ int fVal;
+ };
+
+}
+
+namespace togglemoose {
+
+ class MyOtherClass {
+ public:
+ int testToggle1();
+ int testToggle2();
+ int testToggle3();
+ };
+}
+
+namespace deer {
+
+ class Pickle;
+
+};
+
+// Code from Zhiqiu Kong
+
+#ifndef BREAD_H
+#define BREAD_H
+
+namespace bread_name {
+ class bread
+ {
+ public:
+ void geta();
+ private:
+ int m_a;
+ int m_b;
+ };
+}
+
+#endif
+
+// Code from David Engster
+// Creating alias types through 'using' trickery
+
+namespace somestuff {
+ class OneClass {
+ public:
+ void aFunc();
+ int anInt;
+ };
+ struct aStruct {
+ int foo;
+ int bar;
+ };
+}
+
+namespace otherstuff {
+ // make otherstuff::OneClass an alias for somestuff::OneClass
+ using somestuff::OneClass;
+}
+
+namespace morestuff {
+ // make morestuff an alias namespace for somestuff
+ using namespace somestuff;
+ // but hide aStruct with own type
+ struct aStruct {
+ int anotherFoo;
+ int anotherBar;
+ };
+}
+
+// We can also create an alias for an alias
+namespace evenmorestuff {
+ using otherstuff::OneClass;
+}
+
+// Now with nested namespaces
+namespace outer {
+ namespace inner {
+ struct StructNested {
+ int one;
+ int two;
+ };
+ struct AnotherStruct {
+ int three;
+ int four;
+ };
+ }
+}
+
+// Namespace which pulls in one of its own nested namespaces
+namespace first {
+ class AAA1;
+ namespace second {
+ class AAA2;
+ }
+ // Elevate nested namespace into first one
+ using namespace second;
+}
+
+namespace third {
+ using namespace first;
+ class AAA3;
+}
+
+
+// Elevate the first struct into 'outer'
+// so that we can access it via 'outer::StructNested'
+namespace outer {
+ using outer::inner::StructNested;
+}
+
+// Create an alias for a nested namespace
+namespace outerinner {
+ // equivalent to 'namespace outerinner = outer::inner;'
+ using namespace outer::inner;
+}
+
+// Create namespace alias
+namespace alias_for_somestuff = somestuff;
+// Same for nested namespace
+namespace alias_for_outerinner = outer::inner;
--- /dev/null
+/* testvarnames.cpp --- semantic-ia-utest completion engine unit tests
+
+ Copyright (C) 2008-2021 Free Software Foundation, Inc.
+
+ Author: Eric M. Ludlam <zappo@gnu.org>
+
+ This file is part of GNU Emacs.
+
+ GNU Emacs is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ GNU Emacs is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+*/
+
+struct independent {
+ int indep_1;
+ int indep_2;
+};
+
+struct independent var_indep_struct;
+
+struct {
+ int unnamed_1;
+ int unnamed_2;
+} var_unnamed_struct;
+
+struct {
+ int unnamed_3;
+ int unnamed_4;
+} var_un_2, var_un_3;
+
+struct inlinestruct {
+ int named_1;
+ int named_2;
+} var_named_struct;
+
+struct inline2struct {
+ int named_3;
+ int named_4;
+} var_n_2, var_n_3;
+
+/* Structures with names that then declare variables
+ * should also be completable.
+ *
+ * Getting this to work is the bugfix in semantic-c.el CVS v 1.122
+ */
+struct inlinestruct in_var1;
+struct inline2struct in_var2;
+
+/*
+ * Structures (or any types) could have the same name as a variable.
+ * Make sure we complete vars over types.
+ *
+ * See cedet-devel mailing list Dec 23, 2013 for details.
+ */
+struct varorstruct {};
+int varorstruct;
+
+int assigntovarorstruct;
+
+int test_1(int var_arg1) {
+
+ var_// -1-
+ ; // #1# ("var_arg1" "var_indep_struct" "var_n_2" "var_n_3" "var_named_struct" "var_un_2" "var_un_3" "var_unnamed_struct")
+
+ var_indep_struct.// -2-
+ ; // #2# ( "indep_1" "indep_2" )
+
+ var_unnamed_struct.// -3-
+ ; // #3# ( "unnamed_1" "unnamed_2" )
+
+ var_named_struct.// -4-
+ ; // #4# ( "named_1" "named_2" )
+
+ var_un_2.// -5-
+ ; // #5# ( "unnamed_3" "unnamed_4" )
+ var_un_3.// -6-
+ ; // #6# ( "unnamed_3" "unnamed_4" )
+
+ var_n_2.// -7-
+ ; // #7# ( "named_3" "named_4" )
+ var_n_3.// -8-
+ ; // #8# ( "named_3" "named_4" )
+
+ in_// -9-
+ ; // #9# ( "in_var1" "in_var2" )
+
+ in_var1.// -10-
+ ; // #10# ( "named_1" "named_2")
+ in_var2.// -11-
+ ; // #11# ( "named_3" "named_4")
+
+ varorstruct = assign// -12-
+ ; // #12# ( "assigntovarorstruct" )
+}
--- /dev/null
+// testvarnames.java --- Semantic unit test for Java
+
+// Copyright (C) 2009-2021 Free Software Foundation, Inc.
+
+// Author: Eric M. Ludlam <zappo@gnu.org>
+
+// This file is part of GNU Emacs.
+
+// GNU Emacs is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// GNU Emacs is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+package tests;
+
+/**
+ *
+ *
+ * Created: 02/17/14
+ *
+ * @author Eric M. Ludlam
+ * @version
+ * @since
+ */
+public class testvarnames {
+
+ public class varorclass {
+ public static long misclongvalue;
+ };
+
+ public static varorclass varoftypevarorclass = NULL;
+
+ public static long varorclass = 1;
+
+ public static long assignintovar = 1;
+
+ public static varorclass classassign = NULL;
+
+ static public void main(String [] args) {
+
+ varorclass = assign// -1-
+ // #1# ( "assignintovar" )
+ ;
+
+ varoftypevarorclass = clas// -2-
+ // #2# ( "classassign" )
+
+ varoftypevarorclass.misc//-3-
+ // #3# ( "misclongvalue" )
+ }
+
+} // testvarnames
--- /dev/null
+;; testwisent.wy --- unit test support file for semantic-utest-ia
+
+;; Copyright (C) 2008-2021 Free Software Foundation, Inc.
+
+;; Author: Eric M. Ludlam <zappo@gnu.org>
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; Parser for nothing in particular mode
+
+%languagemode nothing-mode
+%parsetable wisent-nothing-parser-tables
+%keywordtable wisent-nothing-keywords
+%tokentable wisent-nothing-tokens
+%languagemode nothing-mode
+%setupfunction wisent-nothing-default-setup
+
+%start goal
+
+;;; Punctuation
+%type <punctuation> ;;syntax "\\(\\s.\\|\\s$\\|\\s'\\)+" matchdatatype string
+
+%token <punctuation> DOT "."
+%token <punctuation> COMA ","
+%token <punctuation> COLONCOLON "::"
+%token <punctuation> COLON ":"
+%token <punctuation> SEMICOLON ";"
+
+;;; KEYWORDS
+%type <keyword>
+
+%keyword COLONOSCOPY "colonoscopy"
+%keyword SEMISOMETHING "semisomething"
+
+%%
+
+goal
+ ;; Misc
+ : COLON ;; -1-
+ ;; #1# ( "COLONCOLON" "COLON" "COLONOSCOPY" )
+ | SEMI ;; -2-
+ ;; #2# ( "SEMI_useless_rule" "SEMICOLON" "SEMISOMETHING" )
+ | thing ;; -3-
+ ;; #3# ( "thing_term_1" "thing_term_2" )
+ ;
+
+SEMI_useless_rule
+ :
+ ;
+
+thing_term_1
+ :
+ ;
+
+thing_term_2
+ :
+ ;
+
+%%
+(define-lex wisent-nothing-lexer
+ "Lexical analyzer to handle nothing in particular buffers."
+ ;; semantic-lex-newline
+ semantic-lex-ignore-whitespace
+ semantic-lex-ignore-newline
+ semantic-lex-ignore-comments
+
+ semantic-lex-default-action
+ )
+
+;; testwisent.wy ends here
\ No newline at end of file
;; (Replace // with contents of comment-start for the language being tested.)
;;; Code:
+(require 'ert)
+(require 'ert-x)
(require 'semantic)
(require 'semantic/analyze)
(require 'semantic/analyze/refs)
(require 'semantic/symref)
(require 'semantic/symref/filter)
-(defvar cedet-utest-directory
- (let* ((C (file-name-directory (locate-library "cedet")))
- (D (expand-file-name "../../test/manual/cedet/" C)))
- D)
- "Location of test files for this test suite.")
-
-(defvar semantic-utest-test-directory (expand-file-name "tests" cedet-utest-directory)
- "Location of test files.")
-
(ert-deftest semantic-utest-ia-doublens.cpp ()
- (let ((tst (expand-file-name "testdoublens.cpp" semantic-utest-test-directory)))
- (should (file-exists-p tst))
+ (let ((tst (ert-resource-file "testdoublens.cpp")))
(should-not (semantic-ia-utest tst))))
(ert-deftest semantic-utest-ia-subclass.cpp ()
- (let ((tst (expand-file-name "testsubclass.cpp" semantic-utest-test-directory)))
- (should (file-exists-p tst))
+ (let ((tst (ert-resource-file "testsubclass.cpp")))
(should-not (semantic-ia-utest tst))))
(ert-deftest semantic-utest-ia-typedefs.cpp ()
- (let ((tst (expand-file-name "testtypedefs.cpp" semantic-utest-test-directory)))
- (should (file-exists-p tst))
+ (let ((tst (ert-resource-file "testtypedefs.cpp")))
(should-not (semantic-ia-utest tst))))
(ert-deftest semantic-utest-ia-struct.cpp ()
- (let ((tst (expand-file-name "teststruct.cpp" semantic-utest-test-directory)))
- (should (file-exists-p tst))
+ (let ((tst (ert-resource-file "teststruct.cpp")))
(should-not (semantic-ia-utest tst))))
;;(ert-deftest semantic-utest-ia-union.cpp ()
-;; (let ((tst (expand-file-name "testunion.cpp" semantic-utest-test-directory)))
-;; (should (file-exists-p tst))
+;; (let ((tst (ert-resource-file "testunion.cpp")))
;; (should-not (semantic-ia-utest tst))))
(ert-deftest semantic-utest-ia-templates.cpp ()
- (let ((tst (expand-file-name "testtemplates.cpp" semantic-utest-test-directory)))
- (should (file-exists-p tst))
+ (let ((tst (ert-resource-file "testtemplates.cpp")))
(should-not (semantic-ia-utest tst))))
;;(ert-deftest semantic-utest-ia-friends.cpp ()
-;; (let ((tst (expand-file-name "testfriends.cpp" semantic-utest-test-directory)))
-;; (should (file-exists-p tst))
+;; (let ((tst (ert-resource-file "testfriends.cpp")))
;; (should-not (semantic-ia-utest tst))))
(ert-deftest semantic-utest-ia-using.cpp ()
- (let ((tst (expand-file-name "testusing.cpp" semantic-utest-test-directory)))
- (should (file-exists-p tst))
+ (let ((tst (ert-resource-file "testusing.cpp")))
(should-not (semantic-ia-utest tst))))
(ert-deftest semantic-utest-ia-nsp.cpp ()
(skip-unless (executable-find "g++"))
- (let ((tst (expand-file-name "testnsp.cpp" semantic-utest-test-directory)))
- (should (file-exists-p tst))
+ (let ((tst (ert-resource-file "testnsp.cpp")))
(should-not (semantic-ia-utest tst))))
(ert-deftest semantic-utest-ia-localvars.cpp ()
- (let ((tst (expand-file-name "testlocalvars.cpp" semantic-utest-test-directory)))
- (should (file-exists-p tst))
+ (let ((tst (ert-resource-file "testlocalvars.cpp")))
(should-not (semantic-ia-utest tst))))
(ert-deftest semantic-utest-ia-namespace.cpp ()
(skip-unless (executable-find "g++"))
- (let ((tst (expand-file-name "testnsp.cpp" semantic-utest-test-directory)))
- (should (file-exists-p tst))
+ (let ((tst (ert-resource-file "testnsp.cpp")))
(should-not (semantic-ia-utest tst))))
(ert-deftest semantic-utest-ia-sppcomplete.c ()
- (let ((tst (expand-file-name "testsppcomplete.c" semantic-utest-test-directory)))
- (should (file-exists-p tst))
+ (let ((tst (ert-resource-file "testsppcomplete.c")))
(should-not (semantic-ia-utest tst))))
(ert-deftest semantic-utest-ia-varnames.c ()
- (let ((tst (expand-file-name "testvarnames.c" semantic-utest-test-directory)))
- (should (file-exists-p tst))
+ (let ((tst (ert-resource-file "testvarnames.c")))
(should-not (semantic-ia-utest tst))))
(ert-deftest semantic-utest-ia-javacomp.java ()
- (let ((tst (expand-file-name "testjavacomp.java" semantic-utest-test-directory)))
- (should (file-exists-p tst))
+ (let ((tst (ert-resource-file "testjavacomp.java")))
(should-not (semantic-ia-utest tst))))
(ert-deftest semantic-utest-ia-varnames.java ()
- (let ((tst (expand-file-name "testvarnames.java" semantic-utest-test-directory)))
- (should (file-exists-p tst))
+ (let ((tst (ert-resource-file "testvarnames.java")))
(should-not (semantic-ia-utest tst))))
;;(ert-deftest semantic-utest-ia-f90.f90 ()
-;; (let ((tst (expand-file-name "testf90.f90" semantic-utest-test-directory)))
-;; (should (file-exists-p tst))
+;; (let ((tst (ert-resource-file "testf90.f90")))
;; (should-not (semantic-ia-utest tst))))
(ert-deftest semantic-utest-ia-wisent.wy ()
- (let ((tst (expand-file-name "testwisent.wy" semantic-utest-test-directory)))
- (should (file-exists-p tst))
+ (let ((tst (ert-resource-file "testwisent.wy")))
(should-not (semantic-ia-utest tst))))
(ert-deftest semantic-utest-ia-texi ()
- (let ((tst (expand-file-name "test.texi" semantic-utest-test-directory)))
- (should (file-exists-p tst))
+ (let ((tst (ert-resource-file "test.texi")))
(should-not (semantic-ia-utest tst))))
(ert-deftest semantic-utest-ia-make ()
- (let ((tst (expand-file-name "test.mk" semantic-utest-test-directory)))
- (should (file-exists-p tst))
+ (let ((tst (ert-resource-file "test.mk")))
(should-not (semantic-ia-utest tst))))
(ert-deftest semantic-utest-ia-srecoder ()
- (let ((tst (expand-file-name "test.srt" semantic-utest-test-directory)))
- (should (file-exists-p tst))
+ (let ((tst (ert-resource-file "test.srt")))
(should-not (semantic-ia-utest tst))))
;;; Core testing utility
+++ /dev/null
-# A Test Makefile. -*-makefile-*-
-
-# This test is for a file in this test directory. Just a random one.
-FILES=testdoub # -1-
-# #1# ("testdoublens.cpp" "testdoublens.hpp" )
-
-all: optional
-
-# This one completes on a variable name.
-optional: $FIL # -2-
- # #2# ("FILES")
- compile $@
-
-notoptional: opt # -3-
- # #3# ("optional")
- echo "Done."
-
-#end
+++ /dev/null
-;; test.srt --- unit test support file for semantic-utest-ia
-
-;; Copyright (C) 2008-2021 Free Software Foundation, Inc.
-
-;; Author: Eric M. Ludlam <zappo@gnu.org>
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-;;
-
-set mode "c++-mode"
-set escape_start "{{"
-set escape_end "}}"
-
-context file
-
-template class :blank
-"A test template for emacs lisp"
-----
-----
-
-template classic :blank
-"A test template for emacs lisp"
-----
-----
-
-template variable :blank
-"A test template for emacs lisp"
-----
-----
-
-template function :blank
-"A test template for emacs lisp"
-----
-----
-
-template testarea :blank
-"A test template for emacs lisp"
-----
-{{<A:cla}} -1-
- }} #1# ( "class" "classic" )
- {{^}}
-
-{{/A}}
-----
-
-;; This is a bad hack - In order for the text to parse, but also get a completion
-;; moniker into the right spot, we need to pretend a comment is the same as the
-;; escape_end.
-;; Local variables:
-;; comment-start-skip: "}}"
-;; End:
+++ /dev/null
-\input texinfo
-@setfilename test.info
-@set TITLE TEST
-@set AUTHOR Eric Ludlam
-@settitle @value{TITLE}
-
-@ifinfo
-@format
-START-INFO-DIR-ENTRY
-* test: (test). TEST
-END-INFO-DIR-ENTRY
-@end format
-@end ifinfo
-
-@titlepage
-@sp 10
-@center @titlefont{test}
-@vskip 0pt plus 1 fill
-Copyright @copyright{} 2015 Eric Ludlam
-@end titlepage
-
-@node Top
-@top @value{TITLE}
-
-This is a simple manual filled with stuff that should test completion in texinfo mode.
-
-@m@c -1-
-@c #1# ( "@majorheading" "@macro" "@menu" "@multitable" )
-
-@menu
-* Index::
-@end menu
-
-
-@node Index
-@chapter Index
-
-@contents
-
-@bye
+++ /dev/null
-// testdoublens.cpp --- semantic-ia-utest completion engine unit tests
-
-// Copyright (C) 2008-2021 Free Software Foundation, Inc.
-
-// Author: Eric M. Ludlam <zappo@gnu.org>
-
-// This file is part of GNU Emacs.
-
-// GNU Emacs is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// GNU Emacs is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-
-#include "testdoublens.hpp"
-
-namespace Name1 {
- namespace Name2 {
-
- Foo::Foo()
- {
- p// -1-
- // #1# ( "pMumble" "publishStuff" )
- ;
- }
-
- int Foo::get() // ^1^
- {
- p// -2-
- // #2# ( "pMumble" "publishStuff" )
- ;
- return 0;
- }
-
- void Foo::publishStuff(int a, int b) // ^2^
- {
- int foo = a;
- int bar = b;
- }
-
- // Test polymorphism on arg types. Note that order is
- // mixed to maximize failure cases
- void Foo::publishStuff(char a, char b) // ^4^
- {
- int foo = a;
- int bar = b;
- }
-
- void Foo::sendStuff(int a, int b) // ^3^
- {
- int foo = a;
- int bar = b;
-
- Foo::publishStuff(1,2)
-
- }
-
- } // namespace Name2
-} // namespace Name1
-
-// Test multiple levels of metatype expansion
-int test_fcn () {
- stage3_Foo MyFoo;
-
- MyFoo.// -3-
- // #3# ( "Mumble" "get" )
- ;
-
- Name1::Name2::F//-4-
- // #4# ( "Foo" )
- ;
-
- // @TODO - get this working...
- Name1::stage2_Foo::M//-5-
- /// #5# ( "Mumble" )
- ;
-}
-
-stage3_Foo foo_fcn() {
- // Can we go "up" to foo with senator-go-to-up-reference?
-}
-
-
-// Second test from Ravikiran Rajagopal
-
-namespace A {
- class foo {
- public:
- void aa();
- void bb();
- };
-}
-namespace A {
- class bar {
- public:
- void xx();
- public:
- foo myFoo;
- };
-
- void bar::xx()
- {
- myFoo.// -6- <--- cursor is here after the dot
- // #6# ( "aa" "bb" )
- ;
- }
-}
-
-// Double namespace example from Hannu Koivisto
-//
-// This is tricky because the parent class "Foo" is found within the
-// scope of B, so the scope calculation needs to put that together
-// before searching for parents in scope.
-namespace a {
- namespace b {
-
- class Bar : public Foo
- {
- int baz();
- };
-
- int Bar::baz()
- {
- return dum// -7-
- // #7# ( "dumdum" )
- ;
- }
-
- } // namespace b
-} // namespace a
-
-// Three namespace example from Hannu Koivisto
-//
-// This one is special in that the name e::Foo, where "e" is in
-// the scope, and not referenced from the global namespace. This
-// wasn't previously handled, so the fullscope needed to be added
-// to the list of things searched when in split-name decent search mode
-// for scopes.
-
-namespace d {
- namespace e {
-
- class Foo
- {
- public:
- int write();
- };
-
- } // namespace d
-} // namespace e
-
-
-namespace d {
- namespace f {
-
- class Bar
- {
- public:
- int baz();
-
- private:
- e::Foo &foo;
- };
-
- int Bar::baz()
- {
- return foo.w// -8-
- // #8# ( "write" )
- ;
- }
-
- } // namespace f
-} // namespace d
-
-// Fully qualified const struct function arguments
-class ContainsStruct
-{
- struct TheStruct
- {
- int memberOne;
- int memberTwo;
- };
-};
-
-void someFunc(const struct ContainsStruct::TheStruct *foo)
-{
- foo->// -9-
- // #9# ("memberOne" "memberTwo")
-}
-
-// Class with structure tag
-class ContainsNamedStruct
-{
- struct _fooStruct
- {
- int memberOne;
- int memberTwo;
- } member;
-};
-
-void someOtherFunc(void)
-{
- ContainsNamedStruct *someClass;
- // This has to find ContainsNamedStruct::_fooStruct
- someClass->member.// -10-
- // #10# ("memberOne" "memberTwo")
-}
+++ /dev/null
-// testdoublens.hpp --- Header file used in one of the Semantic tests
-
-// Copyright (C) 2008-2021 Free Software Foundation, Inc.
-
-// Author: Eric M. Ludlam <zappo@gnu.org>
-
-// This file is part of GNU Emacs.
-
-// GNU Emacs is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// GNU Emacs is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-
-namespace Name1 {
- namespace Name2 {
-
- class Foo
- {
- typedef unsigned int Mumble;
- public:
- Foo();
- ~Foo();
- int get();
-
- private:
- void publishStuff(char /* a */, char /* b */);
-
- void publishStuff(int q, int r); // Purposely different names.
-
- void sendStuff(int a, int b);
-
- Mumble* pMumble;
- };
-
- typedef Foo stage1_Foo;
-
- } // namespace Name2
-
- typedef Name2::stage1_Foo stage2_Foo;
-
- typedef Name2::Foo decl_stage1_Foo;
-
-} // namespace Name1
-
-typedef Name1::stage2_Foo stage3_Foo;
-
-
-// Double namespace from Hannu Koivisto
-namespace a {
- namespace b {
-
- class Foo
- {
- struct Dum {
- int diDum;
- };
-
- protected:
- mutable a::b::Foo::Dum dumdum;
- };
-
- } // namespace b
-} // namespace a
+++ /dev/null
-// Test parsing of friends and how they are used in completion.
-/*
- >> Thanks Damien Profeta for the nice example.
- >
- > I paste a small example.
- > It would be great if friend can be well parsed and even greater if
- > class B can access to all the members of A.
-*/
-
-class Af // %2% ( ( "testfriends.cpp" ) ( "Af" "B::testB" ) )
-{
-public:
- int pubVar;
-private:
- int privateVar;
-
- friend class B;
-
-};
-
-class B
-{
-public:
- int testB();
- int testAB();
-
-};
-
-
-int B::testB() {
- Af classA;
- classA.//-1-
- ; //#1# ( "privateVar" "pubVar" )
-}
-
-int B::testAB() { // %1% ( ( "testfriends.cpp" ) ( "B" "B::testAB" ) )
-}
-
+++ /dev/null
-// testjavacomp.java --- Semantic unit test for Java
-
-// Copyright (C) 2009-2021 Free Software Foundation, Inc.
-
-// Author: Eric M. Ludlam <zappo@gnu.org>
-
-// This file is part of GNU Emacs.
-
-// GNU Emacs is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// GNU Emacs is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-
-package tests.testjavacomp;
-
-class secondClass {
- private void scFuncOne() { }
- public void scFuncOne() { }
-
- int package_protected_field;
- public int public_protected_field;
- private int private_protected_field;
-}
-
-
-public class testjavacomp {
-
- private int funcOne() { }
- private int funcTwo() { }
- private char funcThree() { }
-
- class nestedClass {
- private void ncFuncOne() { }
- public void ncFuncOne() { }
- }
-
- public void publicFunc() {
-
- int i;
-
- i = fu// -1-
- // #1# ( "funcOne" "funcTwo" )
- ;
-
- fu// -2-
- // #2# ( "funcOne" "funcThree" "funcTwo" )
- ;
-
- secondClass SC;
-
- SC.s//-3-
- // #3# ( "scFuncOne" )
- ;
-
- // @TODO - to make this test complete, we need an import
- // with a package protected field that is excluded
- // from the completion list.
- SC.p//-4-
- // #4# ( "package_protected_field" "public_protected_field" )
-
- nestedClass NC;
-
- // @todo - need to fix this? I don't know if this is legal java.
- NC.// - 5-
- // #5# ( "ncFuncOne" )
- ;
- }
-
-} // testjavacomp
+++ /dev/null
-// testlocalvars.java --- Semantic unit test for Java
-
-// Copyright (C) 2009-2021 Free Software Foundation, Inc.
-
-// Author: Eric M. Ludlam <zappo@gnu.org>
-
-// This file is part of GNU Emacs.
-
-// GNU Emacs is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// GNU Emacs is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-
-
-class foo {
- foo *member;
- char anArray[10];
-};
-
-void func()
-{
- foo local1;
- foo* local2 = localvar.member;
- foo* local3 = new foo();
- foo local4[10];
- char local5[5] = {'1','2','3','4','5'};
- char *local6 = "12345";
- char local7 = local.anArray[0];
- char local8 = true ? 10 : 11 ;
-
- // Check that all of the above was parsed
- local//-1-
- ; //#1# ("local1" "local2" "local3" "local4" "local5" "local6" "local7" "local8" )
-
- local1.//-2-
- ; //#2# ("anArray" "member")
-
- local2->//-3-
- ; //#3# ("anArray" "member")
-
- local3->//-4-
- ; //#4# ("anArray" "member")
-
- local4[0].//-5-
- ; //#5# ("anArray" "member")
-}
+++ /dev/null
-/* testnsp.cpp --- semantic-ia-utest completion engine unit tests
-
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
-
- Author: Eric M. Ludlam <zappo@gnu.org>
-
- This file is part of GNU Emacs.
-
- GNU Emacs is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- GNU Emacs is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-*/
-
-namespace nsp {
-
- class rootclass {
- public:
- int fromroot() {};
- };
-
-}
-
-namespace nsp {
- class childclass : public rootclass {
- public:
- int fromchild() {};
- };
-}
-
-void myfcn_not_in_ns (void) {
- nsp::childclass test;
-
- test.// -1-
- ; // #1# ( "fromchild" "fromroot" )
-}
-
-// Test a class declared in a class, where the contents
-// are in a qualified name.
-//
-// Thanks Michael Reiher for the concise example.
-
-class AAA
-{
-public:
- AAA();
-
- void aaa();
-
-private:
- class Private;
- Private * const d;
-};
-
-class AAA::Private
-{
- Private() : bbb(0) {
- }
-
- BBB* bbb;
-};
-
-void AAA::aaa()
-{
- d->// -2-
- ; // #2# ( "bbb" )
-}
-
-// #include files inside a namespace
-// David Engster <deng@randomsample.de>
-// See revisions 8034-8037 which implement this.
-
-namespace another {
- #include "testdoublens.hpp"
-}
-
-void foo(void) {
-
- another::// -3-
- ; // #3# ( "Name1" "a" "stage3_Foo" )
-
- another::Name1::Name2::Foo a;
-
- a.// -4-
- ; // #4# ( "Mumble" "get" )
-}
-
-// What happens if a type your looking for is scoped within a type,
-// but you are one level into the completion so the originating scope
-// excludes the type of the variable you are completing through?
-// Thanks Martin Stein for this nice example.
-
-namespace ms_structs
-{
- struct ms_aaa
- {
- int xx;
- };
-
- struct ms_bbb
- {
- struct ms_aaa yy;
- };
-};
-
-int fun()
-{
- using namespace ms_structs;
- struct ms_bbb mszz;
- int uu = mszz.// -5-
- ; // #5# ( "yy" )
- int kk = mszz.yy.// - 6- @TODO - bring in patch from SF
- ; // #6# ( "xx" )
-}
+++ /dev/null
-/* testesppcomplete.cpp --- semantic-ia-utest completion engine unit tests
-
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
-
- Author: Eric M. Ludlam <zappo@gnu.org>
-
- This file is part of GNU Emacs.
-
- GNU Emacs is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- GNU Emacs is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-*/
-
-/* Example provided by Hannes Janetzek */
-
-struct Test { int test; };
-
-#define BLA(_type) \
- _type *bla = (_type*) malloc(sizeof(_type));
-
-#define BLUB(_type) \
- (_type*)malloc(sizeof(_type));
-
-#define FOO(_type) \
- _type *foo = BLUB(_type);
-
-#define BAR(_type) \
- _type *bar = (*_type)BLUB(_type);
-
-int main(int argc, char *argv[]) {
- BLA(Test);
- bla->// -1-
- ; // #1# ( "test" )
-
- FOO(Test);
- foo->// -2-
- ; // #2# ( "test" )
-
- BAR(Test);
- bar->// -3-
- ; // #3# ( "test" )
-}
-
-/* Test symref and macros together. */
-
-// This function exists only so we can have a comment in a tag with this name.
-void function_with_macro_name ()
-// %1% ( ( "testsppcomplete.c" ) ( "function_with_macro_name" "function_with_macro_name" "use_macro") )
-// Note: fwmn is in twice, once for function, and once for the constant macro below.
-{
-}
-
-#define function_with_macro_name 1
-
-int use_macro () {
- int a = function_with_macro_name;
-}
+++ /dev/null
-// teststruct.cpp --- semantic-ia-utest completion engine unit tests
-
-// Copyright (C) 2008-2021 Free Software Foundation, Inc.
-
-// Author: Eric M. Ludlam <zappo@gnu.org>
-
-// This file is part of GNU Emacs.
-
-// GNU Emacs is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// GNU Emacs is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-
-
-// Note: initially provided by by Alex Ott.
-
-template <typename DerivedT>
-struct grammar {
-public:
- typedef grammar<DerivedT> self_t;
- typedef DerivedT const& embed_t;
- grammar() {}
- ~grammar() { }
- void use_parser() const { }
- void test1() { }
-};
-
-struct PDFbool_parser : public grammar<PDFbool_parser> {
- PDFbool_parser() {}
- template <typename scannerT> struct definition {
- typedef typename scannerT::iterator_t iterator_t;
- int top;
- definition(const PDFbool_parser& /*self*/) {
- return ;
- }
- const int start() const {
- return top;
- }
- };
-};
-
-int main(void) {
- PDFbool_parser PDFbool_p = PDFbool_parser();
- PDFbool_p.//-1-
- ;
- // #1# ("definition" "embed_t" "self_t" "test1" "use_parser")
-}
-
-// ----------------------------------------------------------------------
-
-template <class Derived> struct Base {
-public:
- void interface()
- {
- // ...
- static_cast<Derived*>(this)->implementation();
- // ...
- }
-
- static void static_func()
- {
- // ...
- Derived::static_sub_func();
- // ...
- }
-};
-
-struct Derived : Base<Derived> {
- void implementation() { }
- static void static_sub_func() { }
-};
-
-int foo () {
- Derived d;
- d.//-2-
- ;
- // #2# ("implementation" "interface" "static_func" "static_sub_func")
-}
+++ /dev/null
-// testsubclass.cpp --- unit test for analyzer and complex C++ inheritance
-
-// Copyright (C) 2007-2021 Free Software Foundation, Inc.
-
-// Author: Eric M. Ludlam <zappo@gnu.org>
-
-// This file is part of GNU Emacs.
-
-// GNU Emacs is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// GNU Emacs is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-
-//#include <iostream>
-#include "testsubclass.hh"
-
-void animal::moose::setFeet(int numfeet) //^1^
-{
- if (numfeet > 4) {
- std::cerr << "Why would a moose have more than 4 feet?" << std::endl;
- return;
- }
-
- fFeet = numfeet;
-}
-
-int animal::moose::getFeet() //^2^
-{
- return fFeet;
-}
-
-void animal::moose::doNothing() //^3^
-{
- animal::moose foo();
-
- fFeet = N// -15-
- ; // #15# ( "NAME1" "NAME2" "NAME3" )
-}
-
-
-void deer::moose::setAntlers(bool have_antlers) //^4^
-{
- fAntlers = have_antlers;
-}
-
-bool deer::moose::getAntlers() //^5^
-// %1% ( ( "testsubclass.cpp" "testsubclass.hh" ) ( "deer::moose::doSomething" "deer::moose::getAntlers" "moose" ) )
-{
- return fAntlers;
-}
-
-bool i_dont_have_symrefs()
-// %2% ( ("testsubclass.cpp" ) ("i_dont_have_symrefs"))
-{
-}
-
-void deer::moose::doSomething() //^6^
-{
- // All these functions should be identified by semantic analyzer.
- getAntlers();
- setAntlers(true);
-
- getFeet();
- setFeet(true);
-
- doNothing();
-
- fSomeField = true;
-
- fIsValid = true;
-}
-
-void deer::alces::setLatin(bool l) {
- fLatin = l;
-}
-
-bool deer::alces::getLatin() {
- return fLatin;
-}
-
-void deer::alces::doLatinStuff(moose moosein) {
- // All these functions should be identified by semantic analyzer.
- getFeet();
- setFeet(true);
-
- getLatin();
- setLatin(true);
-
- doNothing();
-
- deer::moose foo();
-
-
-}
-
-moose deer::alces::createMoose()
-{
- moose MooseVariableName;
- bool tmp;
- int itmp;
- bool fool;
- int fast;
-
- MooseVariableName = createMoose();
-
- doLatinStuff(MooseVariableName);
-
- tmp = this.f// -1-
- // #1# ( "fAlcesBool" "fIsValid" "fLatin" )
- ;
-
- itmp = this.f// -2-
- // #2# ( "fAlcesInt" "fGreek" "fIsProtectedInt" )
- ;
-
- tmp = f// -3-
- // #3# ( "fAlcesBool" "fIsValid" "fLatin" "fool" )
- ;
-
- itmp = f// -4-
- // #4# ( "fAlcesInt" "fGreek" "fIsProtectedInt" "fast" )
- ;
-
- MooseVariableName = m// -5-
- // #5# ( "moose" )
-
- return MooseVariableName;
-}
-
-/** Test Scope Changes
- *
- * This function is rigged to make sure the scope changes to account
- * for different locations in local variable parsing.
- */
-int someFunction(int mPickle)
-{
- moose mMoose = deer::alces::createMoose();
-
- if (mPickle == 1) {
-
- int mOption1 = 2;
-
- m// -5-
- // #5# ( "mMoose" "mOption1" "mPickle" )
- ;
-
- } else {
-
- int mOption2 = 2;
-
- m// -6-
- // #6# ( "mMoose" "mOption2" "mPickle" )
- ;
- }
-
-}
-
-// Thanks Ming-Wei Chang for this next example.
-
-namespace pub_priv {
-
- class A{
- private:
- void private_a(){}
- public:
- void public_a();
- };
-
- void A::public_a() {
- A other_a;
-
- other_a.p// -7-
- // #7# ( "private_a" "public_a" )
- ;
- }
-
- int some_regular_function(){
- A a;
- a.p// -8-
- // #8# ( "public_a" )
- ;
- return 0;
- }
-
-}
-
-
-/** Test Scope w/in a function (non-method) with classes using
- * different levels of inheritance.
- */
-int otherFunction()
-{
- sneaky::antelope Antelope(1);
- sneaky::jackalope Jackalope(1);
- sneaky::bugalope Bugalope(1);
-
- Antelope.// -9-
- // #9# ( "fAntyPublic" "fQuadPublic" "testAccess")
- ;
-
- Jackalope.// -10-
- // #10# ( "fBunnyPublic" "testAccess")
- ;
-
- Jackalope// @1@ 6
- ;
- Jackalope;
- Jackalope;
- Jackalope;
-
- Bugalope.// -11-
- // #11# ( "fBugPublic" "testAccess")
- ;
- Bugalope// @2@ 3
- ;
-}
-
-/** Test methods within each class for types of access to the baseclass.
- */
-
-bool sneaky::antelope::testAccess() //^7^
-{
- this.// -12-
- // #12# ( "fAntyPrivate" "fAntyProtected" "fAntyPublic" "fQuadProtected" "fQuadPublic" "testAccess" )
- ;
-}
-
-bool sneaky::jackalope::testAccess() //^8^
-{
- this.// -13-
- // #13# ( "fBunnyPrivate" "fBunnyProtected" "fBunnyPublic" "fQuadProtected" "fQuadPublic" "testAccess" )
- ;
-}
-
-bool sneaky::bugalope::testAccess() //^9^
-{
- this.// -14-
- // #14# ( "fBugPrivate" "fBugProtected" "fBugPublic" "fQuadPublic" "testAccess" )
- ;
-}
+++ /dev/null
-// testsubclass.hh --- unit test for analyzer and complex C++ inheritance
-
-// Copyright (C) 2007-2021 Free Software Foundation, Inc.
-
-// Author: Eric M. Ludlam <zappo@gnu.org>
-
-// This file is part of GNU Emacs.
-
-// GNU Emacs is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// GNU Emacs is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-
-//#include <cmath>
-// #include <stdio.h>
-
-#ifndef TESTSUBCLASS_HH
-#define TESTSUBCLASS_HH
-
-namespace animal {
-
- class moose {
- public:
- moose() : fFeet(0),
- fIsValid(false)
- { }
-
- virtual void setFeet(int);
- int getFeet();
-
- void doNothing();
-
- enum moose_enum {
- NAME1, NAME2, NAME3 };
-
-
- protected:
-
- bool fIsValid;
- int fIsProtectedInt;
-
- private:
- int fFeet; // Usually 2 or 4.
- bool fIsPrivateBool;
-
- }; // moose
-
- int two_prototypes();
- int two_prototypes();
-
- class quadruped {
- public:
- quadruped(int a) : fQuadPrivate(a)
- { }
-
- int fQuadPublic;
-
- protected:
- int fQuadProtected;
-
- private:
- int fQuadPrivate;
-
- };
-
-}
-
-
-namespace deer {
-
- class moose : public animal::moose {
- public:
- moose() : fAntlers(false)
- { }
-
- void setAntlers(bool);
- bool getAntlers();
-
- void doSomething();
-
- protected:
-
- bool fSomeField;
-
- private:
- bool fAntlers;
-
- };
-
-} // deer
-
-// A second namespace of the same name will test the
-// namespace merging needed to resolve deer::alces
-namespace deer {
-
- class alces : public animal::moose {
- public:
- alces(int lat) : fLatin(lat)
- { }
-
- void setLatin(bool);
- bool getLatin();
-
- void doLatinStuff(moose moosein); // for completion testing
-
- moose createMoose(); // for completion testing.
-
- protected:
- bool fAlcesBool;
- int fAlcesInt;
-
- private:
- bool fLatin;
- int fGreek;
- };
-
-};
-
-// A third namespace with classes that does protected and private inheritance.
-namespace sneaky {
-
- class antelope : public animal::quadruped {
-
- public:
- antelope(int a) : animal::quadruped(),
- fAntyProtected(a)
- {}
-
- int fAntyPublic;
-
- bool testAccess();
-
- protected:
- int fAntyProtected;
-
- private :
- int fAntyPrivate;
-
- };
-
- class jackalope : protected animal::quadruped {
-
- public:
- jackalope(int a) : animal::quadruped(),
- fBunny(a)
- {}
-
- int fBunnyPublic;
-
- bool testAccess();
-
- protected:
- bool fBunnyProtected;
-
- private :
- bool fBunnyPrivate;
-
- };
-
- // Nothing specified means private.
- class bugalope : /* private*/ animal::quadruped {
-
- public:
- bugalope(int a) : animal::quadruped(),
- fBug(a)
- {}
-
- int fBugPublic;
-
- bool testAccess();
- protected:
- bool fBugProtected;
-
- private :
- bool fBugPrivate;
-
- };
-
-
-};
-
-#endif
+++ /dev/null
-// testtemplates.cpp --- semantic-ia-utest completion engine unit tests
-
-// Copyright (C) 2008-2021 Free Software Foundation, Inc.
-
-// Author: Eric M. Ludlam <zappo@gnu.org>
-
-// This file is part of GNU Emacs.
-
-// GNU Emacs is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// GNU Emacs is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-
-
-// TODO - this probably means can't be part of emacs, as I don't know who this guy is.
-// Written by 'Raf'
-
-template <class T, int U, class V>
-class read_ref {
-public:
- const T* read_ref_member_one( T);
- const V* read_ref_member_two();
-};
-
-namespace NS {
- template <class T, int U, class V>
- class ref {
- public:
- read_ref<T,10,V> operator->() {
- m_// -1-
- ;
- // #1# ( "m_datas" )
- }
-
- private:
- T m_datas[U];
- };
-
-}
-
-class FooOne {
-public:
- int fooOneMember();
-};
-
-class FooTwo {
-public:
- int fooTwoMember();
-};
-
-class FooThree {
-public:
- int fooThreeMember();
-
- FooOne * operator->();
-};
-
-typedef ref<FooOne, 10,FooTwo> Test;
-
-using NS;
-
-void
-main(void) {
- ref<FooOne, 10, FooTwo> v;
-
- v->read_ref_member_one()-> // -2-
- ;
- // #2# ( "fooOneMember" )
-
- v->read_ref_member_two()-> // -3-
- ;
- // #3# ( "fooTwoMember" )
-
- v-> // -4-
- ;
- // #4# ( "read_ref_member_one" "read_ref_member_two" )
-
- Test t;
-
- t->read_ref_member_two()-> // -5-
- ;
- // #5# ( "fooTwoMember" )
-
- ref<FooOne, 10, FooThree> v2;
-
- v2->read_ref_member_two()-> // -6-
- ;
- // #6# ( "fooOneMember" )
-
- /* Try all these things by also specifying the namespace in the name. */
- NS::ref<FooOne, 10, FooTwo> v3;
-
- v3->read_ref_member_one()-> // -7-
- ;
- // #7# ( "fooOneMember" )
-
- v3->read_ref_member_two()-> // -8-
- ;
- // #8# ( "fooTwoMember" )
-
- v3->read_ref_member_two// @1@ 5
- ;
-
-}
-
-// More Namespace Magic using member constants.
-
-template<typename T>
-struct isFooLike {
- static const bool value = false;
-};
-
-template <>
-struct isFooLike<int> {
- static const bool value = true;
-};
-
-
-template <typename T, bool isFoo>
-class A {
-public:
- A();
- void foo() {};
-};
-
-
-template <typename T>
-class FooFour : public A<T, isPodLike<T>::value> {
-public:
- bool bar() {}
-};
-
-
-int main2() {
-
- FooFour<int> ff;
-
- ff.// - 9- @ TODO - bring over patch from SF
- ; // #9# ( "bar" "foo" );
-
-}
+++ /dev/null
-// testtypedefs.cpp --- Sample with some fake bits out of std::string
-
-// Copyright (C) 2008-2021 Free Software Foundation, Inc.
-
-// Author: Eric M. Ludlam <zappo@gnu.org>
-
-// This file is part of GNU Emacs.
-
-// GNU Emacs is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// GNU Emacs is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-
-// Thanks Ming-Wei Chang for these examples.
-
-namespace std {
- template <T>class basic_string {
- public:
- void resize(int);
- };
-}
-
-typedef std::basic_string<char> mstring;
-
-using namespace std;
-typedef basic_string<char> bstring;
-
-int main(){
- mstring a;
- a.// -1-
- ;
- // #1# ( "resize" )
- bstring b;
- // It doesn't work here.
- b.// -2-
- ;
- // #2# ( "resize" )
- return 0;
-}
-
-// ------------------
-
-class Bar
-{
-public:
- void someFunc() {}
-};
-
-typedef Bar new_Bar;
-
-template <class mytype>
-class TBar
-{
-public:
- void otherFunc() {}
-};
-
-typedef TBar<char> new_TBar;
-
-int main()
-{
- new_Bar nb;
- new_TBar ntb;
-
- nb.// -3-
- ;
- // #3# ("someFunc")
- ntb.// -4-
- ;
- // #4# ("otherFunc")
-
- return 0;
-}
-
-// ------------------
-// Example from Yupeng.
-
-typedef struct epd_info {
- int a;
-} epd_info_t;
-
-static int epd_probe(struct platform_device *pdev)
-{
- struct epd_info *db;
- epd_info_t db1;
-
- db.// -5-
- ; // #5# ("a")
- db1.// -6-
- ;// #6# ("a")
-
- return 1;
-}
-
-// ------------------
-// Example from Michel LAFON-PUYO
-
-typedef enum
-{
- ENUM1,
- ENUM2
-} e_toto;
-
-typedef struct
-{
- int field_a;
- int field_b;
-} t_toto;
-
-// Note: Error condition from anonymous types in a typedef
-// was that the first (ie - the enum) would be used in
-// place of the struct.
-int func(void)
-{
- t_toto t;
- t. // -7-
- ; // #7# ( "field_a" "field_b" )
- return 0;
-}
-
-
-// ------------------
-// Example from Dixon Ryan
-
-
-namespace NS2 {
- class MyClass {
-
- public:
- void myFunction() { }
- };
-}
-
-typedef class NS2::MyClass* MyClassHandle;
-
-int dixon ( void ) {
- MyClassHandle mch = getMyClassHandle();
- NS2::MyClass* mcptr = getMyClassHandle();
-
- mcptr-> // -8-
- ; // #8# ( "myFunction" )
- mch-> // - 9- TODO bring over patch from SF
- ; // #9# ( "myFunction" )
- deleteMyClassHandle(mch);
-
- return 0;
-}
+++ /dev/null
-// testusing.cpp --- semantic-ia-utest completion engine unit tests
-
-// Copyright (C) 2008-2021 Free Software Foundation, Inc.
-
-// Author: Eric M. Ludlam <zappo@gnu.org>
-
-// This file is part of GNU Emacs.
-
-// GNU Emacs is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// GNU Emacs is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-
-
-#include <adstdio.h>
-
-#include <testusing.hh>
-
-namespace moose {
-
- class MyClass;
- class Point;
-
- typedef MyClass snerk;
-}
-
-namespace moose {
-
- class Point;
- class MyClass;
-
-}
-
-namespace {
-
- int global_variable = 0;
-
-};
-
-using moose::MyClass;
-
-void someFcn() {
-
- MyClass f;
-
- f.//-1-
- ; //#1# ( "getVal" "setVal" )
-
-}
-
-// Code from Zhiqiu Kong
-
-namespace panda {
-
- using namespace bread_name;
-
- int func()
- {
- bread test;
- test.//-2-
- ;// #2# ( "geta" )
- return 0;
- }
-}
-
-namespace togglemoose {
-
- MyOtherClass::testToggle1() { //^1^
- // Impl for testToggle1
- }
-}
-
-togglemoose::MyOtherClass::testToggle2() { //^3^
- // Impl for testToggle2
-}
-
-using togglemoose;
-
-MyOtherClass::testToggle3() { //^3^
- // Impl for testToggle3
-}
-
-// Local using statements and aliased types
-// Code from David Engster
-
-void func2()
-{
- using namespace somestuff;
- OneClass f;
- f.//-3-
- ; //#3# ( "aFunc" "anInt" )
-}
-
-void func3()
-{
- using somestuff::OneClass;
- OneClass f;
- f.//-4-
- ; //#4# ( "aFunc" "anInt" )
-}
-
-// Dereferencing alias types created through 'using' statements
-
-// Alias with fully qualified name
-void func4()
-{
- otherstuff::OneClass f;
- f. //-5-
- ; //#5# ( "aFunc" "anInt" )
-}
-
-// Alias through namespace directive
-void func5()
-{
- using namespace otherstuff;
- OneClass f;
- f. //-6-
- ; //#6# ( "aFunc" "anInt" )
-}
-
-// Check name hiding
-void func6()
-{
- using namespace morestuff;
- OneClass f; // Alias for somestuff::OneClass
- f. //-7-
- ; //#7# ( "aFunc" "anInt" )
- aStruct g; // This however is morestuff::aStruct !
- g. //-8-
- ; //#8# ( "anotherBar" "anotherFoo" )
-}
-
-// Alias of an alias
-// Currently doesn't work interactively for some reason.
-void func6()
-{
- using namespace evenmorestuff;
- OneClass f;
- f. //-7-
- ; //#7# ( "aFunc" "anInt" )
-}
-
-// Alias for struct in nested namespace, fully qualified
-void func7()
-{
- outer::StructNested f;
- f.//-8-
- ; //#8# ( "one" "two" )
-}
-
-// Alias for nested namespace
-void func8()
-{
- using namespace outerinner;
- StructNested f;
- AnotherStruct g;
- f.//-9-
- ; //#9# ( "one" "two" )
- g.//-10-
- ; //#10# ( "four" "three" )
-}
-
-// Check conventional namespace aliases
-// - fully qualified -
-void func9()
-{
- alias_for_somestuff::OneClass c;
- c.//-11-
- ; //#11# ( "aFunc" "anInt" )
- alias_for_outerinner::AnotherStruct s;
- s. //-12-
- ; //#12# ( "four" "three" )
-}
-
-// - unqualified -
-void func10()
-{
- using namespace alias_for_somestuff;
- OneClass c2;
- c2.//-13-
- ; //#13# ( "aFunc" "anInt" )
- using namespace alias_for_outerinner;
- AnotherStruct s2;
- s2.//-14-
- ; //#14# ( "four" "three" )
-}
-
-// Completion on namespace aliases
-void func11()
-{
- alias_for_somestuff:://-15-
- ; //#15# ( "OneClass" "aStruct")
- alias_for_outerinner:://-16-
- ; //#16# ( "AnotherStruct" "StructNested" )
-}
-
-// make sure unfound using statements don't crash stuff.
-using something::cantbe::Found;
-
-void unfoundfunc()
-{
- NotFound notfound; // Variable can't be found.
-
- notfound.//-17-
- ; //#17# ( ) Nothing here since this is an undefined class
-
-}
-
-// Using statements can depend on previous ones...
-
-void acc_using()
-{
- using namespace outer;
- // This is effectively like 'using namespace outer::inner'
- using namespace inner;
-
- StructNested sn;
- sn.//-18-
- ; //#18# ( "one" "two" )
-}
-
-// Check the same outside of function scope
-
-using namespace outer;
-using namespace inner;
-
-void acc_using2()
-{
- StructNested sn;
- sn.//-19-
- ; //#19# ( "one" "two" )
-}
-
-// Check if scope gets correctly generated, i.e., without us providing any
-// hints in the form of an existing type
-
-void check_scope()
-{
- using namespace first;
- AAA//-20-
- ; //#20# ( "AAA1" "AAA2" )
-}
-
-void check_scope2()
-{
- using namespace third;
- AAA//-21-
- ; //#21# ( "AAA1" "AAA2" "AAA3" )
-}
-
-// Make sure this also works not only in functions
-
-namespace check_scope3 {
- using namespace first;
- AAA//-22-
- ; //#22# ( "AAA1" "AAA2" )
-}
+++ /dev/null
-// testusing.hh --- semantic-ia-utest completion engine unit tests
-
-// Copyright (C) 2008-2021 Free Software Foundation, Inc.
-
-// Author: Eric M. Ludlam <zappo@gnu.org>
-
-// This file is part of GNU Emacs.
-
-// GNU Emacs is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// GNU Emacs is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-
-namespace moose {
-
- class Point;
-
- class MyClass;
-
-}
-
-
-namespace moose {
-
- class Point;
-
- class MyClass {
- public:
- MyClass() : fVal(0) {
- }
-
- ~MyClass() {};
-
- /**
- * fVal Accessors
- * @{
- */
- int getVal() const {
- return fVal;
- }
- void setVal(int Val) const {
- fVal = Val;
- }
- /**
- * @}
- */
-
- private:
- int fVal;
- };
-
-}
-
-namespace togglemoose {
-
- class MyOtherClass {
- public:
- int testToggle1();
- int testToggle2();
- int testToggle3();
- };
-}
-
-namespace deer {
-
- class Pickle;
-
-};
-
-// Code from Zhiqiu Kong
-
-#ifndef BREAD_H
-#define BREAD_H
-
-namespace bread_name {
- class bread
- {
- public:
- void geta();
- private:
- int m_a;
- int m_b;
- };
-}
-
-#endif
-
-// Code from David Engster
-// Creating alias types through 'using' trickery
-
-namespace somestuff {
- class OneClass {
- public:
- void aFunc();
- int anInt;
- };
- struct aStruct {
- int foo;
- int bar;
- };
-}
-
-namespace otherstuff {
- // make otherstuff::OneClass an alias for somestuff::OneClass
- using somestuff::OneClass;
-}
-
-namespace morestuff {
- // make morestuff an alias namespace for somestuff
- using namespace somestuff;
- // but hide aStruct with own type
- struct aStruct {
- int anotherFoo;
- int anotherBar;
- };
-}
-
-// We can also create an alias for an alias
-namespace evenmorestuff {
- using otherstuff::OneClass;
-}
-
-// Now with nested namespaces
-namespace outer {
- namespace inner {
- struct StructNested {
- int one;
- int two;
- };
- struct AnotherStruct {
- int three;
- int four;
- };
- }
-}
-
-// Namespace which pulls in one of its own nested namespaces
-namespace first {
- class AAA1;
- namespace second {
- class AAA2;
- }
- // Elevate nested namespace into first one
- using namespace second;
-}
-
-namespace third {
- using namespace first;
- class AAA3;
-}
-
-
-// Elevate the first struct into 'outer'
-// so that we can access it via 'outer::StructNested'
-namespace outer {
- using outer::inner::StructNested;
-}
-
-// Create an alias for a nested namespace
-namespace outerinner {
- // equivalent to 'namespace outerinner = outer::inner;'
- using namespace outer::inner;
-}
-
-// Create namespace alias
-namespace alias_for_somestuff = somestuff;
-// Same for nested namespace
-namespace alias_for_outerinner = outer::inner;
+++ /dev/null
-/* testvarnames.cpp --- semantic-ia-utest completion engine unit tests
-
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
-
- Author: Eric M. Ludlam <zappo@gnu.org>
-
- This file is part of GNU Emacs.
-
- GNU Emacs is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- GNU Emacs is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-
-*/
-
-struct independent {
- int indep_1;
- int indep_2;
-};
-
-struct independent var_indep_struct;
-
-struct {
- int unnamed_1;
- int unnamed_2;
-} var_unnamed_struct;
-
-struct {
- int unnamed_3;
- int unnamed_4;
-} var_un_2, var_un_3;
-
-struct inlinestruct {
- int named_1;
- int named_2;
-} var_named_struct;
-
-struct inline2struct {
- int named_3;
- int named_4;
-} var_n_2, var_n_3;
-
-/* Structures with names that then declare variables
- * should also be completable.
- *
- * Getting this to work is the bugfix in semantic-c.el CVS v 1.122
- */
-struct inlinestruct in_var1;
-struct inline2struct in_var2;
-
-/*
- * Structures (or any types) could have the same name as a variable.
- * Make sure we complete vars over types.
- *
- * See cedet-devel mailing list Dec 23, 2013 for details.
- */
-struct varorstruct {};
-int varorstruct;
-
-int assigntovarorstruct;
-
-int test_1(int var_arg1) {
-
- var_// -1-
- ; // #1# ("var_arg1" "var_indep_struct" "var_n_2" "var_n_3" "var_named_struct" "var_un_2" "var_un_3" "var_unnamed_struct")
-
- var_indep_struct.// -2-
- ; // #2# ( "indep_1" "indep_2" )
-
- var_unnamed_struct.// -3-
- ; // #3# ( "unnamed_1" "unnamed_2" )
-
- var_named_struct.// -4-
- ; // #4# ( "named_1" "named_2" )
-
- var_un_2.// -5-
- ; // #5# ( "unnamed_3" "unnamed_4" )
- var_un_3.// -6-
- ; // #6# ( "unnamed_3" "unnamed_4" )
-
- var_n_2.// -7-
- ; // #7# ( "named_3" "named_4" )
- var_n_3.// -8-
- ; // #8# ( "named_3" "named_4" )
-
- in_// -9-
- ; // #9# ( "in_var1" "in_var2" )
-
- in_var1.// -10-
- ; // #10# ( "named_1" "named_2")
- in_var2.// -11-
- ; // #11# ( "named_3" "named_4")
-
- varorstruct = assign// -12-
- ; // #12# ( "assigntovarorstruct" )
-}
+++ /dev/null
-// testvarnames.java --- Semantic unit test for Java
-
-// Copyright (C) 2009-2021 Free Software Foundation, Inc.
-
-// Author: Eric M. Ludlam <zappo@gnu.org>
-
-// This file is part of GNU Emacs.
-
-// GNU Emacs is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// GNU Emacs is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-
-package tests;
-
-/**
- *
- *
- * Created: 02/17/14
- *
- * @author Eric M. Ludlam
- * @version
- * @since
- */
-public class testvarnames {
-
- public class varorclass {
- public static long misclongvalue;
- };
-
- public static varorclass varoftypevarorclass = NULL;
-
- public static long varorclass = 1;
-
- public static long assignintovar = 1;
-
- public static varorclass classassign = NULL;
-
- static public void main(String [] args) {
-
- varorclass = assign// -1-
- // #1# ( "assignintovar" )
- ;
-
- varoftypevarorclass = clas// -2-
- // #2# ( "classassign" )
-
- varoftypevarorclass.misc//-3-
- // #3# ( "misclongvalue" )
- }
-
-} // testvarnames
+++ /dev/null
-;; testwisent.wy --- unit test support file for semantic-utest-ia
-
-;; Copyright (C) 2008-2021 Free Software Foundation, Inc.
-
-;; Author: Eric M. Ludlam <zappo@gnu.org>
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;;
-;; Parser for nothing in particular mode
-
-%languagemode nothing-mode
-%parsetable wisent-nothing-parser-tables
-%keywordtable wisent-nothing-keywords
-%tokentable wisent-nothing-tokens
-%languagemode nothing-mode
-%setupfunction wisent-nothing-default-setup
-
-%start goal
-
-;;; Punctuation
-%type <punctuation> ;;syntax "\\(\\s.\\|\\s$\\|\\s'\\)+" matchdatatype string
-
-%token <punctuation> DOT "."
-%token <punctuation> COMA ","
-%token <punctuation> COLONCOLON "::"
-%token <punctuation> COLON ":"
-%token <punctuation> SEMICOLON ";"
-
-;;; KEYWORDS
-%type <keyword>
-
-%keyword COLONOSCOPY "colonoscopy"
-%keyword SEMISOMETHING "semisomething"
-
-%%
-
-goal
- ;; Misc
- : COLON ;; -1-
- ;; #1# ( "COLONCOLON" "COLON" "COLONOSCOPY" )
- | SEMI ;; -2-
- ;; #2# ( "SEMI_useless_rule" "SEMICOLON" "SEMISOMETHING" )
- | thing ;; -3-
- ;; #3# ( "thing_term_1" "thing_term_2" )
- ;
-
-SEMI_useless_rule
- :
- ;
-
-thing_term_1
- :
- ;
-
-thing_term_2
- :
- ;
-
-%%
-(define-lex wisent-nothing-lexer
- "Lexical analyzer to handle nothing in particular buffers."
- ;; semantic-lex-newline
- semantic-lex-ignore-whitespace
- semantic-lex-ignore-newline
- semantic-lex-ignore-comments
-
- semantic-lex-default-action
- )
-
-;; testwisent.wy ends here
\ No newline at end of file