Correct naming of TexCommand parameter class Change-Id: Ie6b82597819414417aead439792cff7e73c607ec
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/ast/LtxParser.java b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/ast/LtxParser.java index 6db5a91..91865b2 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/ast/LtxParser.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/ast/LtxParser.java
@@ -41,10 +41,10 @@ import org.eclipse.statet.jcommons.text.core.input.TextParserInput; import org.eclipse.statet.docmlet.tex.core.TexCore; -import org.eclipse.statet.docmlet.tex.core.commands.Argument; import org.eclipse.statet.docmlet.tex.core.commands.EnvDefinitions; import org.eclipse.statet.docmlet.tex.core.commands.LtxCommandDefinitions; import org.eclipse.statet.docmlet.tex.core.commands.TexCommand; +import org.eclipse.statet.docmlet.tex.core.commands.TexCommand.Parameter; import org.eclipse.statet.docmlet.tex.core.commands.TexCommandSet; import org.eclipse.statet.docmlet.tex.core.commands.TexEmbedCommand; import org.eclipse.statet.docmlet.tex.core.parser.CustomScanner; @@ -376,11 +376,11 @@ private void putToStack(final byte type, final byte argContent) { switch (argContent & 0xf0) { - case Argument.CONTROLWORD: - case Argument.LABEL: + case Parameter.CONTROLWORD: + case Parameter.LABEL: putToStack(type, LABEL_TEXT); break; - case Argument.NUM: + case Parameter.NUM: putToStack(type, NUM_TEXT); break; default: @@ -784,13 +784,13 @@ } this.lexer.setReportAsterisk(false); } - List<Argument> arguments; - if (!(arguments= command.getArguments()).isEmpty()) { + List<Parameter> parameters; + if (!(parameters= command.getParameters()).isEmpty()) { int nextArg= 0; final List<TexAstNode> children= new ArrayList<>(); - ARGUMENTS: while (this.foundEndStackPos < 0 && nextArg < arguments.size()) { - Argument argument= arguments.get(nextArg); - boolean optional= ((argument.getType() & Argument.OPTIONAL) != 0); + ARGUMENTS: while (this.foundEndStackPos < 0 && nextArg < parameters.size()) { + Parameter parameter= parameters.get(nextArg); + boolean optional= ((parameter.getType() & Parameter.OPTIONAL) != 0); final ContainerNode argNode; switch (this.lexer.pop()) { case LtxLexer.WHITESPACE: @@ -812,8 +812,8 @@ argNode= new Group.Square(controlNode, this.lexer.getOffset(), this.lexer.getStopOffset()); children.add(argNode); this.lexer.consume(); - putToStack(ST_SQUARED, argument.getContent()); - if (argument.getContent() == Argument.EMBEDDED) { + putToStack(ST_SQUARED, parameter.getContent()); + if (parameter.getContent() == Parameter.EMBEDDED) { consumeEmbedGroup(argNode, (TexEmbedCommand)command, nextArg); } else { @@ -825,13 +825,13 @@ continue ARGUMENTS; case LtxLexer.CURLY_BRACKET_OPEN: while (optional) { - if (++nextArg >= arguments.size()) { + if (++nextArg >= parameters.size()) { break ARGUMENTS; } - argument= arguments.get(nextArg); - optional= (argument.getType() == Argument.OPTIONAL); + parameter= parameters.get(nextArg); + optional= (parameter.getType() == Parameter.OPTIONAL); } - if (argument.getType() != Argument.REQUIRED) { + if (parameter.getType() != Parameter.REQUIRED) { break ARGUMENTS; } @@ -839,8 +839,8 @@ argNode= new Group.Bracket(controlNode, this.lexer.getOffset(), this.lexer.getStopOffset()); children.add(argNode); this.lexer.consume(); - putToStack(ST_CURLY, argument.getContent()); - if (argument.getContent() == Argument.EMBEDDED) { + putToStack(ST_CURLY, parameter.getContent()); + if (parameter.getContent() == Parameter.EMBEDDED) { consumeEmbedGroup(argNode, (TexEmbedCommand)command, nextArg); } else { @@ -855,7 +855,7 @@ label= argNode.children[0].getText() ); if (envCommand != null) { command= envCommand; - arguments= command.getArguments(); + parameters= command.getParameters(); } } else { @@ -1070,13 +1070,13 @@ if (requiredArgs < 0) { requiredArgs= 0; } - final var args= new @NonNull Argument[optionalArgs + requiredArgs]; + final var args= new @NonNull Parameter[optionalArgs + requiredArgs]; { int i= 0; while (optionalArgs-- > 0) { - args[i++]= new Argument(Argument.OPTIONAL, Argument.NONE); + args[i++]= new Parameter(Parameter.OPTIONAL, Parameter.NONE); } while (requiredArgs-- > 0) { - args[i++]= new Argument(Argument.REQUIRED, Argument.NONE); + args[i++]= new Parameter(Parameter.REQUIRED, Parameter.NONE); } } { Map<String, TexCommand> map;
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/ast/TexAsts.java b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/ast/TexAsts.java index 037de10..a9a7ec2 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/ast/TexAsts.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/ast/TexAsts.java
@@ -14,6 +14,8 @@ package org.eclipse.statet.docmlet.tex.core.ast; +import static org.eclipse.statet.jcommons.lang.ObjectUtils.nonNullAssert; + import static org.eclipse.statet.docmlet.tex.core.ast.TexAstStatusConstants.TYPE123_GROUP_NOT_CLOSED; import java.util.List; @@ -23,8 +25,8 @@ import org.eclipse.statet.jcommons.text.core.BasicTextRegion; import org.eclipse.statet.jcommons.text.core.TextRegion; -import org.eclipse.statet.docmlet.tex.core.commands.Argument; import org.eclipse.statet.docmlet.tex.core.commands.EnvDefinitions; +import org.eclipse.statet.docmlet.tex.core.commands.TexCommand.Parameter; import org.eclipse.statet.ltk.ast.core.Asts; import org.eclipse.statet.ltk.core.StatusCodes; @@ -41,12 +43,12 @@ * @return array with the resolved arguments (items can be <code>null</code>) */ public static @Nullable TexAstNode[] resolveArguments(final ControlNode node) { - final List<Argument> arguments= node.getCommand().getArguments(); - final @Nullable TexAstNode[] resolved= new @Nullable TexAstNode[arguments.size()]; + final List<Parameter> parameters= nonNullAssert(node.getCommand()).getParameters(); + final @Nullable TexAstNode[] resolved= new @Nullable TexAstNode[parameters.size()]; int idxArgs= 0, idxValues= 0; while (idxArgs < resolved.length && idxValues < node.getChildCount()) { final TexAstNode child= node.getChild(idxValues); - if ((arguments.get(idxArgs).getType() & Argument.OPTIONAL) != 0) { + if ((parameters.get(idxArgs).getType() & Parameter.OPTIONAL) != 0) { if (child.getText() == "[") { //$NON-NLS-1$ idxValues++; resolved[idxArgs++]= child; @@ -81,11 +83,12 @@ public static int getIndexAt(final @Nullable TexAstNode[] nodes, final int offset) { int insert= 0; for (int i= 0; i < nodes.length; i++) { - if (nodes[i] != null) { - if (offset < nodes[i].getStartOffset()) { + final var node= nodes[i]; + if (node != null) { + if (offset < node.getStartOffset()) { break; } - if (offset <= nodes[i].getEndOffset()) { + if (offset <= node.getEndOffset()) { return i; } insert= i + 1;
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/Argument.java b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/Argument.java deleted file mode 100644 index d19d825..0000000 --- a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/Argument.java +++ /dev/null
@@ -1,102 +0,0 @@ -/*=============================================================================# - # Copyright (c) 2009, 2021 Stephan Wahlbrink and others. - # - # This program and the accompanying materials are made available under the - # terms of the Eclipse Public License 2.0 which is available at - # https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - # which is available at https://www.apache.org/licenses/LICENSE-2.0. - # - # SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - # - # Contributors: - # Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation - #=============================================================================*/ - -package org.eclipse.statet.docmlet.tex.core.commands; - -import org.eclipse.statet.jcommons.lang.NonNullByDefault; -import org.eclipse.statet.jcommons.lang.Nullable; - - -@NonNullByDefault -public final class Argument { - - - public static final byte NONE= 0b00000000; - - public static final byte REQUIRED= 0b00000001; - public static final byte OPTIONAL= 0b00000010; -// public static final byte ROUND= 0b00000100; - - public static final byte TITLE= (byte) 0x11; - - public static final byte CONTROLWORD= (byte) 0x20; - - public static final byte LABEL= (byte) 0x30; - public static final byte LABEL_ENV= (byte) 0x31; - public static final byte LABEL_REFLABEL_DEF= (byte) 0x32; - public static final byte LABEL_REFLABEL_REF= (byte) 0x33; - public static final byte LABEL_COUNTER_DEF= (byte) 0x34; - public static final byte LABEL_COUNTER_SET= (byte) 0x35; - public static final byte LABEL_COUNTER_REF= (byte) 0x36; - public static final byte LABEL_BIB_DEF= (byte) 0x38; - public static final byte LABEL_BIB_REF= (byte) 0x39; - - public static final byte RESOURCE= (byte) 0x40; - public static final byte RESOURCE_SINGLE= (byte) 0x41; - public static final byte RESOURCE_LIST= (byte) 0x42; - - public static final byte NUM= (byte) 0x50; - - public static final byte POS= (byte) 0x7f; - public static final byte LOC= (byte) 0x7f; - - public static final byte EMBEDDED= (byte) 0xf1; - - - private final @Nullable String label; - private final byte type; - private final byte content; - - - public Argument(final byte type, final byte content) { - this.label= null; - this.type= type; - this.content= content; - } - - public Argument(final String label, final byte type, final byte content) { - this.label= label; - this.type= type; - this.content= content; - } - - - public @Nullable String getLabel() { - return this.label; - } - - public byte getType() { - return this.type; - } - - public boolean isRequired() { - return ((this.type & REQUIRED) != 0); - } - - public boolean isOptional() { - return ((this.type & OPTIONAL) != 0); - } - - public byte getContent() { - return this.content; - } - - - @Override - public String toString() { - return String.format("%s (type= 0x%02x, content= 0x%02x)", //$NON-NLS-1$ - this.label, this.type, this.content ); - } - -}
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/DivDocDefinitions.java b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/DivDocDefinitions.java index a761825..1764603 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/DivDocDefinitions.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/DivDocDefinitions.java
@@ -27,6 +27,8 @@ import org.eclipse.statet.jcommons.collections.ImCollections; import org.eclipse.statet.jcommons.lang.NonNullByDefault; +import org.eclipse.statet.docmlet.tex.core.commands.TexCommand.Parameter; + @NonNullByDefault public interface DivDocDefinitions { @@ -34,23 +36,23 @@ TexCommand DOCUMENT_input_COMMAND= new TexCommand(C2_DOCUMENT_INCLUDE, "input", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("file", Argument.REQUIRED, Argument.RESOURCE_SINGLE) + new Parameter("file", Parameter.REQUIRED, Parameter.RESOURCE_SINGLE) ), "Insert the content of the given file into the document"); TexCommand DOCUMENT_insert_COMMAND= new TexCommand(C2_DOCUMENT_INCLUDE, "insert", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("file", Argument.REQUIRED, Argument.RESOURCE_SINGLE) + new Parameter("file", Parameter.REQUIRED, Parameter.RESOURCE_SINGLE) ), "Includes the content of the given file with page feed into the document"); TexCommand DOCUMENT_includegraphics_COMMAND= new TexCommand(C3_DOCUMENT_ELEMENT_IMAGES, "includegraphics", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("options", Argument.OPTIONAL, Argument.NONE), - new Argument("file", Argument.REQUIRED, Argument.RESOURCE_SINGLE) + new Parameter("options", Parameter.OPTIONAL, Parameter.NONE), + new Parameter("file", Parameter.REQUIRED, Parameter.RESOURCE_SINGLE) ), "Includes the graphic of the given file into the document"); TexCommand DOCUMENT_item_COMMAND= new TexCommand(C3_DOCUMENT_ELEMENT_LISTS, "item", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("symbol/term", Argument.OPTIONAL, Argument.NONE) + new Parameter("symbol/term", Parameter.OPTIONAL, Parameter.NONE) ), "Adds a new item to the list"); TexCommand DOCUMENT_hline_COMMAND= new TexCommand(C3_DOCUMENT_ELEMENT_TABLES, @@ -62,15 +64,15 @@ TexCommand DOCUMENT_addcontentsline_COMMAND= new TexCommand(C3_DOCUMENT_CONTENTLISTS_DEF, "addcontentsline", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("content list", Argument.REQUIRED, Argument.NONE), - new Argument("type of entry", Argument.REQUIRED, Argument.NONE), - new Argument("entry", Argument.REQUIRED, Argument.NONE) + new Parameter("content list", Parameter.REQUIRED, Parameter.NONE), + new Parameter("type of entry", Parameter.REQUIRED, Parameter.NONE), + new Parameter("entry", Parameter.REQUIRED, Parameter.NONE) ), "Adds an extra entry to a content list (toc, lof, lot, ...)"); TexCommand DOCUMENT_caption_COMMAND= new TexCommand(C3_DOCUMENT_CONTENTLISTS_DEF, "caption", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("short caption", Argument.OPTIONAL, Argument.NONE), - new Argument("caption", Argument.REQUIRED, Argument.NONE) + new Parameter("short caption", Parameter.OPTIONAL, Parameter.NONE), + new Parameter("caption", Parameter.REQUIRED, Parameter.NONE) ), "Adds a caption for the surrounding element"); TexCommand DOCUMENT_tableofcontents_COMMAND= new TexCommand(C3_DOCUMENT_CONTENTLISTS_GEN, @@ -85,7 +87,7 @@ TexCommand DOCUMENT_index_COMMAND= new TexCommand(C3_DOCUMENT_INDEX_DEF, "index", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("keyword", Argument.REQUIRED, Argument.NONE) + new Parameter("keyword", Parameter.REQUIRED, Parameter.NONE) ), "Adds an entry to the index referring to the current position"); TexCommand DOCUMENT_printindex_COMMAND= new TexCommand(C3_DOCUMENT_INDEX_GEN, @@ -94,12 +96,12 @@ TexCommand DOCUMENT_vspace_COMMAND= new TexCommand(C2_DOCUMENT_LAYOUT, "vspace", true, ImCollections.newList( //$NON-NLS-1$ - new Argument("length", Argument.REQUIRED, Argument.NONE) + new Parameter("length", Parameter.REQUIRED, Parameter.NONE) ), "Adds vertical space at the current positition"); TexCommand DOCUMENT_hspace_COMMAND= new TexCommand(C2_DOCUMENT_LAYOUT, "hspace", true, ImCollections.newList( //$NON-NLS-1$ - new Argument("length", Argument.REQUIRED, Argument.NONE) + new Parameter("length", Parameter.REQUIRED, Parameter.NONE) ), "Adds horizontal space at the current position");
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/EnvDefinitions.java b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/EnvDefinitions.java index 234adef..f03976f 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/EnvDefinitions.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/EnvDefinitions.java
@@ -34,12 +34,14 @@ import org.eclipse.statet.jcommons.collections.ImCollections; import org.eclipse.statet.jcommons.lang.NonNullByDefault; +import org.eclipse.statet.docmlet.tex.core.commands.TexCommand.Parameter; + @NonNullByDefault public interface EnvDefinitions { - Argument GENERICENV_ENVLABEL_ARGUMENT= new Argument("environment name", Argument.REQUIRED, Argument.LABEL_ENV); + Parameter GENERICENV_ENVLABEL_ARGUMENT= new Parameter("environment name", Parameter.REQUIRED, Parameter.LABEL_ENV); TexCommand GENERICENV_begin_COMMAND= new TexCommand(C2_GENERICENV_BEGIN, @@ -108,12 +110,12 @@ TexCommand ENV_alignat_BEGIN= new TexCommand(C3_ENV_MATH_DISPLAY_BEGIN, "alignat", false, ImCollections.newList( //$NON-NLS-1$ GENERICENV_ENVLABEL_ARGUMENT, - new Argument("number of columns", Argument.REQUIRED, Argument.NUM) + new Parameter("number of columns", Parameter.REQUIRED, Parameter.NUM) ), "Multiple Equation Math Environment, numbered, with mutual alignment" ); TexCommand ENV_alignatA_BEGIN= new TexCommand(C3_ENV_MATH_DISPLAY_BEGIN, "alignat*", false, ImCollections.newList( //$NON-NLS-1$ GENERICENV_ENVLABEL_ARGUMENT, - new Argument("number of columns", Argument.REQUIRED, Argument.NUM) + new Parameter("number of columns", Parameter.REQUIRED, Parameter.NUM) ), "Multiple Equation Math Environment, nonnumbered, with mutual alignment" ); TexCommand ENV_math_BEGIN_SHORTHAND= new TexCommand(0, "(", @@ -184,8 +186,8 @@ TexCommand ENV_tabular_BEGIN= new TexCommand(C3_ENV_ELEMENT_TABLES_BEGIN, "tabular", false, ImCollections.newList( //$NON-NLS-1$ GENERICENV_ENVLABEL_ARGUMENT, - new Argument(Argument.OPTIONAL, Argument.POS), - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.OPTIONAL, Parameter.POS), + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Table Structure Environment" ); TexCommand ENV_tabbing_BEGIN= new TexCommand(C3_ENV_ELEMENT_TABLES_BEGIN, "tabbing", false, ImCollections.newList( //$NON-NLS-1$ @@ -200,12 +202,12 @@ TexCommand ENV_table_BEGIN= new TexCommand(C3_ENV_ELEMENT_FLOATS_BEGIN, "table", false, ImCollections.newList( //$NON-NLS-1$ GENERICENV_ENVLABEL_ARGUMENT, - new Argument("location", Argument.OPTIONAL, Argument.LOC) + new Parameter("location", Parameter.OPTIONAL, Parameter.LOC) ), "Table Float Environment" ); TexCommand ENV_figure_BEGIN= new TexCommand(C3_ENV_ELEMENT_FLOATS_BEGIN, "figure", false, ImCollections.newList( //$NON-NLS-1$ GENERICENV_ENVLABEL_ARGUMENT, - new Argument("location", Argument.OPTIONAL, Argument.LOC) + new Parameter("location", Parameter.OPTIONAL, Parameter.LOC) ), "Figure Float Environment" ); TexCommand ENV_center_BEGIN= new TexCommand(C3_ENV_ELEMENT_ALIGN_BEGIN, @@ -224,14 +226,14 @@ TexCommand ENV_thebibliography_BEGIN= new TexCommand(C2_ENV_OTHER_BEGIN, "thebibliography", false, ImCollections.newList( //$NON-NLS-1$ GENERICENV_ENVLABEL_ARGUMENT, - new Argument("prototype for label", Argument.REQUIRED, Argument.NONE) + new Parameter("prototype for label", Parameter.REQUIRED, Parameter.NONE) ), "Centered Aligning Environment" ); TexCommand ENV_array_BEGIN= new TexCommand(C2_ENV_MATHCONTENT_BEGIN, "array", false, ImCollections.newList( //$NON-NLS-1$ GENERICENV_ENVLABEL_ARGUMENT, - new Argument("position", Argument.OPTIONAL, Argument.POS), - new Argument("columns", Argument.REQUIRED, Argument.NONE) + new Parameter("position", Parameter.OPTIONAL, Parameter.POS), + new Parameter("columns", Parameter.REQUIRED, Parameter.NONE) ), "Array Structure" ); TexCommand ENV_matrix_BEGIN= new TexCommand(C2_ENV_MATHCONTENT_BEGIN, "matrix", false, ImCollections.newList( //$NON-NLS-1$
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/LtxFontCommand.java b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/LtxFontCommand.java index 3775650..609331e 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/LtxFontCommand.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/LtxFontCommand.java
@@ -27,9 +27,9 @@ super(type, word, description); } - public LtxFontCommand(final int type, final String word, final List<Argument> arguments, + public LtxFontCommand(final int type, final String word, final List<Parameter> parameters, final String description) { - super(type, word, false, arguments, description); + super(type, word, false, parameters, description); } }
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/LtxPrintCommand.java b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/LtxPrintCommand.java index d65013a..1a858ab 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/LtxPrintCommand.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/LtxPrintCommand.java
@@ -32,10 +32,10 @@ this.unicode= unicode; } - public LtxPrintCommand(final int type, final String word, final List<Argument> arguments, + public LtxPrintCommand(final int type, final String word, final List<Parameter> parameters, final String description, final String unicode) { - super(type, word, false, arguments, description); + super(type, word, false, parameters, description); this.unicode= unicode; }
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/MathStylingDefinitions.java b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/MathStylingDefinitions.java index a9df3d1..4aa355e 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/MathStylingDefinitions.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/MathStylingDefinitions.java
@@ -19,6 +19,8 @@ import org.eclipse.statet.jcommons.collections.ImCollections; import org.eclipse.statet.jcommons.lang.NonNullByDefault; +import org.eclipse.statet.docmlet.tex.core.commands.TexCommand.Parameter; + @NonNullByDefault public interface MathStylingDefinitions { @@ -26,31 +28,31 @@ TexCommand STYLE_mathnormal_COMMAND= new LtxFontCommand(C2_STYLE_MATH, "mathnormal", ImCollections.newList( - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints given text using Normal Math font" ); // 2e TexCommand STYLE_mathrm_COMMAND= new LtxFontCommand(C2_STYLE_MATH, "mathrm", ImCollections.newList( - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints given text using Roman Typeface font family" ); // 2e TexCommand STYLE_mathsf_COMMAND= new LtxFontCommand(C2_STYLE_MATH, "mathsf", ImCollections.newList( - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints given text using Sans-Serif Typeface font family" ); // 2e TexCommand STYLE_mathtt_COMMAND= new LtxFontCommand(C2_STYLE_MATH, "mathtt", ImCollections.newList( - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints given text using Typewriter-like Face font family" ); // 2e TexCommand STYLE_mathcal_COMMAND= new LtxFontCommand(C2_STYLE_MATH, "mathcal", ImCollections.newList( - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints given text using Calligraphic font family" ); // 2e TexCommand STYLE_mathbf_COMMAND= new LtxFontCommand(C2_STYLE_MATH, "mathbf", ImCollections.newList( - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints given text using Bold Weight font series" ); // 2e TexCommand STYLE_mathit_COMMAND= new LtxFontCommand(C2_STYLE_MATH, "mathit", ImCollections.newList( - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints given text using Italic font shape" ); // 2e
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/MathSymbolDefinitions.java b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/MathSymbolDefinitions.java index 21875ec..451aee7 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/MathSymbolDefinitions.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/MathSymbolDefinitions.java
@@ -32,6 +32,8 @@ import org.eclipse.statet.jcommons.collections.ImCollections; import org.eclipse.statet.jcommons.lang.NonNullByDefault; +import org.eclipse.statet.docmlet.tex.core.commands.TexCommand.Parameter; + @NonNullByDefault public interface MathSymbolDefinitions { @@ -215,23 +217,23 @@ //-- Roots, Fractions, ... -- TexCommand MATHSYMBOL_sqrt_COMMAND= new TexCommand(C3_MATHSYMBOL_OP_ROOTFRAC, "sqrt", false, ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.OPTIONAL, Argument.NONE), - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.OPTIONAL, Parameter.NONE), + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints Root of given value and optional radix" ); // std TexCommand MATHSYMBOL_frac_COMMAND= new TexCommand(C3_MATHSYMBOL_OP_ROOTFRAC, "frac", false, ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE), - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE), + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints Fraction of given numerator and denominator" ); // std TexCommand MATHSYMBOL_dfrac_COMMAND= new TexCommand(C3_MATHSYMBOL_OP_ROOTFRAC, "dfrac", false, ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE), - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE), + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints Fraction (display-style sized) of given numerator and denominator" ); // std TexCommand MATHSYMBOL_tfrac_COMMAND= new TexCommand(C3_MATHSYMBOL_OP_ROOTFRAC, "tfrac", false, ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE), - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE), + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints Fraction (text-style sized) of given numerator and denominator" ); // std //-- Rel Std -- @@ -687,59 +689,59 @@ //-- Accents -- TexCommand MATHSYMBOL_grave_COMMAND= new LtxPrintCommand(C3_MATHSYMBOL_ACCENTS_, "grave", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints accent Grave above given text", "\u0300" ); // std \u02CB TexCommand MATHSYMBOL_acute_COMMAND= new LtxPrintCommand(C3_MATHSYMBOL_ACCENTS_, "acute", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints accent Acute above given text", "\u0301" ); // std u02CA TexCommand MATHSYMBOL_hat_COMMAND= new LtxPrintCommand(C3_MATHSYMBOL_ACCENTS_, "hat", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints accent Circumflex (hat) above given text", "\u0302" ); // std u02C6 TexCommand MATHSYMBOL_tilde_COMMAND= new LtxPrintCommand(C3_MATHSYMBOL_ACCENTS_, "tilde", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints Tilde above given text", "\u0303" ); // std u02DC TexCommand MATHSYMBOL_bar_COMMAND= new LtxPrintCommand(C3_MATHSYMBOL_ACCENTS_, "bar", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints Macron (bar) above given text", "\u0304" ); // std u00AF TexCommand MATHSYMBOL_overline_COMMAND= new LtxPrintCommand(C3_MATHSYMBOL_ACCENTS_, "overline", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints Line above given text", "\u0305" ); // std u00AF TexCommand MATHSYMBOL_breve_COMMAND= new LtxPrintCommand(C3_MATHSYMBOL_ACCENTS_, "breve", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints Breve above given text", "\u0306" ); // std u02D8 TexCommand MATHSYMBOL_check_COMMAND= new LtxPrintCommand(C3_MATHSYMBOL_ACCENTS_, "check", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints Carot (inversed hat) above given text", "\u030C" ); // std u02C7 TexCommand MATHSYMBOL_dot_COMMAND= new LtxPrintCommand(C3_MATHSYMBOL_ACCENTS_, "dot", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints Dot above given text", "\u0307" ); // std u02D9 TexCommand MATHSYMBOL_ddot_COMMAND= new LtxPrintCommand(C3_MATHSYMBOL_ACCENTS_, "ddot", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints Diaeresis (two dots) above given text", "\u0308" ); // std u00A8 TexCommand MATHSYMBOL_dddot_COMMAND= new LtxPrintCommand(C3_MATHSYMBOL_ACCENTS_, "dddot", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints Three Dots above given text", "\u20DB" ); // ams TexCommand MATHSYMBOL_vec_COMMAND= new LtxPrintCommand(C3_MATHSYMBOL_ACCENTS_, "vec", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints Vector indicator/Right Arrow above given text", "\u20D7" ); // std TexCommand MATHSYMBOL_widehat_COMMAND= new LtxPrintCommand(C3_MATHSYMBOL_ACCENTS_, "widehat", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints wide accent Circumflex (hat) above given text", null ); // std TexCommand MATHSYMBOL_widetilde_COMMAND= new LtxPrintCommand(C3_MATHSYMBOL_ACCENTS_, "widetilde", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints wide Tilde above given text", null ); // std
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/PreambleDefinitions.java b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/PreambleDefinitions.java index e6bb788..826546a 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/PreambleDefinitions.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/PreambleDefinitions.java
@@ -23,6 +23,8 @@ import org.eclipse.statet.jcommons.collections.ImCollections; import org.eclipse.statet.jcommons.lang.NonNullByDefault; +import org.eclipse.statet.docmlet.tex.core.commands.TexCommand.Parameter; + @NonNullByDefault public interface PreambleDefinitions { @@ -30,77 +32,77 @@ TexCommand PREAMBLE_documentclass_COMMAND= new TexCommand(C2_PREAMBLE_DOCDEF, "documentclass", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("options", Argument.OPTIONAL, Argument.NONE), - new Argument("class", Argument.REQUIRED, Argument.NONE) + new Parameter("options", Parameter.OPTIONAL, Parameter.NONE), + new Parameter("class", Parameter.REQUIRED, Parameter.NONE) ), "Sets the class of the document" ); TexCommand PREAMBLE_usepackage_COMMAND= new TexCommand(C2_PREAMBLE_DOCDEF, "usepackage", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("options", Argument.OPTIONAL, Argument.NONE), - new Argument("package name", Argument.REQUIRED, Argument.NONE) + new Parameter("options", Parameter.OPTIONAL, Parameter.NONE), + new Parameter("package name", Parameter.REQUIRED, Parameter.NONE) ), "Loads given package into use" ); TexCommand PREAMBLE_title_COMMAND= new TexCommand(C2_PREAMBLE_DOCDEF, "title", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("title", Argument.REQUIRED, Argument.TITLE) + new Parameter("title", Parameter.REQUIRED, Parameter.TITLE) ), "Sets the title of the document" ); TexCommand PREAMBLE_author_COMMAND= new TexCommand(C2_PREAMBLE_DOCDEF, "author", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("author", Argument.REQUIRED, Argument.TITLE) + new Parameter("author", Parameter.REQUIRED, Parameter.TITLE) ), "Sets the author of the document" ); TexCommand PREAMBLE_date_COMMAND= new TexCommand(C2_PREAMBLE_DOCDEF, "date", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("date", Argument.REQUIRED, Argument.TITLE) + new Parameter("date", Parameter.REQUIRED, Parameter.TITLE) ), "Sets the date of the document" ); TexCommand PREAMBLE_newcommand_COMMAND= new TexCommand(C3_PREAMBLE_CONTROLDEF_COMMAND, "newcommand", true, ImCollections.newList( //$NON-NLS-1$ - new Argument("command", Argument.REQUIRED, Argument.CONTROLWORD), - new Argument("number of arguments", Argument.OPTIONAL, Argument.NUM), - new Argument("default for 1st argument", Argument.OPTIONAL, Argument.NONE), - new Argument("definition", Argument.REQUIRED, Argument.NONE) + new Parameter("command", Parameter.REQUIRED, Parameter.CONTROLWORD), + new Parameter("number of arguments", Parameter.OPTIONAL, Parameter.NUM), + new Parameter("default for 1st argument", Parameter.OPTIONAL, Parameter.NONE), + new Parameter("definition", Parameter.REQUIRED, Parameter.NONE) ), "Defines a new command" ); TexCommand PREAMBLE_renewcommand_COMMAND= new TexCommand(C3_PREAMBLE_CONTROLDEF_COMMAND, "renewcommand", true, ImCollections.newList( //$NON-NLS-1$ - new Argument("command", Argument.REQUIRED, Argument.CONTROLWORD), - new Argument("number of arguments", Argument.OPTIONAL, Argument.NUM), - new Argument("default for 1st argument", Argument.OPTIONAL, Argument.NONE), - new Argument("definition", Argument.REQUIRED, Argument.NONE) + new Parameter("command", Parameter.REQUIRED, Parameter.CONTROLWORD), + new Parameter("number of arguments", Parameter.OPTIONAL, Parameter.NUM), + new Parameter("default for 1st argument", Parameter.OPTIONAL, Parameter.NONE), + new Parameter("definition", Parameter.REQUIRED, Parameter.NONE) ), "Redefines a command" ); TexCommand PREAMBLE_providecommand_COMMAND= new TexCommand(C3_PREAMBLE_CONTROLDEF_COMMAND, "providecommand", true, ImCollections.newList( //$NON-NLS-1$ - new Argument("command", Argument.REQUIRED, Argument.CONTROLWORD), - new Argument("number of arguments", Argument.OPTIONAL, Argument.NUM), - new Argument("default for 1st argument", Argument.OPTIONAL, Argument.NONE), - new Argument("definition", Argument.REQUIRED, Argument.NONE) + new Parameter("command", Parameter.REQUIRED, Parameter.CONTROLWORD), + new Parameter("number of arguments", Parameter.OPTIONAL, Parameter.NUM), + new Parameter("default for 1st argument", Parameter.OPTIONAL, Parameter.NONE), + new Parameter("definition", Parameter.REQUIRED, Parameter.NONE) ), "Defines a new command if not yet exists" ); TexCommand PREAMBLE_newenvironment_COMMAND= new TexCommand(C3_PREAMBLE_CONTROLDEF_ENV, "newenvironment", true, ImCollections.newList( //$NON-NLS-1$ - new Argument("environment name", Argument.REQUIRED, Argument.CONTROLWORD), - new Argument("number of arguments", Argument.OPTIONAL, Argument.NUM), - new Argument("default for 1st argument", Argument.OPTIONAL, Argument.NONE), - new Argument("definition for begin", Argument.REQUIRED, Argument.NONE), - new Argument("definition for end", Argument.REQUIRED, Argument.NONE) + new Parameter("environment name", Parameter.REQUIRED, Parameter.CONTROLWORD), + new Parameter("number of arguments", Parameter.OPTIONAL, Parameter.NUM), + new Parameter("default for 1st argument", Parameter.OPTIONAL, Parameter.NONE), + new Parameter("definition for begin", Parameter.REQUIRED, Parameter.NONE), + new Parameter("definition for end", Parameter.REQUIRED, Parameter.NONE) ), "Defines a new environment" ); TexCommand PREAMBLE_renewenvironment_COMMAND= new TexCommand(C3_PREAMBLE_CONTROLDEF_ENV, "renewenvironment", true, ImCollections.newList( //$NON-NLS-1$ - new Argument("environment name", Argument.REQUIRED, Argument.CONTROLWORD), - new Argument("number of arguments", Argument.OPTIONAL, Argument.NUM), - new Argument("default for 1st argument", Argument.OPTIONAL, Argument.NONE), - new Argument("definition for begin", Argument.REQUIRED, Argument.NONE), - new Argument("definition for end", Argument.REQUIRED, Argument.NONE) + new Parameter("environment name", Parameter.REQUIRED, Parameter.CONTROLWORD), + new Parameter("number of arguments", Parameter.OPTIONAL, Parameter.NUM), + new Parameter("default for 1st argument", Parameter.OPTIONAL, Parameter.NONE), + new Parameter("definition for begin", Parameter.REQUIRED, Parameter.NONE), + new Parameter("definition for end", Parameter.REQUIRED, Parameter.NONE) ), "Redefines a environment" ); TexCommand PREAMBLE_ensuremath_COMMAND= new TexCommand(C2_PREAMBLE_CONTROLDEF, "ensuremath", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("definition", Argument.REQUIRED, Argument.NONE) + new Parameter("definition", Parameter.REQUIRED, Parameter.NONE) ), "Ensures math-mode for given definition" ); TexCommand PREAMBLE_insertonly_COMMAND= new TexCommand(C2_PREAMBLE_MISC, "insertonly", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("file list", Argument.REQUIRED, Argument.RESOURCE_LIST) + new Parameter("file list", Parameter.REQUIRED, Parameter.RESOURCE_LIST) ), "Specifies which files will be included by \\include" ); TexCommand PREAMBLE_hyphenation_COMMAND= new TexCommand(C2_PREAMBLE_MISC, "hyphenation", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("word list", Argument.REQUIRED, Argument.NONE) + new Parameter("word list", Parameter.REQUIRED, Parameter.NONE) ), "Defines hyphenation for given words" ); }
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/RefDefinitions.java b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/RefDefinitions.java index 2a471f5..1ab006c 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/RefDefinitions.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/RefDefinitions.java
@@ -24,6 +24,8 @@ import org.eclipse.statet.jcommons.collections.ImCollections; import org.eclipse.statet.jcommons.lang.NonNullByDefault; +import org.eclipse.statet.docmlet.tex.core.commands.TexCommand.Parameter; + @NonNullByDefault public interface RefDefinitions { @@ -31,102 +33,102 @@ TexCommand LABEL_label_COMMAND= new TexCommand(C3_LABEL_REFLABEL_DEF, "label", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("marker", Argument.REQUIRED, Argument.LABEL_REFLABEL_DEF) + new Parameter("marker", Parameter.REQUIRED, Parameter.LABEL_REFLABEL_DEF) ), "Marks the current element/line with the given label" ); TexCommand LABEL_ref_COMMAND= new TexCommand(C3_LABEL_REFLABEL_REF, "ref", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("marker", Argument.REQUIRED, Argument.LABEL_REFLABEL_REF) + new Parameter("marker", Parameter.REQUIRED, Parameter.LABEL_REFLABEL_REF) ), "Prints a Reference (number) to the given label" ); TexCommand LABEL_pageref_COMMAND= new TexCommand(C3_LABEL_REFLABEL_REF, "pageref", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("marker", Argument.REQUIRED, Argument.LABEL_REFLABEL_REF) + new Parameter("marker", Parameter.REQUIRED, Parameter.LABEL_REFLABEL_REF) ), "Prints a Page Reference (page number) to the given label" ); TexCommand LABEL_eqref_COMMAND= new TexCommand(C3_LABEL_REFLABEL_REF, "eqref", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("marker", Argument.REQUIRED, Argument.LABEL_REFLABEL_REF) + new Parameter("marker", Parameter.REQUIRED, Parameter.LABEL_REFLABEL_REF) ), "Prints a Reference (number) to the given equation label" ); TexCommand LABEL_newcounter_COMMAND= new TexCommand(C3_LABEL_COUNTER_DEF, "newcounter", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("counter", Argument.REQUIRED, Argument.LABEL_COUNTER_DEF), - new Argument("superordinated counter", Argument.OPTIONAL, Argument.LABEL_COUNTER_REF) + new Parameter("counter", Parameter.REQUIRED, Parameter.LABEL_COUNTER_DEF), + new Parameter("superordinated counter", Parameter.OPTIONAL, Parameter.LABEL_COUNTER_REF) ), "Defines a new counter" ); TexCommand LABEL_setcounter_COMMAND= new TexCommand(C3_LABEL_COUNTER_REF, "setcounter", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("counter", Argument.REQUIRED, Argument.LABEL_COUNTER_SET), - new Argument("value", Argument.REQUIRED, Argument.NONE) + new Parameter("counter", Parameter.REQUIRED, Parameter.LABEL_COUNTER_SET), + new Parameter("value", Parameter.REQUIRED, Parameter.NONE) ), "Sets the counter to the given value" ); TexCommand LABEL_addtocounter_COMMAND= new TexCommand(C3_LABEL_COUNTER_REF, "addtocounter", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("counter", Argument.REQUIRED, Argument.LABEL_COUNTER_SET), - new Argument("value", Argument.REQUIRED, Argument.NONE) + new Parameter("counter", Parameter.REQUIRED, Parameter.LABEL_COUNTER_SET), + new Parameter("value", Parameter.REQUIRED, Parameter.NONE) ), "Increments the counter by the given value" ); TexCommand LABEL_stepcounter_COMMAND= new TexCommand(C3_LABEL_COUNTER_REF, "stepcounter", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("counter", Argument.REQUIRED, Argument.LABEL_COUNTER_SET) + new Parameter("counter", Parameter.REQUIRED, Parameter.LABEL_COUNTER_SET) ), "Increments the counter by one" ); TexCommand LABEL_Alph_COMMAND= new TexCommand(C3_LABEL_COUNTER_REF, "Alph", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("counter", Argument.REQUIRED, Argument.LABEL_COUNTER_REF) + new Parameter("counter", Parameter.REQUIRED, Parameter.LABEL_COUNTER_REF) ), "Prints the current value of the counter in alphabetic uppercase letters (A, B, C,...)" ); TexCommand LABEL_alph_COMMAND= new TexCommand(C3_LABEL_COUNTER_REF, "alph", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("counter", Argument.REQUIRED, Argument.LABEL_COUNTER_REF) + new Parameter("counter", Parameter.REQUIRED, Parameter.LABEL_COUNTER_REF) ), "Prints the current value of the counter in alphabetic lowercase letters (a, b, c,...)" ); TexCommand LABEL_Roman_COMMAND= new TexCommand(C3_LABEL_COUNTER_REF, "Roman", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("counter", Argument.REQUIRED, Argument.LABEL_COUNTER_REF) + new Parameter("counter", Parameter.REQUIRED, Parameter.LABEL_COUNTER_REF) ), "Prints the current value of the counter in uppercase roman numbers (I, II, III,...)" ); TexCommand LABEL_roman_COMMAND= new TexCommand(C3_LABEL_COUNTER_REF, "roman", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("counter", Argument.REQUIRED, Argument.LABEL_COUNTER_REF) + new Parameter("counter", Parameter.REQUIRED, Parameter.LABEL_COUNTER_REF) ), "Prints the current value of the counter in lowercase roman numbers (i, ii, iii,...)" ); TexCommand LABEL_arabic_COMMAND= new TexCommand(C3_LABEL_COUNTER_REF, "arabic", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("counter", Argument.REQUIRED, Argument.LABEL_COUNTER_REF) + new Parameter("counter", Parameter.REQUIRED, Parameter.LABEL_COUNTER_REF) ), "Prints the current value of the counter in arabic numbers (1, 2, 3,...)" ); TexCommand LABEL_value_COMMAND= new TexCommand(C3_LABEL_COUNTER_REF, "value", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("counter", Argument.REQUIRED, Argument.LABEL_COUNTER_REF) + new Parameter("counter", Parameter.REQUIRED, Parameter.LABEL_COUNTER_REF) ), "Returns the current value of the counter as number" ); TexCommand BIB_bibitem_COMMAND= new TexCommand(TexCommand.C2_BIB_DEF, "bibitem", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("label to print", Argument.OPTIONAL, Argument.NONE), - new Argument("key", Argument.REQUIRED, Argument.LABEL_BIB_DEF) + new Parameter("label to print", Parameter.OPTIONAL, Parameter.NONE), + new Parameter("key", Parameter.REQUIRED, Parameter.LABEL_BIB_DEF) ), "Adds an entry to the bibliography" ); TexCommand BIB_cite_COMMAND= new TexCommand(C2_BIB_REF, "cite", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("annotation", Argument.OPTIONAL, Argument.NONE), - new Argument("key", Argument.REQUIRED, Argument.LABEL_BIB_REF) + new Parameter("annotation", Parameter.OPTIONAL, Parameter.NONE), + new Parameter("key", Parameter.REQUIRED, Parameter.LABEL_BIB_REF) ), "Prints a literature reference to the given bibliography entry" ); TexCommand BIB_nocite_COMMAND= new TexCommand(C2_BIB_REF, "nocite", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("key", Argument.REQUIRED, Argument.LABEL_BIB_REF) + new Parameter("key", Parameter.REQUIRED, Parameter.LABEL_BIB_REF) ), "Ensures that the given literature reference appears in the bibliography of the document" ); TexCommand BIB_bibliography_COMMAND= new TexCommand(C2_BIB_INCLUDE, "bibliography", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("files", Argument.REQUIRED, Argument.RESOURCE_LIST) + new Parameter("files", Parameter.REQUIRED, Parameter.RESOURCE_LIST) ), "Includes the given bibliography(s)" ); TexCommand BIB_bibliographystyle_COMMAND= new TexCommand(TexCommand.BIB, "bibliographystyle", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("style", Argument.REQUIRED, Argument.NONE) + new Parameter("style", Parameter.REQUIRED, Parameter.NONE) ), "Includes the given bibliography(s)" );
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TexCommand.java b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TexCommand.java index 2689dbe..b286ffb 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TexCommand.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TexCommand.java
@@ -143,7 +143,90 @@ public static final int C2_BIB_INCLUDE= BIB | 0x30; - private static final List<Argument> NO_ARGUMENTS= Collections.emptyList(); + public static final class Parameter { + + + public static final byte NONE= 0b00000000; + + public static final byte REQUIRED= 0b00000001; + public static final byte OPTIONAL= 0b00000010; + // public static final byte ROUND= 0b00000100; + + public static final byte TITLE= (byte) 0x11; + + public static final byte CONTROLWORD= (byte) 0x20; + + public static final byte LABEL= (byte) 0x30; + public static final byte LABEL_ENV= (byte) 0x31; + public static final byte LABEL_REFLABEL_DEF= (byte) 0x32; + public static final byte LABEL_REFLABEL_REF= (byte) 0x33; + public static final byte LABEL_COUNTER_DEF= (byte) 0x34; + public static final byte LABEL_COUNTER_SET= (byte) 0x35; + public static final byte LABEL_COUNTER_REF= (byte) 0x36; + public static final byte LABEL_BIB_DEF= (byte) 0x38; + public static final byte LABEL_BIB_REF= (byte) 0x39; + + public static final byte RESOURCE= (byte) 0x40; + public static final byte RESOURCE_SINGLE= (byte) 0x41; + public static final byte RESOURCE_LIST= (byte) 0x42; + + public static final byte NUM= (byte) 0x50; + + public static final byte POS= (byte) 0x7f; + public static final byte LOC= (byte) 0x7f; + + public static final byte EMBEDDED= (byte) 0xf1; + + + private final @Nullable String label; + private final byte type; + private final byte content; + + + public Parameter(final byte type, final byte content) { + this.label= null; + this.type= type; + this.content= content; + } + + public Parameter(final String label, final byte type, final byte content) { + this.label= label; + this.type= type; + this.content= content; + } + + + public @Nullable String getLabel() { + return this.label; + } + + public byte getType() { + return this.type; + } + + public boolean isRequired() { + return ((this.type & REQUIRED) != 0); + } + + public boolean isOptional() { + return ((this.type & OPTIONAL) != 0); + } + + public byte getContent() { + return this.content; + } + + + @Override + public String toString() { + return String.format("%s (type= 0x%02x, content= 0x%02x)", //$NON-NLS-1$ + this.label, this.type, this.content ); + } + + } + + + private static final List<Parameter> NO_PARAMS= Collections.emptyList(); /*package*/ static final Collator COLLATOR= Collator.getInstance(Locale.ENGLISH); static { @@ -154,7 +237,7 @@ private final int type; private final String word; private final boolean supportAserisk; - private final List<Argument> arguments; + private final List<Parameter> parameters; private final String description; @@ -162,24 +245,24 @@ public TexCommand(final int type, - final String word, final boolean asterisk, final List<Argument> arguments, + final String word, final boolean asterisk, final List<Parameter> parameters, final @Nullable TexPackage texPackage, final String description) { this.type= type; this.word= word; this.supportAserisk= asterisk; - this.arguments= arguments; + this.parameters= parameters; this.texPackage= texPackage; this.description= description; } public TexCommand(final int type, - final String word, final boolean asterisk, final List<Argument> arguments, + final String word, final boolean asterisk, final List<Parameter> parameters, final String description) { - this(type, word, asterisk, arguments, null, description); + this(type, word, asterisk, parameters, null, description); } public TexCommand(final int type, final String word, final String description) { - this(type, word, false, NO_ARGUMENTS, null, description); + this(type, word, false, NO_PARAMS, null, description); } @@ -195,8 +278,8 @@ return this.supportAserisk; } - public List<Argument> getArguments() { - return this.arguments; + public List<Parameter> getParameters() { + return this.parameters; } public @Nullable TexPackage getPackage() {
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TexEmbedCommand.java b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TexEmbedCommand.java index 5b4e02f..776763e 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TexEmbedCommand.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TexEmbedCommand.java
@@ -30,9 +30,9 @@ public TexEmbedCommand(final int type, final String embeddedType, - final String word, final boolean asterisk, final List<Argument> arguments, + final String word, final boolean asterisk, final List<Parameter> parameters, final String description) { - super(type, word, asterisk, arguments, description); + super(type, word, asterisk, parameters, description); this.embeddedType= embeddedType; }
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TextSectioningDefinitions.java b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TextSectioningDefinitions.java index 4b142c0..3d7e6dd 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TextSectioningDefinitions.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TextSectioningDefinitions.java
@@ -24,6 +24,8 @@ import org.eclipse.statet.jcommons.collections.ImCollections; import org.eclipse.statet.jcommons.lang.NonNullByDefault; +import org.eclipse.statet.docmlet.tex.core.commands.TexCommand.Parameter; + @NonNullByDefault public interface TextSectioningDefinitions { @@ -31,38 +33,38 @@ TexCommand SECTIONING_part_COMMAND= new TexCommand(C2_SECTIONING_PART, "part", true, ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.OPTIONAL, Argument.TITLE), - new Argument(Argument.REQUIRED, Argument.TITLE) + new Parameter(Parameter.OPTIONAL, Parameter.TITLE), + new Parameter(Parameter.REQUIRED, Parameter.TITLE) ), "Starts a new Part" ); TexCommand SECTIONING_chapter_COMMAND= new TexCommand(C2_SECTIONING_CHAPTER, "chapter", true, ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.OPTIONAL, Argument.TITLE), - new Argument(Argument.REQUIRED, Argument.TITLE) + new Parameter(Parameter.OPTIONAL, Parameter.TITLE), + new Parameter(Parameter.REQUIRED, Parameter.TITLE) ), "Starts a new Chapter" ); TexCommand SECTIONING_section_COMMAND= new TexCommand(C2_SECTIONING_SECTION, "section", true, ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.OPTIONAL, Argument.TITLE), - new Argument(Argument.REQUIRED, Argument.TITLE) + new Parameter(Parameter.OPTIONAL, Parameter.TITLE), + new Parameter(Parameter.REQUIRED, Parameter.TITLE) ), "Starts a new Section" ); TexCommand SECTIONING_subsection_COMMAND= new TexCommand(C2_SECTIONING_SUBSECTION, "subsection", true, ImCollections.newList( - new Argument(Argument.OPTIONAL, Argument.TITLE), - new Argument(Argument.REQUIRED, Argument.TITLE) + new Parameter(Parameter.OPTIONAL, Parameter.TITLE), + new Parameter(Parameter.REQUIRED, Parameter.TITLE) ), "Starts a new SubSection" ); TexCommand SECTIONING_subsubsection_COMMAND= new TexCommand(C2_SECTIONING_SUBSUBSECTION, "subsubsection", true, ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.OPTIONAL, Argument.TITLE), - new Argument(Argument.REQUIRED, Argument.TITLE) + new Parameter(Parameter.OPTIONAL, Parameter.TITLE), + new Parameter(Parameter.REQUIRED, Parameter.TITLE) ), "Starts new SubSubSection" ); TexCommand SECTIONING_paragraph_COMMAND= new TexCommand(SECTIONING | 0x60, "paragraph", true, ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.OPTIONAL, Argument.TITLE), - new Argument(Argument.REQUIRED, Argument.TITLE) + new Parameter(Parameter.OPTIONAL, Parameter.TITLE), + new Parameter(Parameter.REQUIRED, Parameter.TITLE) ), "Starts a new Paragraph" ); TexCommand SECTIONING_subparagraph_COMMAND= new TexCommand(SECTIONING | 0x70, "subparagraph", true, ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.OPTIONAL, Argument.TITLE), - new Argument(Argument.REQUIRED, Argument.TITLE) + new Parameter(Parameter.OPTIONAL, Parameter.TITLE), + new Parameter(Parameter.REQUIRED, Parameter.TITLE) ), "Starts a new SubParagraph" );
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TextStylingDefinitions.java b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TextStylingDefinitions.java index 6b35e60..1c77943 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TextStylingDefinitions.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TextStylingDefinitions.java
@@ -22,6 +22,8 @@ import org.eclipse.statet.jcommons.collections.ImCollections; import org.eclipse.statet.jcommons.lang.NonNullByDefault; +import org.eclipse.statet.docmlet.tex.core.commands.TexCommand.Parameter; + @NonNullByDefault public interface TextStylingDefinitions { @@ -40,7 +42,7 @@ TexCommand COMMONFONTS_underline_COMMAND= new LtxFontCommand(C2_STYLE_TEXT, "underline", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Underlines the given text" ); // tex TexCommand COMMONFONTS_rmfamily_COMMAND= new LtxFontCommand(C3_STYLE_TEXT_FONT_O, @@ -66,43 +68,43 @@ TexCommand COMMONFONTS_textrm_COMMAND= new LtxFontCommand(C3_STYLE_TEXT_FONT_B, "textrm", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints given text using Roman Typeface font family" ); // 2e TexCommand COMMONFONTS_textsf_COMMAND= new LtxFontCommand(C3_STYLE_TEXT_FONT_B, "textsf", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints given text using Sans-Serif Typeface font family" ); // 2e TexCommand COMMONFONTS_texttt_COMMAND= new LtxFontCommand(C3_STYLE_TEXT_FONT_B, "texttt", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints given text using Typewriter-like Face font family" ); // 2e TexCommand COMMONFONTS_textmd_COMMAND= new LtxFontCommand(C3_STYLE_TEXT_FONT_B, "textmd", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints given text using Medium Weight font series" ); // 2e TexCommand COMMONFONTS_textbf_COMMAND= new LtxFontCommand(C3_STYLE_TEXT_FONT_B, "textbf", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints given text using Bold Weight font series" ); // 2e TexCommand COMMONFONTS_textup_COMMAND= new LtxFontCommand(C3_STYLE_TEXT_FONT_B, "textup", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints given text using Upright font shape" ); // 2e TexCommand COMMONFONTS_textit_COMMAND= new LtxFontCommand(C3_STYLE_TEXT_FONT_B, "textit", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints given text using Italic font shape" ); // 2e TexCommand COMMONFONTS_textsl_COMMAND= new LtxFontCommand(C3_STYLE_TEXT_FONT_B, "textsl", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints given text using Slated font shape" ); // 2e TexCommand COMMONFONTS_textsc_COMMAND= new LtxFontCommand(C3_STYLE_TEXT_FONT_B, "textsc", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints given text using Small Caps font shape" ); // 2e TexCommand COMMONFONTS_emph_COMMAND= new LtxFontCommand(C3_STYLE_TEXT_FONT_B, "emph", ImCollections.newList( //$NON-NLS-1$ - new Argument(Argument.REQUIRED, Argument.NONE) + new Parameter(Parameter.REQUIRED, Parameter.NONE) ), "Prints given text emphasized" ); // 2e TexCommand COMMONFONTS_tiny_COMMAND= new LtxFontCommand(C3_STYLE_TEXT_SIZE_O,
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TikzPackage.java b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TikzPackage.java index 0158c31..d3a9a5e 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TikzPackage.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/docmlet/tex/core/commands/TikzPackage.java
@@ -24,6 +24,8 @@ import org.eclipse.statet.jcommons.collections.ImList; import org.eclipse.statet.jcommons.lang.NonNullByDefault; +import org.eclipse.statet.docmlet.tex.core.commands.TexCommand.Parameter; + @NonNullByDefault public class TikzPackage extends TexPackage { @@ -42,14 +44,14 @@ this.commands= ImCollections.newList( new TexCommand(C3_ELEMENT_GRAPHIC_PICTURE, "tikz", false, ImCollections.newList( //$NON-NLS-1$ - new Argument("options", Argument.OPTIONAL, Argument.NONE) + new Parameter("options", Parameter.OPTIONAL, Parameter.NONE) ), this, "TikZ Picture (single command)" ) ); this.envs= ImCollections.newList( new TexCommand(TexCommand.C3_ENV_ELEMENT_GRAPHICS_BEGIN, "tikzpicture", false, ImCollections.newList( //$NON-NLS-1$ GENERICENV_ENVLABEL_ARGUMENT, - new Argument("options", Argument.OPTIONAL, Argument.NONE) + new Parameter("options", Parameter.OPTIONAL, Parameter.NONE) ), this, "TikZ Picture" ) ); }
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/internal/docmlet/tex/core/model/SourceAnalyzer.java b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/internal/docmlet/tex/core/model/SourceAnalyzer.java index 2b8da7c..ca41caf 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/internal/docmlet/tex/core/model/SourceAnalyzer.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.core/src/org/eclipse/statet/internal/docmlet/tex/core/model/SourceAnalyzer.java
@@ -394,7 +394,7 @@ case TexCommand.SYMBOL: case TexCommand.MATHSYMBOL: if (command instanceof LtxPrintCommand - && command.getArguments().isEmpty() + && command.getParameters().isEmpty() && this.titleDoBuild) { final String text= ((LtxPrintCommand) command).getText(); if (text != null) {
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/editors/LtxCommandCompletionProposal.java b/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/editors/LtxCommandCompletionProposal.java index 37bac96..dac1c63 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/editors/LtxCommandCompletionProposal.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/editors/LtxCommandCompletionProposal.java
@@ -49,9 +49,9 @@ import org.eclipse.statet.ecommons.ui.util.UIAccess; import org.eclipse.statet.ecommons.ui.viewers.ViewerLabelUtils; -import org.eclipse.statet.docmlet.tex.core.commands.Argument; import org.eclipse.statet.docmlet.tex.core.commands.EnvDefinitions; import org.eclipse.statet.docmlet.tex.core.commands.TexCommand; +import org.eclipse.statet.docmlet.tex.core.commands.TexCommand.Parameter; import org.eclipse.statet.docmlet.tex.core.source.LtxHeuristicTokenScanner; import org.eclipse.statet.docmlet.tex.ui.TexUIResources; import org.eclipse.statet.internal.docmlet.tex.ui.sourceediting.LtxArgumentListContextInformation; @@ -355,8 +355,8 @@ protected StyledString computeStyledText() { final StyledString styledText= new StyledString(((this.command.getType() & TexCommand.MASK_MAIN) == TexCommand.ENV) ? this.command.getControlWord() : "\\" + this.command.getControlWord() ); - for (final Argument arg : this.command.getArguments()) { - if ((arg.getType() & Argument.OPTIONAL) != 0) { + for (final var param : this.command.getParameters()) { + if ((param.getType() & Parameter.OPTIONAL) != 0) { styledText.append("[]"); } else { @@ -405,13 +405,13 @@ mode= 201; } else if ((this.command.getType() & TexCommand.MASK_MAIN) != TexCommand.ENV) { - final List<Argument> args= this.command.getArguments(); - if (args != null && !args.isEmpty()) { - final boolean isFirstOptional= args.get(0).isOptional(); + final List<Parameter> parameters= this.command.getParameters(); + if (parameters != null && !parameters.isEmpty()) { + final boolean isFirstOptional= parameters.get(0).isOptional(); int idxFirstRequired= -1; - for (int i= (isFirstOptional) ? 1 : 0; i < args.size(); i++) { - final Argument arg= args.get(i); - if (arg.isRequired()) { + for (int i= (isFirstOptional) ? 1 : 0; i < parameters.size(); i++) { + final Parameter param= parameters.get(i); + if (param.isRequired()) { idxFirstRequired= i; break; } @@ -441,8 +441,8 @@ } mode++; positions.add(mode++); - for (int i= idxFirstRequired+1; i < args.size(); i++) { - if (args.get(i).isRequired()) { + for (int i= idxFirstRequired+1; i < parameters.size(); i++) { + if (parameters.get(i).isRequired()) { replacement.append("{}"); mode++; positions.add(mode++);
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/editors/LtxElementCompletionComputer.java b/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/editors/LtxElementCompletionComputer.java index a806923..f2660d8 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/editors/LtxElementCompletionComputer.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/editors/LtxElementCompletionComputer.java
@@ -34,11 +34,11 @@ import org.eclipse.statet.docmlet.tex.core.ast.TexAstNode; import org.eclipse.statet.docmlet.tex.core.ast.TexAstStatusConstants; import org.eclipse.statet.docmlet.tex.core.ast.TexAsts; -import org.eclipse.statet.docmlet.tex.core.commands.Argument; import org.eclipse.statet.docmlet.tex.core.commands.EnvDefinitions; import org.eclipse.statet.docmlet.tex.core.commands.LtxCommandDefinitions; import org.eclipse.statet.docmlet.tex.core.commands.PreambleDefinitions; import org.eclipse.statet.docmlet.tex.core.commands.TexCommand; +import org.eclipse.statet.docmlet.tex.core.commands.TexCommand.Parameter; import org.eclipse.statet.docmlet.tex.core.commands.TexCommandSet; import org.eclipse.statet.docmlet.tex.core.model.LtxSourceUnitModelInfo; import org.eclipse.statet.docmlet.tex.core.model.TexElement; @@ -187,19 +187,20 @@ } } } - else if (context instanceof LtxAssistInvocationContext) { - final LtxAssistInvocationContext texContext= context; - final CommandCall commandCall= texContext.getCommandCall(true); - final int argIdx; - if (commandCall != null && (argIdx= commandCall.getInvocationArgIdx()) >= 0) { - final TexCommand command= commandCall.getCommand(); - final Argument argDef= command.getArguments().get(argIdx); - final TexAstNode argNode= commandCall.getArgNode(argIdx); - final int offset= texContext.getInvocationOffset() - prefix.length(); + else { + final CommandCall commandCall= context.getCommandCall(true); + final int argParameterIndex; + final TexAstNode argNode; + if (commandCall != null + && (argParameterIndex= commandCall.getInvocationArgParameterIndex()) >= 0 + && (argNode= commandCall.getArgNode(argParameterIndex)) != null) { + final int offset= context.getInvocationOffset() - prefix.length(); final TextRegion region= TexAsts.getInnerRegion(argNode); if (region != null && region.getStartOffset() <= offset && offset <= region.getEndOffset() ) { - if (argIdx == 0 + final TexCommand command= commandCall.getCommand(); + final Parameter parameter= command.getParameters().get(argParameterIndex); + if (argParameterIndex == 0 && ((command.getType() & TexCommand.MASK_MAIN) == TexCommand.GENERICENV || (command.getType() & TexCommand.MASK_MAIN) == TexCommand.ENV )) { final List<String> prefered= new ArrayList<>(); @@ -224,11 +225,11 @@ } else { if (modelInfo != null) { - switch (argDef.getContent()) { - case Argument.LABEL_REFLABEL_DEF: + switch (parameter.getContent()) { + case Parameter.LABEL_REFLABEL_DEF: addLabelDefProposals(context, argNode, modelInfo.getLabels(), proposals); break; - case Argument.LABEL_REFLABEL_REF: + case Parameter.LABEL_REFLABEL_REF: addLabelRefProposals(context, argNode, modelInfo.getLabels(), proposals); break; }
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/editors/TexPathCompletionComputer.java b/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/editors/TexPathCompletionComputer.java index 4ac64f3..808f812 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/editors/TexPathCompletionComputer.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/editors/TexPathCompletionComputer.java
@@ -28,8 +28,8 @@ import org.eclipse.statet.docmlet.tex.core.ast.TexAstNode; import org.eclipse.statet.docmlet.tex.core.ast.TexAsts; -import org.eclipse.statet.docmlet.tex.core.commands.Argument; import org.eclipse.statet.docmlet.tex.core.commands.TexCommand; +import org.eclipse.statet.docmlet.tex.core.commands.TexCommand.Parameter; import org.eclipse.statet.internal.docmlet.tex.ui.sourceediting.LtxAssistInvocationContext; import org.eclipse.statet.internal.docmlet.tex.ui.sourceediting.LtxAssistInvocationContext.CommandCall; import org.eclipse.statet.ltk.model.core.element.SourceUnit; @@ -98,14 +98,16 @@ if (context instanceof LtxAssistInvocationContext) { final LtxAssistInvocationContext texContext= (LtxAssistInvocationContext)context; final CommandCall commandCall= texContext.getCommandCall(true); - final int argIdx; - if (commandCall != null && (argIdx= commandCall.getInvocationArgIdx()) >= 0) { + final int argParameterIndex; + final TexAstNode argNode; + if (commandCall != null + && (argParameterIndex= commandCall.getInvocationArgParameterIndex()) >= 0 + && (argNode= commandCall.getArgNode(argParameterIndex)) != null) { final TexCommand command= commandCall.getCommand(); - final Argument argDef= command.getArguments().get(argIdx); - final TexAstNode argNode= commandCall.getArgNode(argIdx); + final Parameter param= command.getParameters().get(argParameterIndex); final int offset= texContext.getInvocationOffset(); if (mode == ContentAssistComputer.SPECIFIC_MODE - || (argDef.getContent() & 0xf0) == Argument.RESOURCE ) { + || (param.getContent() & 0xf0) == Parameter.RESOURCE ) { final TextRegion region= TexAsts.getInnerRegion(argNode); if (region != null && region.getStartOffset() >= offset && offset <= region.getEndOffset() ) {
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/sourceediting/LtxArgumentListContextInformation.java b/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/sourceediting/LtxArgumentListContextInformation.java index 3d181be..39cce51 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/sourceediting/LtxArgumentListContextInformation.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/sourceediting/LtxArgumentListContextInformation.java
@@ -17,13 +17,15 @@ import org.eclipse.jface.text.contentassist.IContextInformationExtension; import org.eclipse.swt.graphics.Image; +import org.eclipse.statet.jcommons.collections.ImCollections; +import org.eclipse.statet.jcommons.collections.ImIntList; import org.eclipse.statet.jcommons.collections.IntArrayList; import org.eclipse.statet.jcommons.collections.IntList; import org.eclipse.statet.jcommons.lang.NonNullByDefault; import org.eclipse.statet.jcommons.lang.Nullable; -import org.eclipse.statet.docmlet.tex.core.commands.Argument; import org.eclipse.statet.docmlet.tex.core.commands.TexCommand; +import org.eclipse.statet.docmlet.tex.core.commands.TexCommand.Parameter; import org.eclipse.statet.ltk.ui.sourceediting.assist.AssistInformationProposal; @@ -37,18 +39,20 @@ private final TexCommand command; private final String information; - private final int[] informationArgumentIdxs; + private final ImIntList informationArgumentIndexes; public LtxArgumentListContextInformation(final int offset, final TexCommand command) { this.offset= offset; this.command= command; - final StringBuilder sb= new StringBuilder(); - final IntList idxs= new IntArrayList(); - appendArgumentList(sb, idxs, this.command); - this.information= sb.toString(); - this.informationArgumentIdxs= idxs.toArray(); + { // build information string + final StringBuilder sb= new StringBuilder(); + final IntList idxs= new IntArrayList(); + appendArgumentList(sb, idxs, this.command); + this.information= sb.toString(); + this.informationArgumentIndexes= ImCollections.toIntList(idxs); + } } @@ -58,7 +62,6 @@ public TexCommand getCommand() { return this.command; - } @@ -82,8 +85,13 @@ return this.information; } - public int[] getInformationDisplayStringArgumentIdxs() { - return this.informationArgumentIdxs; + /** + * Returns the indexes of the command parameters in the information display string. + * + * @return list with the indexes + */ + public ImIntList getInformationDisplayStringParameterIndexes() { + return this.informationArgumentIndexes; } @@ -95,19 +103,19 @@ private static void appendArgumentList(final StringBuilder text, final IntList idxs, final TexCommand command) { - for (final Argument arg : command.getArguments()) { + for (final var param : command.getParameters()) { idxs.add(text.length()); - if ((arg.getType() & Argument.OPTIONAL) != 0) { + if ((param.getType() & Parameter.OPTIONAL) != 0) { text.append('['); - if (arg.getLabel() != null) { - text.append(arg.getLabel()); + if (param.getLabel() != null) { + text.append(param.getLabel()); } text.append(']'); } else { text.append('{'); - if (arg.getLabel() != null) { - text.append(arg.getLabel()); + if (param.getLabel() != null) { + text.append(param.getLabel()); } text.append('}'); }
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/sourceediting/LtxAssistInvocationContext.java b/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/sourceediting/LtxAssistInvocationContext.java index 6d0b3fc..4ace5a2 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/sourceediting/LtxAssistInvocationContext.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/sourceediting/LtxAssistInvocationContext.java
@@ -48,14 +48,14 @@ private final ControlNode controlNode; private final @Nullable TexAstNode[] argNodes; - private final int invocationArgIdx; + private final int invocationArgParameterIndex; private CommandCall(final ControlNode controlNode) { nonNullAssert(controlNode.getCommand()); this.controlNode= controlNode; this.argNodes= TexAsts.resolveArguments(controlNode); - this.invocationArgIdx= TexAsts.getIndexAt(this.argNodes, getInvocationOffset()); + this.invocationArgParameterIndex= TexAsts.getIndexAt(this.argNodes, getInvocationOffset()); } @@ -74,19 +74,19 @@ /** * Returns the node of the argument. - * @param argIdx the index of the argument + * @param parameterIndex the index of the argument * @return the list with ast nodes */ - public final @Nullable TexAstNode getArgNode(final int argIdx) { - return this.argNodes[argIdx]; + public final @Nullable TexAstNode getArgNode(final int parameterIndex) { + return this.argNodes[parameterIndex]; } /** * Returns the index of the argument at the {@link LtxAssistInvocationContext#getInvocationOffset() invocation offset}. * @return the index of the argument */ - public final int getInvocationArgIdx() { - return this.invocationArgIdx; + public final int getInvocationArgParameterIndex() { + return this.invocationArgParameterIndex; } }
diff --git a/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/sourceediting/LtxContextInformationValidator.java b/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/sourceediting/LtxContextInformationValidator.java index ccd783d..50f43f4 100644 --- a/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/sourceediting/LtxContextInformationValidator.java +++ b/docmlet/org.eclipse.statet.docmlet.tex.ui/src/org/eclipse/statet/internal/docmlet/tex/ui/sourceediting/LtxContextInformationValidator.java
@@ -113,18 +113,19 @@ if (info == null) { return false; } - if (info.getCommand().getArguments().size() > 0) { - final int argIdx= getCurrentArgInDef(offset); - final int[] idxs= info.getInformationDisplayStringArgumentIdxs(); - if (argIdx >= 0 && argIdx < idxs.length) { - if (argIdx == this.lastPresentation) { + if (info.getCommand().getParameters().size() > 0) { + final int argParameterIdx= getCurrentArgParameterIdx(offset); + final var indexes= info.getInformationDisplayStringParameterIndexes(); + if (argParameterIdx >= 0 && argParameterIdx < indexes.size()) { + if (argParameterIdx == this.lastPresentation) { return false; } - final int start= idxs[argIdx]; - final int stop= (argIdx + 1 < idxs.length) ? idxs[argIdx + 1] : info.getInformationDisplayString().length(); + final int start= indexes.getAt(argParameterIdx); + final int stop= (argParameterIdx + 1 < indexes.size()) ? + indexes.getAt(argParameterIdx + 1) : info.getInformationDisplayString().length(); presentation.clear(); presentation.addStyleRange(new StyleRange(start, stop - start, null, null, SWT.BOLD)); - this.lastPresentation= argIdx; + this.lastPresentation= argParameterIdx; return true; } } @@ -193,11 +194,10 @@ return this.scannedArgs; } - private int getCurrentArgInDef(final int offset) { + private int getCurrentArgParameterIdx(final int offset) { final ControlNode args= getScannedArgs(); if (args != null) { - @Nullable - final TexAstNode[] argNodes= TexAsts.resolveArguments(args); + final @Nullable TexAstNode[] argNodes= TexAsts.resolveArguments(args); int idx= TexAsts.getIndexAt(argNodes, offset); // correct selection in between groups if (idx < 0) { @@ -210,7 +210,7 @@ } else if (idx > 0 && argNodes[idx].getStartOffset() == offset) { while (idx > 0 && argNodes[idx - 1] == null - && this.info.getCommand().getArguments().get(idx - 1).isOptional()) { + && this.info.getCommand().getParameters().get(idx - 1).isOptional()) { idx--; } }