Skip to content

Commit

Permalink
Create a helper Counter class.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Apr 22, 2024
1 parent afb6a68 commit c506615
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public TemplateBuffer evaluate(Template template) throws BadLocationException, T
String spacesIndentString = StringUtils.createSpaceString(getTabWidth());

//indent to needed level and
//replace any \t for the indentation string
//replace any \t for the indentation string
String pattern = template.getPattern();
List<String> splitted = StringUtils.splitInLines(pattern);

Expand Down Expand Up @@ -94,7 +94,7 @@ public TemplateBuffer evaluate(Template template) throws BadLocationException, T
}
}

//recreate it (if needed).
//recreate it (if needed).
if (changed) {
pattern = template.getPattern();
splitted = StringUtils.splitInLines(pattern);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,9 @@ public String getModuleName() {
* @return a template context that can handle template insertion at the given location, or <code>null</code>
*/
public static PyDocumentTemplateContext createContext(final TemplateContextType contextType,
final ISourceViewerForTemplates edit, final IRegion region, String indent) {
final ISourceViewerForTemplates edit, final IRegion region, String indentTo) {
if (contextType != null) {
IDocument document = edit.getDocument();
final String indentTo = indent;
return new PyDocumentTemplateContext(contextType, document, region.getOffset(), region.getLength(),
indentTo, edit);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.python.pydev.core;

public class Counter {

private boolean ascending = true;
private int currValue = 0;

public Counter() {
}

public Counter(int firstValue) {
this.currValue = firstValue;
}

public Counter(int firstValue, boolean ascending) {
this.currValue = firstValue;
this.ascending = ascending;
}

public int next() {
int ret = this.currValue;
if (ascending) {
this.currValue += 1;
} else {
this.currValue -= 1;
}
return ret;
}

}

0 comments on commit c506615

Please sign in to comment.