AppCode add PsiDir issue

I create dir with files via PsiDirectory.createSubdirectory(..), it works fine in Idea. But same code in AppCode works wrong: Folder not visible in ProjectView "project" mode. AFAIK AppCode doesn't open source, so i have no idea how to debug\fix this.

16 comments
Comment actions Permalink

'Project' view in AppCode represents logical Groups, not real folders. Depending on your needs, you might want to use one of the subclasses of OCNewFileActionBase

0
Comment actions Permalink

I can't find in idea community repository anything related to AppCode. 

Also i'm discovered that the created files can be added to logical groups via context menu:

I dont found any api for adding to logical group. Seems like this functionality exists in ApppCode implementation only. Am i right?

0
Comment actions Permalink

Could you please describe what are you trying to achieve? 

0
Comment actions Permalink

I see, so yes, this is AppCode-specific.

The easiest way is to inherit from OCNewFileActionBase. You can also inherit from XcodeCreateFileDialog and then use com.jetbrains.cidr.actions.newFile.XcodeNewFileHelper.doCreateFiles extension to add the file to the project model

0
Comment actions Permalink

Can't find these classes(using community 163.xx), should i add some dependencies?

0
Comment actions Permalink

Update: found these modules, dont sure that i'm need both

com.intellij.modules.appcode  
com.intellij.modules.cidr.lang

 

0
Comment actions Permalink

Should i make two version of plugin? Maybe exists some way to make dependency optional?

Update: oh, i found answer on http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html 

0
Comment actions Permalink

You can have one version with optional dependencies. In order to access mentioned classes and compile the plugin you'll need to have AppCode SDK setup (you can use the current EAP version).

0
Comment actions Permalink

Can i setup AppCode  SDK on OS windows?

0
Comment actions Permalink

You can set it up, since IntelliJ SDK only requires standard jar files, but most likely you won't be able to run it easily.

You'll also need a way to extract macOS DMG installers on Windows:  http://www.wikihow.com/Open-DMG-Files

0
Comment actions Permalink

Thx a lot.

0
Comment actions Permalink

How to understand what does these args mean?

0
Comment actions Permalink

You must not implement/override the extension, instead call it using the following snippet:

OCNewFileHelperProvider[] providers = Extensions.getExtensions(OCNewFileHelperProvider.EP_NAME);
myHelper = providers.length == 1 ? providers[0].createHelper() : null;

@NotNull PsiDirectory directory // where files should be created
@NotNull String[] fileNames // file names
@NotNull PsiFile[] resultElements // empty array of size of fileNames.
@Nullable DialogWrapper dialog // reference to XcodeCreateFileDialog
@Nullable PsiFile sampleFile // leave it empty 

 

 

0
Comment actions Permalink

Got null in PsiFile[] resultElements, when trying to put null instead of "@Nullable DialogWrapper dialog".

1) Is dialog required? Can i create Dir\Group silently?

2) I have no PBXProjectFile and PBXGroup to instantiate dialog. Can i find them in Event?

3) My Action common for all platform, what is the right way to detect availability of opptional dependency?

e.g:

if(isAppCode()  or isCidrLangAvailable()) {
   event.getData(AppCodeDataKeys.PBXProjectFile);
   event.getData(AppCodeDataKeys.PBXGroup);
}



if(isAppCode() or isCidrLangAvailable()) {

   //todo create dir + group

} else {

   //todo create dir 

}
0
Comment actions Permalink

>1) Is dialog required? Can i create Dir\Group silently?

>2) I have no PBXProjectFile and PBXGroup to instantiate dialog. Can i find them in Event?

 

Try something like this:

 

helper = Extensions.getExtensions(OCNewFileHelperProvider.EP_NAME).createHelper()

isAvailable = helper.initFromFile(psiFile_fromDataContext)

dialogPeer = YourDialog (Inherited From OCNewFileActionBase.CreateFileDialogBase

dialog = helper..createDialog(dialogPeer, myState.selectedDir, dataContext)

dialog.show();

 

if(dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {

helper.doCreateFiles(project, directory, ArrayUtil.toStringArray(fileNames), resultElements, dialog, sampleFile);

}

 

But I must admit that there is no good API to do what you need.

 

> 3) My Action common for all platform, what is the right way to detect availability of opptional dependency?

You can register a custom extension in your plugin and implement it depending on the availability of the optional dependency ( http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html).

We'll get to it when you are able to achieve what you need with dialogs.

 

0

Please sign in to leave a comment.