Skip to content

Commit

Permalink
1.0.5 release
Browse files Browse the repository at this point in the history
  • Loading branch information
kayler-renslow committed Jul 23, 2016
1 parent 1d5a1df commit 2326480
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 69 deletions.
2 changes: 1 addition & 1 deletion META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<completion.contributor language="Arma.Header" implementationClass="com.kaylerrenslow.a3plugin.lang.header.contributors.HeaderCompletionContributor"/>
<lang.commenter language="Arma.Header" implementationClass="com.kaylerrenslow.a3plugin.lang.header.editor.HeaderCommenter"/>
<!--<lang.formatter language="Arma.Header" implementationClass="com.kaylerrenslow.a3plugin.lang.header.codeStyle.formatting.HeaderFormattingBuilder"/>-->
<codeStyleSettingsProvider implementation="com.kaylerrenslow.a3plugin.lang.header.providers.HeaderCodeStyleSettingsProvider"/>
<!--<codeStyleSettingsProvider implementation="com.kaylerrenslow.a3plugin.lang.header.providers.HeaderCodeStyleSettingsProvider"/>-->
<langCodeStyleSettingsProvider implementation="com.kaylerrenslow.a3plugin.lang.header.providers.HeaderLanguageCodeStyleSettingsProvider"/>
<lang.braceMatcher language="Arma.Header" implementationClass="com.kaylerrenslow.a3plugin.lang.header.editor.HeaderBraceMatcher" />
<lang.foldingBuilder language="Arma.Header" implementationClass="com.kaylerrenslow.a3plugin.lang.header.editor.HeaderFoldingBuilder" />
Expand Down
9 changes: 4 additions & 5 deletions src/CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ Shared between languages
CHANGED:
none
FIXED:
none
Stringtable Value color not properly being displayed in color settings page

SQF
ADDED:
none
CHANGED:
removed optimizations to finding variable scope (cached declaration scope and privatization) because they resulted in wrong values
variables set to nil will now be marked as uninitialized
variables declared in params command that have no default value will be marked as "may be uninitialized" instead of more definitive "not initialized"
none
FIXED:
params [["_var", nil]];//was saying _var was defined when it shouldn't be
https://github.com/kayler-renslow/arma-intellij-plugin/issues/17
quick documentation lookup not working for commands while still typing the command

Header
ADDED:
Expand Down
2 changes: 1 addition & 1 deletion src/TODO
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ features:
check if function exists when doing call or spawn
renaming files will rename them in includes and if a SQF function, will rename the class decl

THIS IS BROKEN AGAIN
THIS IS BROKEN AGAIN (scope)
_i = 100;
for [{private _i = 0}, {_i < 5}, {_i = _i + 1}] do {};
hint str _i; // 100
Expand Down
4 changes: 3 additions & 1 deletion src/VERSION changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Version: 1.0.5
Release date: tbd
Release date: July 22 2016

Plugin
ADDED:
Expand All @@ -25,6 +25,8 @@ SQF
variables declared in params command that have no default value will be marked as "may be uninitialized" instead of more definitive "not initialized"
FIXED:
params [["_var", nil]];//was saying _var was defined when it shouldn't be
https://github.com/kayler-renslow/arma-intellij-plugin/issues/17
quick documentation lookup not working for commands while still typing the command

Header
ADDED:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TestClass {
/*Another block comment*/
array[] = {var, 1, 1e1, "", 42, 43};
math = 1 + 69 * 1;
stringtable_value = $str_myTag_Yes;
stringtable_value = <stringtableValue>$str_myTag_Yes</stringtableValue>;
};

thingy = 0; /*hi*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.util.HashMap;
import java.util.Map;

/**
Expand All @@ -33,7 +34,12 @@ public class HeaderColorSettingsPage implements ColorSettingsPage{
new AttributesDescriptor("Comma", HeaderSyntaxHighlighter.COMMA),
new AttributesDescriptor("Stringtable Value", HeaderSyntaxHighlighter.STRINGTABLE_VALUE)
};


private static final Map<String, TextAttributesKey> map = new HashMap<>();
static {
map.put("stringtableValue", HeaderSyntaxHighlighter.STRINGTABLE_VALUE);
}

@Nullable
@Override
public Icon getIcon() {
Expand All @@ -55,7 +61,7 @@ public String getDemoText() {
@Nullable
@Override
public Map<String, TextAttributesKey> getAdditionalHighlightingTagToDescriptorMap() {
return null;
return map;
}

@NotNull
Expand Down
68 changes: 33 additions & 35 deletions src/com/kaylerrenslow/a3plugin/lang/sqf/SQFStatic.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,41 @@ public class SQFStatic {
public static final String DESCRIPTION = Plugin.resources.getString("lang.sqf.description");
static final String FILE_EXTENSION = Plugin.resources.getString("lang.sqf.file_extension");
static final String FILE_EXTENSION_DEFAULT = Plugin.resources.getString("lang.sqf.file_extension_default");

private static final String COMMANDS_DOC_FILE_DIR = "/com/kaylerrenslow/a3plugin/lang/sqf/raw_doc/commands-doc/";
private static final String BIS_FUNCTIONS_DOC_FILE_DIR = "/com/kaylerrenslow/a3plugin/lang/sqf/raw_doc/bis-functions-doc/";

private static final String COMMANDS_DOC_FILE_LOOKUP = COMMANDS_DOC_FILE_DIR + "lookup.list";
private static final String BIS_FUNCTIONS_DOC_FILE_LOOKUP = BIS_FUNCTIONS_DOC_FILE_DIR + "lookup.list";

public static final List<String> LIST_COMMANDS = TextFileListToList.getListFromStream(ResourceGetter.getResourceAsStream(COMMANDS_DOC_FILE_LOOKUP), new ArrayList<>());
public static final List<String> LIST_BIS_FUNCTIONS = TextFileListToList.getListFromStream(ResourceGetter.getResourceAsStream(BIS_FUNCTIONS_DOC_FILE_LOOKUP), new ArrayList<>());

public static final String SQF_SAMPLE_CODE_TEXT = FileReader.getText("/com/kaylerrenslow/a3plugin/lang/sqf/codeStyle/sqfSampleCode.sqf");

private static final String FUNCTION_NAMING_RULE_REGEX = "[a-zA-z_0-9]+_fnc_[a-zA-z_0-9]+"; //don't need to check if the function name starts with a number since that is asserted with the lexer

public static final IElementType[] OPERATORS = {SQFTypes.EQEQ, SQFTypes.EQ, SQFTypes.ASTERISK, SQFTypes.NE, SQFTypes.PERC, SQFTypes.PLUS, SQFTypes.MINUS, SQFTypes.FSLASH, SQFTypes.CARET, SQFTypes.GTGT, SQFTypes.GT, SQFTypes.GE,
SQFTypes.LT, SQFTypes.LE, SQFTypes.EXCL, SQFTypes.AMPAMP, SQFTypes.BARBAR, SQFTypes.QUEST, SQFTypes.COLON};

public static final TokenSet COMMENTS = TokenSet.create(SQFTypes.INLINE_COMMENT);
public static final TokenSet NUMBER_LITERALS = TokenSet.create(SQFTypes.DEC_LITERAL, SQFTypes.INTEGER_LITERAL);
public static final TokenSet IDENTIFIERS = TokenSet.create(SQFTypes.GLOBAL_VAR, SQFTypes.LOCAL_VAR, SQFTypes.VARIABLE);


static {
Collections.sort(LIST_COMMANDS);
Collections.sort(LIST_BIS_FUNCTIONS);
}

public static boolean hasDocumentation(IElementType type) {
if (type == SQFTypes.COMMAND_TOKEN) {
return true;
}
return false;

/** Return true if the given type refers to a command, false otherwise */
public static boolean isCommand(IElementType type) {
return type == SQFTypes.COMMAND_TOKEN || type == SQFTypes.COMMAND;
}

/**
Fetch command syntax for given command. This method will fetch the syntax and params from file and make it readable. Example: "paramName COMMAND paramName2" to "paramName:Number COMMAND paramName2:Number"
@param command command String name
@return syntax with params and param types, or null if the command doesn't have a known syntax
*/
Expand Down Expand Up @@ -88,11 +86,11 @@ public static String getCommandDocSyntax(@NotNull String command) {
// return syntax;
return null;
}


/**
Parses a full function name (e.g. tag_fnc_functionClass) and returns a pair containing the tag name and function class name. Pair first = tag, pair second = function class name
@param fullFunctionName full function name
@return SQFFunctionTagAndName instance
@throws IllegalArgumentException when the function name doesn't follow the function naming requirements
Expand All @@ -107,40 +105,40 @@ public static SQFFunctionTagAndName getFunctionTagAndName(String fullFunctionNam
String functionClassName = fullFunctionName.substring(_fnc_Index + 5); //function's class name.
return new SQFFunctionTagAndName(tagName, functionClassName);
}

/**
Takes a tag and class name and returns the full SQF callable function name (e.g. tag_fnc_className)
@param tag tag
@param functionClassName class name
@return full callable function name
*/
public static String getFullFunctionName(String tag, String functionClassName) {
return tag + "_fnc_" + functionClassName;
}

/**
Returns the file name for the given sqf config function class name
@param functionClassName name to get file name for
@return fn_functionClassName.sqf
*/
public static String getConfigFunctionFileName(String functionClassName) {
return "fn_" + functionClassName + ".sqf";
}

/**
Checks if the given variable name follows the general rules of function naming (requires tag, _fnc_ and then an identifier).
<p>Examples: tag_fnc_function, sj_fnc_function2</p>
<p>Counter Examples: tag_fn_c_function, sj_nc_function2, potatoes, _fnc_function</p>
@param variable Variable to test
@return true if matches, false if it doesn't
*/
public static boolean followsSQFFunctionNameRules(@NotNull String variable) {
return variable.matches(FUNCTION_NAMING_RULE_REGEX); //don't need to explicitly check if a number starts the variable name since that is asserted by the lexer
}

/**
Return true if the given var name is a BIS function, false if it isn't.
*/
Expand All @@ -150,35 +148,35 @@ public static boolean isBisFunction(String varName) {
}
return Collections.binarySearch(LIST_BIS_FUNCTIONS, varName) >= 0;
}

/**
Checks if the given variable name is possibly a BIS function (varName starts with BIS_).
@param varName variable name to check
@return true if starts with BIS_, false otherwise
*/
public static boolean isMaybeBISFunction(String varName) {
String bis = "BIS_";
return varName.startsWith(bis);
}

public static String getCommandDocumentation(String commandName) {
return FileReader.getText(getDocumentationFilePath(commandName));
}

private static String getDocumentationFilePath(String commandName) {
return COMMANDS_DOC_FILE_DIR + commandName;
}

public static String getBISFunctionDocumentation(String bisFunction) {
return FileReader.getText(BIS_FUNCTIONS_DOC_FILE_DIR + bisFunction);
}


public static class SQFFunctionTagAndName {
public final String tagName;
public final String functionClassName;

public SQFFunctionTagAndName(String tagName, String functionClassName) {
this.tagName = tagName;
this.functionClassName = functionClassName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ protected void addCompletions(@NotNull CompletionParameters parameters, Processi
if (cursor == null) {
return;
}
int caretPos = parameters.getEditor().getCaretModel().getPrimaryCaret().getOffset();
String docText = parameters.getEditor().getDocument().getText();
String subText = docText.substring(caretPos - 1, cursor.getTextLength());
if (subText.startsWith("@")) {
String commentText = cursor.getText();
int caretPos = parameters.getEditor().getCaretModel().getPrimaryCaret().getOffset() - cursor.getTextOffset();
if (commentText.charAt(caretPos - 1) == '@') {
result.addElement(new CompletionElementWithTextReplace("@command", "command", 7, Plugin.resources.getString("lang.shared.auto_completion.tags.trail_text.command")).getLookupElement(parameters, context, result));
result.addElement(new CompletionElementWithTextReplace("@bis", "bis", 3, Plugin.resources.getString("lang.shared.auto_completion.tags.trail_text.bis")).getLookupElement(parameters, context, result));
result.addElement(new CompletionElementWithTextReplace("@fnc", "fnc", 3, Plugin.resources.getString("lang.shared.auto_completion.tags.trail_text.fnc")).getLookupElement(parameters, context, result));
Expand Down
Loading

0 comments on commit 2326480

Please sign in to comment.