How to define multiple list for autocomplete using codemirror? - codemirror

I make my own language and using codemirror editor , In my language all class and his methodes defined , so the user only can use class , he can't define a new class ...
For example :
Class A have methods (do1,do2,do3)
Class B have methods (any,click)
I knew how to add all keywords for my language to list and do autocomplete on it using codemirror ...
My question is :
For example :
I want when the user type A then type "." Display list only have the methods contain in class A (do1,do2, do3) I don't want to display keywords or methods of class B within the list of class A ...
So how I can do it with codemirror?
EDIT :
This is my try my example but it does not work when I type (ctrl-space) or type (.) Then the same list is appare I want to display a different list deepened on what I type
my example

Related

Create objects dynamically according to class files in specified project folder

We have a folder with many classes that inherit from the same base class. Their names are formatted like this:
firsttypesubclass_1.cls
firsttypesubclass_2.cls
firsttypesubclass_3.cls
secondtypesubclass_1.cls
secondtypesubclass_2.cls
The program should scan this class folder and create a temp-table with the class-name prefix and count (f.ex "firsttypesubclass" and count=3):
DEFINE PUBLIC TEMP-TABLE TT_AllSubClasses NO-UNDO
FIELD Name AS INT /* f.ex "firsttypesubclass" */
FIELD Name AS INT /* f.ex "firsttypesubclass" */
.
Then we need to create new instances dynamically according to the found classes in a loop like this:
DEF VAR newInstance AS CLASS myBaseClass NO-UNDO.
newInstance = DYNAMIC-NEW TT_AllSubClasses.Name + "_" + STRING(1)(123123) NO-ERROR.
Is there any convenient way to list the class names in the folder? Or is it possibly to get all classes that inherit from the baseclass? I'm thinking about using the file system for checking up the files.
You will have to reach out to the file system and list all class files in the relevant folder. If at runtime the source code is not available, you should base your code on R-code. INPUT FROM OS-DIR is your friend there.
If you are mixing procedural and class based R-code in those relevant folders, you'll also have to verify if the R-code is from a procedure or a class:
RCODE-INFO:FILE-NAME = cFileName .
IF RCODE-INFO:IS-CLASS THEN ...
OpenEdge 11.6 has more reflection features. But there is no functionality that lists all child classes of a given base class. As the ABL does not have a fixed library scheme for classes (like C#), that would probably also be difficult for Progress to implement.

Can an abstract class be embedded in another class?

The documentation says
Abstract classes are essential to support Object Orientation without the typical spamming of the database with always empty auto-created clusters.
But it also says
A class that can't have instances
However, I would like to embed a list class B in class A, not have class A inherit from the abstract class B. Is this allowed?
Example:
enter code here
propVal {
locType : ""
eleName : ""
...
values :[valueStamp]
}
valueStamp {
value : any,
stamp : actionStamp
}
actionStamp{
// various attributes that say who, when, where change was made
}
Is used in many classes keeping track of changes to various fields.
They will never be used stand alone, but can't inherit because they can be used more than once in a class
Sample parent class
classA{
helperAId:"",
helperAProps : embeddedList of PropVals,
helperBId : "",
helperBProps : embeddedList of PropVals
}
Important: The class hierarchy supported by OrientDB is similar to OO principles as implemented by popular languages like Java. However, it is not the same, so there are important differences!
Yes you can embed a (list of) class(es) of type B in a class type A. This is perfectly valid and a much used construct. This is done using the EMBEDDED type.
OrientDB does not support the concept of interfaces or mixin's, just classes and abstract classes. So a class can only inherent (extend) a single parent class. In your use case I would create an abstract ActionStamp class (or whatever you name it) and let your other classes extend it.The B and A classes can both extend this ActionStamp class
So, using your example:
CREATE ABSTRACT CLASS propVal
...
CREATE CLASS A
CREATE PROPERTY A.helperAProps EMBEDDEDLIST propVal
...

Scala parameters for access modifiers?

What is the difference between
class Test {
private[this] val foo = 0
}
vs
class Test {
private val foo = 0
}
What all can go inside the []? Also, what should I search for when I want to look up the specs of this? I tried Googling various combinations of "scala access modifier arguments/parametrized scala access modifier" and nothing came up.
what should I search for when I want to look up the specs of this?
In The Scala Language Specification it is defined as "access modifier" and "access qualifier" (see BNF in §5.2).
What is the difference between
...
What all can go inside the []?
You can put class name, package name or this there. Here is a relevant quote from language specs that explains this (see §5.2 for more details):
The modifier can be qualified with an identifier C (e.g. private[C ]) that must
denote a class or package enclosing the definition. Members labeled with
such a modifier are accessible respectively only from code inside the package
C or only from code inside the class C and its companion module (§5.4).
An different form of qualification is private[this]. A member M marked
with this modifier is called object-protected; it can be accessed only from
within the object in which it is defined. That is, a selection p.M is only legal if the prefix is this or O.this, for some class O enclosing the reference. In
addition, the restrictions for unqualified private apply.
The first one is private for instance class, second is for class. If you use second version you have access from another instance of Test class (it's usefull for equals method or similiar).

How to specify a List<MyCustomType> as a "Return Type" for a UML Interface Property

In my Visio 2007 UML document I am unable to figure out how I can add an operation to an Interface that returns a generic List<MyCustomType> type.
For example:
Say I have a class named "MyClass" and an Interface named "IFace". IFace has a signature of a method that returns a Generic List of MyClass.
For clarity, here's an example of the C# code:
namespace StackO
{
public interface IFace
{
List<MyClass> SomeMethod(string data);
}
public class MyClass
{
}
}
Here's a screenshot of where I'm stuck:
It seems as though the only way to specify a List<MyClass> as my Return Type is to create another user-defined datatype that is explicitly written as List<MyClass>. If this is the case, so be it. However, I'm posting this in hopes that there is a better/proper way to do this.
How can I define the Return Type of an Operation of a Visio Interface to be a Generic List of a User-Defined Datatype?
In the Class diagram properties > Go to operations > select the return type you are interested in changing and click properties.
In the next dialog you will have option for setting prefix List< and suffix >.
This way you can specify the return type as List<>.
I see this option in Visio 2010. But I am not sure if this option is available in Visio 2007.
There is no such a thing as T1<T2> in UML class diagrams.
If you want to specify that the method returns several values, the correct notation is:
SomeMethod(data: String) : MyClass [*]
This notation is much more powerful than the one used by C#. List<MyClass> SomeMethod(string data) gives no information about the contract of the method. With UML, you know that in:
SomeMethod(data: String) : MyClass [*]
SomethingElse() : String [1..*]
LastExample(number: UnlimitedNatural) : Integer [0..1]
SomeMethod returns a sequence containing zero or more elements. SomethingElse returns a sequence of one or several elements: this sequence is never empty. Finally, LastExample returns an optional value. This could be expressed in C# as int? LastExample(uint number) — see, no IEnumerable here.
Also note that:
SomeMethod(data: String) : MyClass [0..*]
shouldn't be used, since [*] means the same thing and is shorter. As for:
SomeMethod(data: String) : MyClass [0..n]
is incorrect, despite being used a lot on the internet.

Type of A field is its Class Name. What is this called in C#?

I new to C#, Sometime I see C# code like this
public class ClassName
{
ClassName field;
}
It mean the field type the same as Class name. WHat this mean and called in C# ?
It is a reference to an instance of the type itself. E.g. An element in a linked list could reference the next element or if the type was a WebPage, it could have a reference to another WebPage.