private static void positionsToVariables(List<RangeMarker> positions, TemplateVariable[] variables) { Iterator<RangeMarker> iterator= positions.iterator(); for (int i= 0; i != variables.length; i++) { TemplateVariable variable= variables[i]; int[] offsets= new int[variable.getOffsets().length]; for (int j= 0; j != offsets.length; j++) offsets[j]= iterator.next().getOffset(); variable.setOffsets(offsets); } } }
private static void positionsToVariables(List<RangeMarker> positions, TemplateVariable[] variables) { Iterator<RangeMarker> iterator= positions.iterator(); for (int i= 0; i != variables.length; i++) { TemplateVariable variable= variables[i]; int[] offsets= new int[variable.getOffsets().length]; for (int j= 0; j != offsets.length; j++) offsets[j]= iterator.next().getOffset(); variable.setOffsets(offsets); } } }
private static void positionsToVariables(List positions, TemplateVariable[] variables) { Iterator iterator = positions.iterator(); for (int i = 0; i != variables.length; i++) { TemplateVariable variable = variables[i]; int[] offsets = new int[variable.getOffsets().length]; for (int j = 0; j != offsets.length; j++) { offsets[j] = ((TextEdit) iterator.next()).getOffset(); } variable.setOffsets(offsets); } } }
private static void positionsToVariables(Position[] positions, TemplateVariable[] variables, int start) { for (int i = 0; i != variables.length; i++) { TemplateVariable variable = variables[i]; int[] offsets = new int[variable.getOffsets().length]; for (int j = 0; j != offsets.length; j++) { offsets[j] = positions[j].getOffset() - start; } variable.setOffsets(offsets); } }
/** * Creates a template variable with multiple possible values. * * @param type the type of the variable * @param name the name of the variable * @param values the values available at this variable, non-empty * @param offsets the array of offsets of the variable * @since 3.3 */ TemplateVariable(TemplateVariableType type, String name, String[] values, int[] offsets) { Assert.isNotNull(type); Assert.isNotNull(name); fType= type; fName= name; setValues(values); setOffsets(offsets); setUnambiguous(false); setResolved(false); fInitialLength= values[0].length(); }
/** * Creates a template variable with multiple possible values. * * @param type the type of the variable * @param name the name of the variable * @param values the values available at this variable, non-empty * @param offsets the array of offsets of the variable * @since 3.3 */ TemplateVariable(TemplateVariableType type, String name, String[] values, int[] offsets) { Assert.isNotNull(type); Assert.isNotNull(name); fType= type; fName= name; setValues(values); setOffsets(offsets); setUnambiguous(false); setResolved(false); fInitialLength= values[0].length(); }
private void removeRangeMarkers(List<TypedPosition> positions, IDocument document, TemplateVariable[] variables) throws MalformedTreeException, BadLocationException, BadPositionCategoryException { // revert previous changes for (Iterator<TypedPosition> it= positions.iterator(); it.hasNext();) { TypedPosition position= it.next(); // remove and re-add in order to not confuse ExclusivePositionUpdater document.removePosition(CATEGORY, position); final String original= position.getType(); if (original != null) { document.replace(position.getOffset(), position.getLength(), original); position.setLength(original.length()); } document.addPosition(position); } Iterator<TypedPosition> it= positions.iterator(); for (int i= 0; i != variables.length; i++) { TemplateVariable variable= variables[i]; int[] offsets= new int[variable.getOffsets().length]; for (int j= 0; j != offsets.length; j++) offsets[j]= it.next().getOffset(); variable.setOffsets(offsets); } } }
private void removeRangeMarkers(List positions, IDocument document, TemplateVariable[] variables) throws MalformedTreeException, BadLocationException, BadPositionCategoryException { // revert previous changes for (Iterator it= positions.iterator(); it.hasNext();) { TypedPosition position= (TypedPosition) it.next(); // remove and re-add in order to not confuse ExclusivePositionUpdater document.removePosition(CATEGORY, position); final String original= position.getType(); if (original != null) { document.replace(position.getOffset(), position.getLength(), original); position.setLength(original.length()); } document.addPosition(position); } Iterator it= positions.iterator(); for (int i= 0; i != variables.length; i++) { TemplateVariable variable= variables[i]; int[] offsets= new int[variable.getOffsets().length]; for (int j= 0; j != offsets.length; j++) offsets[j]= ((Position) it.next()).getOffset(); variable.setOffsets(offsets); } } }
private void removeRangeMarkers(List<TypedPosition> positions, IDocument document, TemplateVariable[] variables) throws MalformedTreeException, BadLocationException, BadPositionCategoryException { // revert previous changes for (Iterator<TypedPosition> it= positions.iterator(); it.hasNext();) { TypedPosition position= it.next(); // remove and re-add in order to not confuse ExclusivePositionUpdater document.removePosition(CATEGORY, position); final String original= position.getType(); if (original != null) { document.replace(position.getOffset(), position.getLength(), original); position.setLength(original.length()); } document.addPosition(position); } Iterator<TypedPosition> it= positions.iterator(); for (int i= 0; i != variables.length; i++) { TemplateVariable variable= variables[i]; int[] offsets= new int[variable.getOffsets().length]; for (int j= 0; j != offsets.length; j++) offsets[j]= it.next().getOffset(); variable.setOffsets(offsets); } } }