-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1821107
commit a5fd3d9
Showing
9 changed files
with
617 additions
and
509 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
**Added** | ||
* | ||
|
||
**Changed** | ||
* | ||
|
||
**Fixed** | ||
* | ||
|
||
**Notes** | ||
* ArmaAddonsManager needs to finish ArmaAddonsIndexingCallback.java utilization by incrementing an addon's current work progress and total work progress | ||
* WE NEED TO DO THIS: https://github.com/kayler-renslow/arma-intellij-plugin/issues/45 | ||
* What if we automatically mark any Addons in the current module that the user has (they are developing an addon) as a reference directory? | ||
We could reuse code this way. People could also reference other projects if we had multiple reference directories without needing to copy and paste stuff everywhere | ||
**Added** | ||
* auto completion for literals (ctrl+space on disableAI will reveal things like "AUTOCOMBAT") | ||
|
||
**Changed** | ||
* removed duplicate vars from auto completion | ||
* prioritized auto completion such that literals are always first, config functions are second, vars are third, and commands are last. | ||
|
||
**Fixed** | ||
* scenario where config functions couldn't be located when no directory was marked as sources root. | ||
This was resolved by assuming the parent directory of the module .iml file was the src root. | ||
|
||
**Notes** | ||
* ArmaAddonsManager needs to finish ArmaAddonsIndexingCallback.java utilization by incrementing an addon's current work progress and total work progress | ||
* WE NEED TO DO THIS: https://github.com/kayler-renslow/arma-intellij-plugin/issues/45 | ||
* What if we automatically mark any Addons in the current module that the user has (they are developing an addon) as a reference directory? | ||
We could reuse code this way. People could also reference other projects if we had multiple reference directories without needing to copy and paste stuff everywhere |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
**Version:** 2.0.1 | ||
**Release Date:** February 13, 2018 | ||
**Version:** 2.0.2 (NOTE TO SELF: update plugin.xml version) | ||
**Release Date:** June 21, 2018 | ||
|
||
**Added** | ||
* | ||
* auto completion for literals (ctrl+space on disableAI will reveal things like "AUTOCOMBAT") | ||
|
||
**Changed** | ||
* Fixed https://github.com/kayler-renslow/arma-intellij-plugin/issues/70 | ||
* Updated command documentation and command syntaxes to 1.82 | ||
* removed duplicate vars from auto completion | ||
* prioritized auto completion such that literals are always first, config functions are second, vars are third, and commands are last. | ||
|
||
**Fixed** | ||
* scenario where config functions couldn't be located when no directory was marked as sources root. | ||
This was resolved by assuming the parent directory of the module .iml file was the src root. | ||
* https://github.com/kayler-renslow/arma-intellij-plugin/issues/73 | ||
|
||
**Known Issues** | ||
* |
46 changes: 24 additions & 22 deletions
46
resources/com/kaylerrenslow/armaplugin/SQFBundle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
#@formatter:off | ||
# This bundle is for strings related to SQF code. Do not use for plugin code. | ||
# This is shown at the top of every command/bis function documentation window | ||
SQFStatic.external-wiki-link=<b>Online Wiki link: <a href='%1$s' style='color:008800'>%1$s</a></b><p>Green links are external links.</p> | ||
FindUsagesProvider.HelpId.function=Function | ||
FindUsagesProvider.HelpId.value_read=Value read | ||
FindUsagesProvider.HelpId.string=String | ||
FindUsagesProvider.Type.function=Function | ||
FindUsagesProvider.Type.variable=Variable | ||
FindUsagesProvider.Type.command=Command | ||
FindUsagesProvider.Type.string=String | ||
FindUsagesProvider.Type.unknown=Unknown Type | ||
|
||
Inspections.CommandCamelCase.display-name=Command Camel Case | ||
Inspections.CommandCamelCase.annotator-problem-description=Command is not camel case (e.g. camelCase). | ||
Inspections.CommandCamelCase.quickfix=Make the Command camel case. | ||
|
||
Inspections.SyntaxAndTypeCheck.display-name=SQF Syntax and Type Checking | ||
|
||
DocTagsAutoCompletion.trail_text.command = Documentation link for Commands | ||
DocTagsAutoCompletion.trail_text.bis = Documentation link for BIS functions | ||
DocTagsAutoCompletion.trail_text.fnc = Documentation link for description.ext/config.cpp config functions | ||
#@formatter:off | ||
# This bundle is for strings related to SQF code. Do not use for plugin code. | ||
# This is shown at the top of every command/bis function documentation window | ||
SQFStatic.external-wiki-link=<b>Online Wiki link: <a href='%1$s' style='color:008800'>%1$s</a></b><p>Green links are external links.</p> | ||
FindUsagesProvider.HelpId.function=Function | ||
FindUsagesProvider.HelpId.value_read=Value read | ||
FindUsagesProvider.HelpId.string=String | ||
FindUsagesProvider.Type.function=Function | ||
FindUsagesProvider.Type.variable=Variable | ||
FindUsagesProvider.Type.command=Command | ||
FindUsagesProvider.Type.string=String | ||
FindUsagesProvider.Type.unknown=Unknown Type | ||
|
||
Inspections.CommandCamelCase.display-name=Command Camel Case | ||
Inspections.CommandCamelCase.annotator-problem-description=Command is not camel case (e.g. camelCase). | ||
Inspections.CommandCamelCase.quickfix=Make the Command camel case. | ||
|
||
Inspections.SyntaxAndTypeCheck.display-name=SQF Syntax and Type Checking | ||
|
||
DocTagsAutoCompletion.trail_text.command = Documentation link for Commands | ||
DocTagsAutoCompletion.trail_text.bis = Documentation link for BIS functions | ||
DocTagsAutoCompletion.trail_text.fnc = Documentation link for description.ext/config.cpp config functions | ||
|
||
CompletionContributors.literal=Literal |
271 changes: 142 additions & 129 deletions
271
src/com/kaylerrenslow/armaplugin/VirtualFileHeaderFileTextProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,129 +1,142 @@ | ||
package com.kaylerrenslow.armaplugin; | ||
|
||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.roots.ProjectFileIndex; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
import com.intellij.psi.PsiFile; | ||
import com.intellij.psi.PsiManager; | ||
import com.kaylerrenslow.armaDialogCreator.arma.header.HeaderFileTextProvider; | ||
import com.kaylerrenslow.armaplugin.settings.ArmaPluginProjectSettings; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import java.nio.file.InvalidPathException; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
import java.util.Scanner; | ||
|
||
/** | ||
* A {@link HeaderFileTextProvider} implementation that accepts {@link VirtualFile} instances | ||
* | ||
* @author Kayler | ||
* @since 12/09/2017 | ||
*/ | ||
public class VirtualFileHeaderFileTextProvider implements HeaderFileTextProvider { | ||
|
||
@NotNull | ||
private final VirtualFile virtualFile; | ||
@NotNull | ||
private final Project project; | ||
|
||
public VirtualFileHeaderFileTextProvider(@NotNull VirtualFile virtualFile, @NotNull Project project) { | ||
this.virtualFile = virtualFile; | ||
this.project = project; | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public Scanner newTextScanner() throws IOException { | ||
PsiFile file = PsiManager.getInstance(project).findFile(virtualFile); | ||
if (file == null) { | ||
throw new FileNotFoundException("File " + virtualFile + " couldn't be found"); | ||
|
||
} | ||
return new Scanner(file.getText()); | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public String getFileName() { | ||
return virtualFile.getName(); | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public String getFilePath() { | ||
return virtualFile.getPath(); | ||
} | ||
|
||
@Override | ||
public long getFileLength() { | ||
return virtualFile.getLength(); | ||
} | ||
|
||
@Override | ||
@Nullable | ||
public HeaderFileTextProvider resolvePath(@NotNull String path) { | ||
VirtualFile resolvedFile = null; | ||
path = path.replaceAll("\\\\", "/"); | ||
if (!path.startsWith("/")) { | ||
VirtualFile srcRoot = ProjectFileIndex.getInstance(project).getSourceRootForFile(this.virtualFile); | ||
if (srcRoot == null) { | ||
return null; | ||
} | ||
|
||
resolvedFile = srcRoot.findFileByRelativePath(path); | ||
if (resolvedFile == null) { | ||
return null; | ||
} | ||
return new VirtualFileHeaderFileTextProvider(resolvedFile, project); | ||
} | ||
|
||
path = path.substring(1); //remove \ | ||
String addonPrefix = ArmaPluginProjectSettings.getInstance(this.project).getState().addonPrefixName; | ||
if (addonPrefix != null) { | ||
if (path.startsWith(addonPrefix + "/")) { | ||
path = path.substring((addonPrefix + "/").length()); | ||
VirtualFile srcRoot = ProjectFileIndex.getInstance(project).getSourceRootForFile(this.virtualFile); | ||
if (srcRoot == null) { | ||
return null; | ||
} | ||
|
||
resolvedFile = srcRoot.findFileByRelativePath(path); | ||
if (resolvedFile != null) { | ||
return new VirtualFileHeaderFileTextProvider(resolvedFile, project); | ||
} | ||
} | ||
} | ||
|
||
Path pathAsPathObj = null; | ||
try { | ||
pathAsPathObj = Paths.get(path); | ||
} catch (InvalidPathException ignore) { | ||
} | ||
if (pathAsPathObj == null) { | ||
return null; | ||
} | ||
List<ArmaAddon> addons = ArmaAddonsManager.getAddons(); | ||
for (ArmaAddon addon : addons) { | ||
File parentFile = addon.getAddonDirectoryInReferenceDirectory().getParentFile(); | ||
if (parentFile == null) { | ||
continue; | ||
} | ||
Path resolved = parentFile.toPath().resolve(pathAsPathObj); | ||
if (resolved == null) { | ||
continue; | ||
} | ||
File file = resolved.toFile(); | ||
if (!file.exists()) { | ||
continue; | ||
} | ||
return new HeaderFileTextProvider.BasicFileInput(file); | ||
} | ||
return null; | ||
} | ||
} | ||
package com.kaylerrenslow.armaplugin; | ||
|
||
import com.intellij.openapi.module.Module; | ||
import com.intellij.openapi.module.ModuleUtil; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.roots.ProjectFileIndex; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
import com.intellij.psi.PsiFile; | ||
import com.intellij.psi.PsiManager; | ||
import com.kaylerrenslow.armaDialogCreator.arma.header.HeaderFileTextProvider; | ||
import com.kaylerrenslow.armaplugin.settings.ArmaPluginProjectSettings; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import java.nio.file.InvalidPathException; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
import java.util.Scanner; | ||
|
||
/** | ||
* A {@link HeaderFileTextProvider} implementation that accepts {@link VirtualFile} instances | ||
* | ||
* @author Kayler | ||
* @since 12/09/2017 | ||
*/ | ||
public class VirtualFileHeaderFileTextProvider implements HeaderFileTextProvider { | ||
|
||
@NotNull | ||
private final VirtualFile virtualFile; | ||
@NotNull | ||
private final Project project; | ||
|
||
public VirtualFileHeaderFileTextProvider(@NotNull VirtualFile virtualFile, @NotNull Project project) { | ||
this.virtualFile = virtualFile; | ||
this.project = project; | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public Scanner newTextScanner() throws IOException { | ||
PsiFile file = PsiManager.getInstance(project).findFile(virtualFile); | ||
if (file == null) { | ||
throw new FileNotFoundException("File " + virtualFile + " couldn't be found"); | ||
|
||
} | ||
return new Scanner(file.getText()); | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public String getFileName() { | ||
return virtualFile.getName(); | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public String getFilePath() { | ||
return virtualFile.getPath(); | ||
} | ||
|
||
@Override | ||
public long getFileLength() { | ||
return virtualFile.getLength(); | ||
} | ||
|
||
@Override | ||
@Nullable | ||
public HeaderFileTextProvider resolvePath(@NotNull String path) { | ||
VirtualFile resolvedFile = null; | ||
path = path.replaceAll("\\\\", "/"); | ||
if (!path.startsWith("/")) { | ||
VirtualFile srcRoot = ProjectFileIndex.getInstance(project).getSourceRootForFile(this.virtualFile); | ||
if (srcRoot == null) { | ||
Module module = ModuleUtil.findModuleForFile(this.virtualFile, project); | ||
if (module == null) { | ||
return null; | ||
} | ||
srcRoot = module.getModuleFile(); | ||
if (srcRoot == null) { | ||
return null; | ||
} | ||
srcRoot = srcRoot.getParent(); | ||
if (srcRoot == null) { | ||
return null; | ||
} | ||
} | ||
|
||
resolvedFile = srcRoot.findFileByRelativePath(path); | ||
if (resolvedFile == null) { | ||
return null; | ||
} | ||
return new VirtualFileHeaderFileTextProvider(resolvedFile, project); | ||
} | ||
|
||
path = path.substring(1); //remove \ | ||
String addonPrefix = ArmaPluginProjectSettings.getInstance(this.project).getState().addonPrefixName; | ||
if (addonPrefix != null) { | ||
if (path.startsWith(addonPrefix + "/")) { | ||
path = path.substring((addonPrefix + "/").length()); | ||
VirtualFile srcRoot = ProjectFileIndex.getInstance(project).getSourceRootForFile(this.virtualFile); | ||
if (srcRoot == null) { | ||
return null; | ||
} | ||
|
||
resolvedFile = srcRoot.findFileByRelativePath(path); | ||
if (resolvedFile != null) { | ||
return new VirtualFileHeaderFileTextProvider(resolvedFile, project); | ||
} | ||
} | ||
} | ||
|
||
Path pathAsPathObj = null; | ||
try { | ||
pathAsPathObj = Paths.get(path); | ||
} catch (InvalidPathException ignore) { | ||
} | ||
if (pathAsPathObj == null) { | ||
return null; | ||
} | ||
List<ArmaAddon> addons = ArmaAddonsManager.getAddons(); | ||
for (ArmaAddon addon : addons) { | ||
File parentFile = addon.getAddonDirectoryInReferenceDirectory().getParentFile(); | ||
if (parentFile == null) { | ||
continue; | ||
} | ||
Path resolved = parentFile.toPath().resolve(pathAsPathObj); | ||
if (resolved == null) { | ||
continue; | ||
} | ||
File file = resolved.toFile(); | ||
if (!file.exists()) { | ||
continue; | ||
} | ||
return new HeaderFileTextProvider.BasicFileInput(file); | ||
} | ||
return null; | ||
} | ||
} |
Oops, something went wrong.