Creating another kotlin class file - kotlin

I have issues creating another kotlin class file in my src folder in IntelliJ, please how do I go about this cos I've made a lot of findings but to no avail.

Related

IntelliJ is acting cray cray with imports

After moving files in and out because I wasn't sure of the structure IntelliJ is just going absolutly mental on me:
My class is situated in main.java.entities.FailedAttempt
Scenario 1
import main.entities.FailedAttempt;
Here it says entities is not found (which is correct) yet it finds the class
Scenario 2
import main.java.entities.FailedAttempt;
Here it finds the import of entities (it should not) but doesn't find the class!
Scenario 3
import main.java.entities.*;
...
private List<FailedAttempt> faList = new ArrayList<FailedAttempt>();
Here the import is correct - no error message - but it's unused and private List<FailedAttempt> cannot be resolved.
What I did:
The package was originally named main.java which contained a bunch of other packages. I renamed it to main, then created another java package in it and put all the other class in that java package. Resulting in exactly what I had at the beggining.. Except for the imports which are totally messed up.
Can I somehow resolve this ? I've a feeling I'll have to manually change the class names, invalidate cache, delete project and reimport the folder into intelliJ. But if there is a better method I'm all for it.
I created an issue on their tracker
Use this icon:
to open the project structure and set it up structure using Project Settings -> Modules under Sources:
Last, you should check, that everything is exported. You can do that under Artifacts.
Hope that helps.
Had to close the project, Import a new project from an earlier git version and work from there. If someone has this in the future and doesn't use cvs I think it's gonna be annoying.

Rename class in external dll without losing reference to it in unityEditor

We've got a visualstudio solution with all our code in it and it's completely seperated from our unity project.
When we build our code into a dll from within visualstudio, the dll is copied over to the unity project plugins folder, so we can use the classes from it in our unity project.
This all works fine, but the problem is when we rename a class in our visual studio solution, rebuild the dll and go back to the unity project, the reference to the renamed class is lost in our scene and/or prefabs...
I looked into the scene & prefab files and noticed the references to the classes in the dll are defined as follows:
m_Script: {fileID: 698634159, guid: aa20b9c3579870b40bb96d13672546a3, type: 3}
I read on the forums that the fileID is generated based on the namespace & name of the class file, so logically when the class is renamed, this fileID changes and unity does not know it needs to reference the renamed class.
Is there a way to define a hard references of some kind, so the reference does not get lost when renaming a class? Or any other suggestions to keep references from getting lost.
I've also tried including a meta file with a guid in the dll, but unity does not seem to take this meta file into account, as it always uses the guid of the dll together with the generated fileId.
Unity can't automagickaly find out you have renamed some class inside the DLL. That's true for any form of project : if you depend on some DLL, and classes changes in the DLL, there is no indication of rename.
The best way to link them is adding your Unity project in the solution, and place a dependance between Unity project and the another. Then maybe the refactor tool will suggest you the rename in the Unity project.
Here is a really good tool to find and replace missing scripts, which i assume is the error you are getting.
http://daikonforge.com/forums/resources/fix-missing-scripts.3/
It comes with the source code once you unpack the Unity3d Package, so you can customize it to your needs.

Create a simple Java Class in IntelliJ 13

When I am using Eclipse I just configure a project in seconds and create classes in seconds. In intelliJ however, I have to be looking all over the place on how ro create a simple Java class. I swear it is not in the new drop down list. Its giving me options for html and leaves out the class for a Java project! Anything would be accepted.
You just right click on the package you want to create a Java Class in, then select New->Java Class
You need to make sure you have your source tree marked as a sources root (IntelliJ usually does a good job detecting this on its own for existing sources). If not you will need to mark it as a sources root before you are able to create a Java class. Right click on the sources root then Mark Directory As->Sources Root
It depends on the kind of project you're doing. For example, if you're in a maven project, creating a file should be done in src/main/java. If you right click on this folder, you'll have the possibility to create a java class.
In general, the context menu depends on the context you're calling it.
Hope it helps

EMF: How to create model instance programmatically without using eclipse instance

With EMF I can import an ecore file (metamodel), generate the code then debug the project as a new eclipse instance to play with my model instance. My purpose is to create my instance without loading a new eclipse instance, for example I would like to create a new Java project that use my generated code to create the instance assuming that I'll do some validation/OCL to have an instance that I can serialize to an XMI file.
I was thinking about export the generated code (Model, Edit, Editor) to a JAR file or as a plugin, but it didn't work perfectly. Do you have any suggestion or HowTo?
I am not sure what you mean by "without loading a new eclipse instance", but if you want to get rid of the EMF and Eclipse-dependencies you can achieve this by editing your genmodel. This recipe explains the steps in detail: http://wiki.eclipse.org/EMF/Recipes#Recipe:_Generating_Pure_API_With_No_Visible_EMF_Dependencies
Not everything EMF has to offer will work with this solution, but it might be sufficient for what you want.

Best practices when importing class files in xcode

I'm working with xcode and I have classes associated with other projects that I want to be included in new projects. I realize that the #import will do the job technically (although what should i do if it's out of the project root folder). But what do I do if I want to include the class "properly" --basically so i can double click and edit out of the main project window where you can see all your files and such.
I guess I'm just looking for the best and/or proper way to include/import (into the project) .h and .m files that I've already created outside of the current project I'm working on. Taking into consideration that I may want to modify the class from the original without subclassing. Hopefully this makes sense.
Thanks,
Nick
Xcode project file organization doesn't reflect the data files on disk. Files can be added to a project from anywhere in the file system. When you add the files, choosing not to copy the files to the current project's directory means that the original files are used. Selecting one of these files in Xcode for editing will alter the original file in that other project. When returning to that other project, Xcode will use the edited files in any further work.
This type of use can be quite handy while working on multiple projects with some shared code. Yet, it can also cause headaches for a versioning system.
Might be worth thinking about how to make the classes into a private framework - then you can import that as another dependency each time. Alternatively you could use a separate version control system location to store the shared classes and just check that out into the project folder.