Skip to content

Commit

Permalink
plugin release 2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
kayler-renslow committed Jun 21, 2018
1 parent 1821107 commit a5fd3d9
Show file tree
Hide file tree
Showing 9 changed files with 617 additions and 509 deletions.
30 changes: 16 additions & 14 deletions CHANGES.md
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
2 changes: 1 addition & 1 deletion META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<idea-plugin>
<id>com.kaylerrenslow.plugin.armaplugin.id</id>
<name>Arma IntelliJ Plugin</name>
<version>2.0.1</version>
<version>2.0.2</version>
<vendor url="https://github.com/kayler-renslow/arma-intellij-plugin">
Kayler Renslow
</vendor>
Expand Down
15 changes: 10 additions & 5 deletions VERSION changelog.md
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 resources/com/kaylerrenslow/armaplugin/SQFBundle.properties
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 src/com/kaylerrenslow/armaplugin/VirtualFileHeaderFileTextProvider.java
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;
}
}
Loading

0 comments on commit a5fd3d9

Please sign in to comment.