From 7fce4cfae69a7a6884c2f2f8cdb610f0e1e805fd Mon Sep 17 00:00:00 2001 From: malte_langkabel Date: Fri, 13 Nov 2015 18:55:10 +0100 Subject: [PATCH] resources: Tutorial Project * added tutorial project to coati projects. * ignoring all .sqlite files for git. --- .gitignore | 10 +-- .../projects/tutorial/src/code_tutorial_1.h | 33 +++++++++ .../projects/tutorial/src/code_tutorial_2.h | 67 +++++++++++++++++++ .../projects/tutorial/src/code_tutorial_3.h | 57 ++++++++++++++++ .../projects/tutorial/src/graph_tutorial_1.h | 37 ++++++++++ .../projects/tutorial/src/graph_tutorial_2.h | 66 ++++++++++++++++++ .../projects/tutorial/src/graph_tutorial_3.h | 38 +++++++++++ .../projects/tutorial/src/graph_tutorial_4.h | 48 +++++++++++++ bin/app/data/projects/tutorial/src/main.cpp | 36 ++++++++++ .../projects/tutorial/src/my_first_step.h | 34 ++++++++++ .../projects/tutorial/src/search_tutorial_1.h | 30 +++++++++ .../projects/tutorial/src/search_tutorial_2.h | 25 +++++++ .../projects/tutorial/src/search_tutorial_3.h | 26 +++++++ .../projects/tutorial/src/search_tutorial_4.h | 39 +++++++++++ .../projects/tutorial/src/search_tutorial_5.h | 27 ++++++++ .../projects/tutorial/src/the_central_hub.h | 29 ++++++++ bin/app/data/projects/tutorial/src/utility.h | 8 +++ bin/app/data/projects/tutorial/tutorial.xml | 12 ++++ 18 files changed, 617 insertions(+), 5 deletions(-) create mode 100644 bin/app/data/projects/tutorial/src/code_tutorial_1.h create mode 100644 bin/app/data/projects/tutorial/src/code_tutorial_2.h create mode 100644 bin/app/data/projects/tutorial/src/code_tutorial_3.h create mode 100644 bin/app/data/projects/tutorial/src/graph_tutorial_1.h create mode 100644 bin/app/data/projects/tutorial/src/graph_tutorial_2.h create mode 100644 bin/app/data/projects/tutorial/src/graph_tutorial_3.h create mode 100644 bin/app/data/projects/tutorial/src/graph_tutorial_4.h create mode 100644 bin/app/data/projects/tutorial/src/main.cpp create mode 100644 bin/app/data/projects/tutorial/src/my_first_step.h create mode 100644 bin/app/data/projects/tutorial/src/search_tutorial_1.h create mode 100644 bin/app/data/projects/tutorial/src/search_tutorial_2.h create mode 100644 bin/app/data/projects/tutorial/src/search_tutorial_3.h create mode 100644 bin/app/data/projects/tutorial/src/search_tutorial_4.h create mode 100644 bin/app/data/projects/tutorial/src/search_tutorial_5.h create mode 100644 bin/app/data/projects/tutorial/src/the_central_hub.h create mode 100644 bin/app/data/projects/tutorial/src/utility.h create mode 100644 bin/app/data/projects/tutorial/tutorial.xml diff --git a/.gitignore b/.gitignore index c88172d6..e8717187 100644 --- a/.gitignore +++ b/.gitignore @@ -4,10 +4,9 @@ /bin/app/Debug/ /bin/app/Release/ /bin/app/data/log/ -/bin/app/data/projects/ +/bin/app/data/projects/ignored/ /bin/app/data/ApplicationSettings.xml /bin/app/data/window_settings.ini -/bin/app/data/*.sqlite /bin/lib/ @@ -16,11 +15,12 @@ /bin/test/data/log/ /bin/test/data/temp.xml /bin/test/data/TestSettings.xml -/bin/test/data/*.sqlite /setup/Linux/lib/* .DS_Store .idea -bin -obj +/ide_plugins/vs/vs2012/CoatiPlugin/CoatiPlugin/bin +/ide_plugins/vs/vs2012/CoatiPlugin/CoatiPlugin/obj + +*.sqlite diff --git a/bin/app/data/projects/tutorial/src/code_tutorial_1.h b/bin/app/data/projects/tutorial/src/code_tutorial_1.h new file mode 100644 index 00000000..9f794afa --- /dev/null +++ b/bin/app/data/projects/tutorial/src/code_tutorial_1.h @@ -0,0 +1,33 @@ +#ifndef CODE_TUTORIAL_1_H +#define CODE_TUTORIAL_1_H + + +#include "utility.h" + +//------------------------------------------------------------------------------ +// +// THE CODE TUTORIAL +// As you already know the code view displays the snippets of code that are +// related to your currently active symbol. These snippets show the relevant +// lines in combination with some context. +// In case you discover something interesting as part of the snippet's context +// you can activate that symbol with a left-click. That way you dig deeper +// through your code base. +// Have you ever wondered what's the meaning of life, the universe and +// everything? Click the respective symbol to find out. +// +//------------------------------------------------------------------------------ + +class CodeTutorial +{ +public: + CodeTutorial() + { + } + + static int meaning_of_life_the_universe_and_everything; +}; + + +#endif // CODE_TUTORIAL_1_H + diff --git a/bin/app/data/projects/tutorial/src/code_tutorial_2.h b/bin/app/data/projects/tutorial/src/code_tutorial_2.h new file mode 100644 index 00000000..bdaeeadb --- /dev/null +++ b/bin/app/data/projects/tutorial/src/code_tutorial_2.h @@ -0,0 +1,67 @@ +#ifndef CODE_TUTORIAL_2_H +#define CODE_TUTORIAL_2_H + + +#include "code_tutorial_1.h" + +//------------------------------------------------------------------------------ +// +// MANAGING CONTEXT +// At this stage you see the whole file. For a shortcut to get here you also +// could have clicked the maximize button at the title bar of the box that +// contains this snippet. It is inactive now because the file is already shown +// as a whole. Before you start experimenting with the other buttons, remember +// that you can click the maximize buttons to get back here and continue +// reading. +// For the final part of this introduction please have a look at where the +// "unrelated_but_very_important()" function is used. +// +//------------------------------------------------------------------------------ + + +void unrelated_but_very_important() +{ +}; + + +int calculate(int (*problem)()) +{ + return problem(); +} + +//------------------------------------------------------------------------------ +// +// MORE CONTEXT +// Who would have expected such a simple question? +// Note that expanding the view didn't change the active symbol. You can +// proceed expanding the view until you hit the level of the file scope. +// So go ahead and find out what else is hidden inside this file! +// +//------------------------------------------------------------------------------ + +void deep_thought() +{ + int (*the_question)() = [](){ return 6 * 7; }; + + +//------------------------------------------------------------------------------ +// +// CONTEXT +// We just talked about Coati providing context to the important lines of code. +// But it feels like something is missing here. What is "the_question"? And +// where does it come from? +// +// EXPANDING TO SCOPES +// Do you see first line of this snippet? It has no line number and says +// "deep_thought". Actually this is the name of the scope that encapsulates the +// snippet. By clicking that line you can tell Coati to expand the view to show +// the whole scope. Give it a try! +// +//------------------------------------------------------------------------------ + int the_answer = calculate(the_question); + CodeTutorial::meaning_of_life_the_universe_and_everything = the_answer; +} + + +#endif // CODE_TUTORIAL_2_H + diff --git a/bin/app/data/projects/tutorial/src/code_tutorial_3.h b/bin/app/data/projects/tutorial/src/code_tutorial_3.h new file mode 100644 index 00000000..0436ff35 --- /dev/null +++ b/bin/app/data/projects/tutorial/src/code_tutorial_3.h @@ -0,0 +1,57 @@ +#ifndef CODE_TUTORIAL_3_H +#define CODE_TUTORIAL_3_H + + +#include "the_central_hub.h" +#include "code_tutorial_2.h" + +//------------------------------------------------------------------------------ +// +// SNIPPETS AND FILES +// It looks like this function is called in two different snippets. When two +// different snippets are located in the same file they share a common file +// view but each of them depicts the name of its own parent's scope. +// If you want to show the lines in between these two snippets you can either +// expand the upper snippet's scope to show the whole file or you can tell the +// lower snippet to reveal its scope. +// Try one of these approaches now. +// +//------------------------------------------------------------------------------ + +void function_with_snippets() +{ + unrelated_but_very_important(); + + +//------------------------------------------------------------------------------ +// +// YOU FOUND THE HIDDEN COMMENT +// Well done! As you see Coati merged the two snippets from before because +// expanding a scope would have caused them to overlap. That's all for the code +// view. +// +// EDIT YOUR CODE +// In case you wondered if you can edit your code using Coati: You can't. Coati +// is designed for code exploration, not as a text editor or an IDE. But there +// is a chance that Coati can talk to your favourite editor (that you already +// know how to operate) via plugin. For more information about available +// plugins please take a look at the Coati User Manual. +// +// We hope you enjoyed this tutorial. You can follow the call below to get back +// to the central hub. +// +// P.S. +// You can also click the file name above to activate the file's node in case +// you want to explore your include hierarchy. +// +//------------------------------------------------------------------------------ + + the_central_hub(); + + + unrelated_but_very_important(); +}; + + +#endif // CODE_TUTORIAL_3_H + diff --git a/bin/app/data/projects/tutorial/src/graph_tutorial_1.h b/bin/app/data/projects/tutorial/src/graph_tutorial_1.h new file mode 100644 index 00000000..c23d2341 --- /dev/null +++ b/bin/app/data/projects/tutorial/src/graph_tutorial_1.h @@ -0,0 +1,37 @@ +#ifndef GRAPH_TUTORIAL_1_H +#define GRAPH_TUTORIAL_1_H + + +#include "utility.h" + +//------------------------------------------------------------------------------ +// +// THE GRAPH TUTORIAL +// In Coati's default window layout the graph is shown to the left, next to the +// code. It displays the structure of your project where all named symbols are +// nodes and all relations are edges. Like the code view it shows only the +// currently active symbol and all the incoming and outgoing dependencies. +// +// HOW DO I NAVIGATE THE GRAPH +// You can activate a new symbol by left-clicking on the node you are +// interested in. For example: to find out where the function +// "where_am_i_called()" is called get over to the graph and click that +// function's node. +// +//------------------------------------------------------------------------------ + +class GraphTutorial +{ +public: + GraphTutorial() + { + } + + static void where_am_i_called() + { + } +}; + + +#endif // GRAPH_TUTORIAL_1_H + diff --git a/bin/app/data/projects/tutorial/src/graph_tutorial_2.h b/bin/app/data/projects/tutorial/src/graph_tutorial_2.h new file mode 100644 index 00000000..0ff3d010 --- /dev/null +++ b/bin/app/data/projects/tutorial/src/graph_tutorial_2.h @@ -0,0 +1,66 @@ +#ifndef GRAPH_TUTORIAL_2_H +#define GRAPH_TUTORIAL_2_H + + +#include "graph_tutorial_1.h" + +//------------------------------------------------------------------------------ +// +// WELL DONE +// You activated a node and both, the graph and the code view have been updated +// accordingly. +// Note that even though Coati provides a graph view it does not remove the +// need for reading code. The graph view is great for gaining a quick overview +// on relations and navigating code, but once you found something you are +// interested in you should still consider the code view to actually read up on +// all the important details. +// +// HIDDEN ELEMENTS +// In order not to flood you with information the graph is hiding a lot of +// elements. Do you see the "ClassWithHiddenMembers" for example? It actually +// contains more members than you currently see. Members that are not important +// for the current context are hidden. Nevertheless you can reveal by clicking +// the arrow next the the class name. +// Try that now. +// +//------------------------------------------------------------------------------ + +class ClassWithHiddenMembers +{ +public: + void potential_caller() + { + GraphTutorial::where_am_i_called(); + } + + void now_you_see_all_contents_of_this_class() + { + } + + void coati_uses_different_colors() + { + } + + void to_distinguish_between_functions() + { + } + + int and_variables; + + int to_continue_click; + +//------------------------------------------------------------------------------ +// +// RELATIONS +// As you see in the graph, this member is accessed at quite some places +// throughout the code base. Lets say you wonder what code causes the edge +// between "reading" and "this_last_member" to appear. What will happen if you +// click the edge? +// +//------------------------------------------------------------------------------ + static int this_last_member; +}; + + +#endif // GRAPH_TUTORIAL_2_H + diff --git a/bin/app/data/projects/tutorial/src/graph_tutorial_3.h b/bin/app/data/projects/tutorial/src/graph_tutorial_3.h new file mode 100644 index 00000000..1ecf332f --- /dev/null +++ b/bin/app/data/projects/tutorial/src/graph_tutorial_3.h @@ -0,0 +1,38 @@ +#ifndef GRAPH_TUTORIAL_3_H +#define GRAPH_TUTORIAL_3_H + + +#include "graph_tutorial_2.h" + +class ProducerOfTheLastMember +{ +public: + void go() + { + ClassWithHiddenMembers::this_last_member = 42; + } + + void on() + { + ClassWithHiddenMembers::this_last_member++; + } +//------------------------------------------------------------------------------ +// +// FOCUSING EDGES +// Even though Coati doesn't allow to activate an edge, you can still focus on +// edges. This doesn't change the currently active symbol (which would cause +// Coati to hide everything but the edge). Instead Coati just highlights the +// relation's location in the code and scrolls you there, so you don't lose +// context. +// Try to activate some more relation. +// +//------------------------------------------------------------------------------ + void reading() + { + ClassWithHiddenMembers::this_last_member *= 2; + } +}; + + +#endif // GRAPH_TUTORIAL_3_H + diff --git a/bin/app/data/projects/tutorial/src/graph_tutorial_4.h b/bin/app/data/projects/tutorial/src/graph_tutorial_4.h new file mode 100644 index 00000000..2e98ad2a --- /dev/null +++ b/bin/app/data/projects/tutorial/src/graph_tutorial_4.h @@ -0,0 +1,48 @@ +#ifndef GRAPH_TUTORIAL_4_H +#define GRAPH_TUTORIAL_4_H + + +#include "graph_tutorial_2.h" +#include "the_central_hub.h" + +class ConsumerOfTheLastMember +{ +public: + void in() + { + ClassWithHiddenMembers::this_last_member--; + } + +//------------------------------------------------------------------------------ +// +// THAT'S IT +// You completed the tutorial on the graph view. There is still more to learn +// but I guess you will figure it out on your own. One last thing: If you see +// an element with a hatched background please call us. It's a runaway! +// Just kidding. Those are elements that are used within your code, but without +// a definition anywhere in your source folder. So if you click them, Coati +// will display all the relations for the element, but the code view won't show +// a definition. If you want to learn more about Coati, go back to the central +// hub. It is called in the function below but you can also try to get there +// using only the graph. +// +//------------------------------------------------------------------------------ + +private: + void the() + { + if (ClassWithHiddenMembers::this_last_member <= 0); + { + the_central_hub(); + } + } + + void codeview() + { + ClassWithHiddenMembers::this_last_member /= 2; + } +}; + + +#endif // GRAPH_TUTORIAL_4_H + diff --git a/bin/app/data/projects/tutorial/src/main.cpp b/bin/app/data/projects/tutorial/src/main.cpp new file mode 100644 index 00000000..7702b759 --- /dev/null +++ b/bin/app/data/projects/tutorial/src/main.cpp @@ -0,0 +1,36 @@ +#ifndef MAIN_H +#define MAIN_H + + +#include "my_first_step.h" + +//------------------------------------------------------------------------------ +// +// WHAT IS THIS? +// This is a tutorial and it is one of the fastest ways to get to know Coati. +// +// WHERE AM I? +// This is Coati's Code View and you are looking at the main function of this +// project's program. +// +// WHY AM I HERE? +// Every time you open up a project in Coati it will go through your project in +// search for a function called "main". In case this function is defined the +// corresponding symbol is activated. Otherwise Coati will just activate the +// first thing in your codebase it happens to stumble across. +// +// WHAT CAN I DO NOW? +// Left-click the "my_first_step()" function call inside the main function. +// Lets see what happens. +// +//------------------------------------------------------------------------------ + +int main() +{ + my_first_step(); + return 0; +} + + +#endif // MAIN_H + diff --git a/bin/app/data/projects/tutorial/src/my_first_step.h b/bin/app/data/projects/tutorial/src/my_first_step.h new file mode 100644 index 00000000..f1e4f2e7 --- /dev/null +++ b/bin/app/data/projects/tutorial/src/my_first_step.h @@ -0,0 +1,34 @@ +#ifndef MY_FIRST_STEP_H +#define MY_FIRST_STEP_H + + +#include "the_central_hub.h" + +//------------------------------------------------------------------------------ +// +// WHAT JUST HAPPENED? +// As I mentioned earlier, Coati knows the concept of an "active" symbol. You +// just changed the active symbol by clicking on the name of a function. +// +// OK, BUT WHAT IS AN ACTIVE SYMBOL? +// Coati doesn't show your entire code base on a single screen. Even for +// relatively small projects that would be pointless - trust me on that. So +// instead of showing everything at once, Coati keeps a strongly focused view +// on your code. This focus only includes the currently active symbol and its +// direct relations. Nothing more. By changing the active symbol as you just +// did, Coati allows you to jump through the code base on your own. +// +// I THINK I GOT IT! +// Now that you understand Coati's central concept you are ready to jump +// further by activating "the_central_hub()" of this tutorial. +// +//------------------------------------------------------------------------------ + +void my_first_step() +{ + the_central_hub(); +} + + +#endif // MY_FIRST_STEP_H + diff --git a/bin/app/data/projects/tutorial/src/search_tutorial_1.h b/bin/app/data/projects/tutorial/src/search_tutorial_1.h new file mode 100644 index 00000000..42ad8b86 --- /dev/null +++ b/bin/app/data/projects/tutorial/src/search_tutorial_1.h @@ -0,0 +1,30 @@ +#ifndef SEARCH_TUTORIAL_1_H +#define SEARCH_TUTORIAL_1_H + + +#include "utility.h" + +//------------------------------------------------------------------------------ +// +// THE SEARCH TUTORIAL +// If you haven't messed up anything yet, you'll find the search bar to the +// upper left of Coati's user interface. Initially it shows the name of the +// currently active symbol. +// Use the shortcut "CTRL/CMD + F" to focus the search bar. You can also just +// click it. Try that now and enter the string "find_me_if_you_can" to search +// for the respective symbol. Press enter or click the magnification glass to +// execute the search. +// +//------------------------------------------------------------------------------ + +class SearchTutorial +{ +public: + SearchTutorial() + { + } +}; + + +#endif // SEARCH_TUTORIAL_1_H + diff --git a/bin/app/data/projects/tutorial/src/search_tutorial_2.h b/bin/app/data/projects/tutorial/src/search_tutorial_2.h new file mode 100644 index 00000000..e18bc534 --- /dev/null +++ b/bin/app/data/projects/tutorial/src/search_tutorial_2.h @@ -0,0 +1,25 @@ +#ifndef SEARCH_TUTORIAL_2_H +#define SEARCH_TUTORIAL_2_H + + +#include "utility.h" + +//------------------------------------------------------------------------------ +// +// THE AUTOCOMPLETION +// I hope you have been lazy enough to not enter the whole string from start to +// finish. So you already noticed Coati's autocompletion box. +// While you enter your search request Coati already tries to find a subset of +// matching symbols to help you get where you want pretty fast. +// But that's not all Coati does. Keep an eye on the search bar while entering +// the string "aux" and activate the symbol showing up. +// +//------------------------------------------------------------------------------ + +void finde_me_if_you_can() +{ +} + + +#endif // SEARCH_TUTORIAL_2_H + diff --git a/bin/app/data/projects/tutorial/src/search_tutorial_3.h b/bin/app/data/projects/tutorial/src/search_tutorial_3.h new file mode 100644 index 00000000..88aa44ea --- /dev/null +++ b/bin/app/data/projects/tutorial/src/search_tutorial_3.h @@ -0,0 +1,26 @@ +#ifndef SEARCH_TUTORIAL_3_H +#define SEARCH_TUTORIAL_3_H + + +#include "utility.h" + +//------------------------------------------------------------------------------ +// +// FUZZY MATCHING +// While looking for matching symbols the search bar does not only consider +// strict matches to the entered substring. Instead it uses a more fuzzy +// approach. This is really helpful when you only have a rough idea of what the +// element you are really looking for is called. +// While showing the list of results the autocompletion also display the kind +// of each of the results to the very right. +// Try to activate the class with the name "NameConflict" next. +// +//------------------------------------------------------------------------------ + +void autocompletion_example() +{ +} + + +#endif // SEARCH_TUTORIAL_3_H + diff --git a/bin/app/data/projects/tutorial/src/search_tutorial_4.h b/bin/app/data/projects/tutorial/src/search_tutorial_4.h new file mode 100644 index 00000000..9be94bdb --- /dev/null +++ b/bin/app/data/projects/tutorial/src/search_tutorial_4.h @@ -0,0 +1,39 @@ +#ifndef SEARCH_TUTORIAL_4_H +#define SEARCH_TUTORIAL_4_H + + +#include "utility.h" + +//------------------------------------------------------------------------------ +// +// WHAT ARE THE OTHER BUTTONS? +// Well done. Lets get over the other buttons left to the search bar really +// quick. +// +// UNDO AND REDO +// You can use the buttons to the very left to undo and redo your actions. This +// may seem odd since Coati doesn't include any features to actually change +// code. Instead Coati offers these buttons to help you navigate. So they +// really come in handy in case you ask yourself something like "How did I end +// up here?" +// +// REFRESH +// The next button allows you to refresh you project in case you changed some +// of your code. The second button toggels the auto-refresh option. When +// enabled Coati refreshes your project every time it's window gets focused. +// +// WHAT'S NEXT? +// Instead of the class activate the struct with the same name as before. +// +//------------------------------------------------------------------------------ + +namespace a +{ + class NameConflict + { + }; +} + + +#endif // SEARCH_TUTORIAL_4_H + diff --git a/bin/app/data/projects/tutorial/src/search_tutorial_5.h b/bin/app/data/projects/tutorial/src/search_tutorial_5.h new file mode 100644 index 00000000..8c801879 --- /dev/null +++ b/bin/app/data/projects/tutorial/src/search_tutorial_5.h @@ -0,0 +1,27 @@ +#ifndef SEARCH_TUTORIAL_5_H +#define SEARCH_TUTORIAL_5_H + + +#include "utility.h" + +//------------------------------------------------------------------------------ +// +// CONGRATULATONS +// You have completed the challenge of search. +// Oh, I almost forgot: You can only find nodes such as symbols via the search +// bar. It doesn't allow you to find edges like calls or inheritance. At least +// not yet. +// Try to get back to the the central hub using the search bar! +// +//------------------------------------------------------------------------------ + +namespace b +{ + struct NameConflict + { + }; +} + + +#endif // SEARCH_TUTORIAL_5_H + diff --git a/bin/app/data/projects/tutorial/src/the_central_hub.h b/bin/app/data/projects/tutorial/src/the_central_hub.h new file mode 100644 index 00000000..ade0799e --- /dev/null +++ b/bin/app/data/projects/tutorial/src/the_central_hub.h @@ -0,0 +1,29 @@ +#ifndef THE_CENTRAL_HUB_H +#define THE_CENTRAL_HUB_H + + +#include "code_tutorial_1.h" +#include "graph_tutorial_1.h" +#include "search_tutorial_1.h" + +//------------------------------------------------------------------------------ +// +// THE HUB +// This is the central hub of Coati's tutorial. From here you can embark on +// short trips to explore the different parts of Coati. Most important: You +// will get to know how all the different parts of Coati interact. +// The function below references all the available tutorials. So pick one and +// jump right to action. +// +//------------------------------------------------------------------------------ + +void the_central_hub() +{ + SearchTutorial* the_challenge_of_search; + GraphTutorial* reading_the_map; + CodeTutorial* explore_the_details; +} + + +#endif // THE_CENTRAL_HUB_H + diff --git a/bin/app/data/projects/tutorial/src/utility.h b/bin/app/data/projects/tutorial/src/utility.h new file mode 100644 index 00000000..b041c57a --- /dev/null +++ b/bin/app/data/projects/tutorial/src/utility.h @@ -0,0 +1,8 @@ +#ifndef UTILITY_H +#define UTILITY_H + + +typedef unsigned int uint; + + +#endif // UTILITY_H \ No newline at end of file diff --git a/bin/app/data/projects/tutorial/tutorial.xml b/bin/app/data/projects/tutorial/tutorial.xml new file mode 100644 index 00000000..ff5af2b5 --- /dev/null +++ b/bin/app/data/projects/tutorial/tutorial.xml @@ -0,0 +1,12 @@ + + + + + .h + .cpp + + + ./src + + + \ No newline at end of file