Skip to content

Commit

Permalink
1.0.6 release
Browse files Browse the repository at this point in the history
  • Loading branch information
kayler-renslow committed Oct 27, 2016
1 parent 31e3c70 commit 733cfdd
Show file tree
Hide file tree
Showing 22 changed files with 347 additions and 137 deletions.
15 changes: 15 additions & 0 deletions Arma Intellij Plugin.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PLUGIN_MODULE" version="4">
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/META-INF/plugin.xml" />
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/grammars" type="java-resource" relativeOutputPath="com.kaylerrenslow.a3plugin.lang" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
2 changes: 1 addition & 1 deletion src/CHANGES.md → CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*

**Fixed**<br>
*
* https://github.com/kayler-renslow/arma-intellij-plugin/issues/26

## Header
**Added**<br>
Expand Down
2 changes: 1 addition & 1 deletion META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin version="2">
<id>com.kaylerrenslow.plugin.armaplugin.id</id>
<name>Arma Intellij Plugin</name>
<version>1.1.0</version>
<version>1.0.6</version>
<!--<vendor email="[email protected]" url="http://www.yourcompany.com">YourCompany</vendor>-->
<description>
Plugin that offers syntax checking of SQF files, syntax highlighting, find usages, refactor renaming, and more various features.
Expand Down
File renamed without changes.
47 changes: 47 additions & 0 deletions VERSION changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
**Version:** 1.0.6<br>
**Release Date:** October 26, 2016

## Plugin
**Added**<br>
*

**Changed**<br>
*

**Fixed**<br>
*


## Shared between languages
**Added**<br>
*

**Changed**<br>
*

**Fixed**<br>
* https://github.com/kayler-renslow/arma-intellij-plugin/issues/30

## SQF
**Added**<br>
*

**Changed**<br>
*

**Fixed**<br>
* https://github.com/kayler-renslow/arma-intellij-plugin/issues/24
* https://github.com/kayler-renslow/arma-intellij-plugin/issues/26
* https://github.com/kayler-renslow/arma-intellij-plugin/issues/27
* https://github.com/kayler-renslow/arma-intellij-plugin/issues/28


## Header
**Added**<br>
*

**Changed**<br>
*

**Fixed**<br>
*
Binary file added icons/command icon.psd
Binary file not shown.
Binary file added icons/function icon.psd
Binary file not shown.
Binary file added icons/header icon.psd
Binary file not shown.
Binary file added icons/magic variable icon.psd
Binary file not shown.
Binary file added icons/plugin icon.psd
Binary file not shown.
Binary file added icons/sqf icon.psd
Binary file not shown.
Binary file added icons/variable icon.psd
Binary file not shown.
34 changes: 0 additions & 34 deletions src/VERSION changelog

This file was deleted.

15 changes: 9 additions & 6 deletions src/com/kaylerrenslow/a3plugin/lang/shared/PsiUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,23 +269,26 @@ public static ASTNode findFirstDescendantElement(@NotNull ASTNode node, @NotNull
return null;
}


public static <E extends PsiElement> ArrayList<E> findDescendantElementsOfInstance(PsiElement rootElement, Class<E> type, PsiElement cursor) {
public static <E extends PsiElement> ArrayList<E> findDescendantElementsOfInstance(@NotNull PsiElement rootElement, @NotNull Class<E> type, @Nullable PsiElement cursor, @Nullable String textContent) {
ArrayList<E> list = new ArrayList<>();
findDescdantElementsOfInstance(rootElement, type, cursor, list);
findDescdantElementsOfInstance(rootElement, type, cursor, textContent, list);
return list;
}

private static <E extends PsiElement> void findDescdantElementsOfInstance(PsiElement rootElement, Class<?> type, PsiElement cursor, ArrayList<E> list) {
public static <E extends PsiElement> ArrayList<E> findDescendantElementsOfInstance(@NotNull PsiElement rootElement, @NotNull Class<E> type, @Nullable PsiElement cursor) {
return findDescendantElementsOfInstance(rootElement, type, cursor, null);
}

private static <E extends PsiElement> void findDescdantElementsOfInstance(PsiElement rootElement, Class<?> type, PsiElement cursor, String textContent, ArrayList<E> list) {
PsiElement child = rootElement.getFirstChild();
while (child != null) {
if (cursor != null && child == cursor) {
continue;
}
if (type.isAssignableFrom(child.getClass())) {
if (type.isAssignableFrom(child.getClass()) && (textContent == null || child.getText().equals(textContent))) {
list.add((E) child);
}
findDescdantElementsOfInstance(child, type, cursor, list);
findDescdantElementsOfInstance(child, type, cursor, textContent, list);
child = child.getNextSibling();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,47 +32,47 @@
Created by Kayler on 08/03/2016.
*/
public class PrivatizationAndDeclarationInspection extends LocalInspectionTool {


@NotNull
@Override
public HighlightDisplayLevel getDefaultLevel() {
return HighlightDisplayLevel.WARNING;
}

@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
return new InspectionVisitor(holder);
}

@Nls
@NotNull
@Override
public String getDisplayName() {
return Plugin.resources.getString("lang.sqf.inspection.privatization_and_declaration.display_name");
}

@Nls
@NotNull
@Override
public String getGroupDisplayName() {
return Plugin.resources.getString("lang.sqf.inspection.group.misc.group_display_name");
}

/**
@author Kayler
Used for making sure variables are declared private, aren't declared private more than once, and are defined.
Created on 06/03/2016.
*/
private static class InspectionVisitor extends SQFVisitor {

private ProblemsHolder holder;

InspectionVisitor(ProblemsHolder holder) {
this.holder = holder;
}

@Override
public void visitVariable(@NotNull SQFVariable var) {
if (var.isLangVar()) {
Expand All @@ -81,20 +81,21 @@ public void visitVariable(@NotNull SQFVariable var) {
if (var.getParent() instanceof SQFMacroCall) {
return;
}
boolean isGlobalVar = var.isGlobalVariable();

final boolean isGlobalVar = var.isGlobalVariable();
final SQFScope declScope = var.getDeclarationScope();

PsiReference[] references;
if (isGlobalVar) {
references = ReferenceProvidersRegistry.getReferencesFromProviders(var);
} else {
references = var.getReferences();
}

int numUsages = 0;

int numAssignments = 0;
boolean isUsedOverride = false;
boolean isDefinedByParams = false;
boolean forceDefined = false;
for (PsiReference reference : references) {
PsiPolyVariantReference polyRef = null;
ResolveResult[] polyResults = null;
Expand Down Expand Up @@ -126,40 +127,44 @@ public void visitVariable(@NotNull SQFVariable var) {
break;
}
}
} else if (resolve instanceof SQFString) {
SQFString string = (SQFString) resolve;
if (SQFPsiUtil.getForVarScope(string) != null) {
numAssignments++;
forceDefined = true;
}
}
} while (polyRef != null && polyRefInd < polyResults.length);

}

SQFPrivatization privatization = null;
if (!isGlobalVar) {
privatization = var.getPrivatization();
if (privatization instanceof SQFPrivatization.SQFPrivateDeclParams) {
SQFParamsStatement paramsStatement = ((SQFPrivatization.SQFPrivateDeclParams) privatization).getPrivatizer();
if (paramsStatement != null && paramsStatement.varIsDefined(var.getVarName())) {
isDefinedByParams = true;
forceDefined = true;
}
}
}
if (numAssignments == numUsages && !isUsedOverride) {
holder.registerProblem(var, Plugin.resources.getString("lang.sqf.annotator.variable_unused"), ProblemHighlightType.WEAK_WARNING);
}
if (numAssignments == 0 && !isDefinedByParams) {
if (numAssignments == 0 && !forceDefined) {
if (privatization instanceof SQFPrivatization.SQFPrivateDeclParams) {
holder.registerProblem(var, Plugin.resources.getString("lang.sqf.annotator.variable_may_be_uninitialized"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
} else {
holder.registerProblem(var, Plugin.resources.getString("lang.sqf.annotator.variable_uninitialized"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
}

SQFScope declScope = var.getDeclarationScope();
if (privatization != null || isGlobalVar) {
return;
}
holder.registerProblem(var, Plugin.resources.getString("lang.sqf.annotator.variable_not_private"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new SQFAnnotatorFixNotPrivate(var, declScope));

}

@Override
public void visitScope(@NotNull SQFScope scope) {
List<SQFPrivateDeclVar> privateVars = scope.getPrivateVars();
Expand Down Expand Up @@ -197,36 +202,36 @@ public void visitScope(@NotNull SQFScope scope) {
vars.add(currentPrivateVar.getVarName());
}
}

private class SQFAnnotatorFixNotPrivate extends IntentionAndQuickFixAction {
private final SmartPsiElementPointer<SQFScope> varScopePointer;
private final SmartPsiElementPointer<SQFVariable> fixVarPointer;

SQFAnnotatorFixNotPrivate(SQFVariable var, SQFScope declScope) {
this.fixVarPointer = SmartPointerManager.getInstance(var.getProject()).createSmartPsiElementPointer(var, var.getContainingFile());
this.varScopePointer = SmartPointerManager.getInstance(var.getProject()).createSmartPsiElementPointer(declScope, declScope.getContainingFile());
}

@NotNull
@Override
public String getName() {
return Plugin.resources.getString("lang.sqf.annotator.variable_not_private.quick_fix");
}

@NotNull
@Override
public String getFamilyName() {
return "";
}

@Override
public void applyFix(@NotNull Project project, PsiFile file, @Nullable Editor editor) {
Runnable runnable = new Runnable() {
@Override
public void run() {
SQFScope varScope = varScopePointer.getElement();
SQFVariable fixVar = fixVarPointer.getElement();
if(fixVar == null || varScope == null){
if (fixVar == null || varScope == null) {
return;
}
ArrayList<SQFCommandExpression> commandExpressions = PsiUtil.findDescendantElementsOfInstance(file, SQFCommandExpression.class, null);
Expand All @@ -239,7 +244,7 @@ public void run() {
return;
}
}

PsiElement declStatement = SQFPsiUtil.createElement(project, String.format("private[\"%s\"];", fixVar.getVarName()), SQFTypes.STATEMENT);
if (varScope.getFirstChild() != null) {
varScope.addBefore(declStatement, varScope.getFirstChild());
Expand All @@ -249,11 +254,11 @@ public void run() {
}
};
WriteCommandAction.runWriteCommandAction(project, runnable);

}
}


}

}
Loading

1 comment on commit 733cfdd

@BangL
Copy link

@BangL BangL commented on 733cfdd Oct 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i love you, going to check it out soon. thanks for your hard work!

Please sign in to comment.