Skip to content

Commit

Permalink
refact: add toString methods to langcfg model classes
Browse files Browse the repository at this point in the history
  • Loading branch information
sebthom committed Nov 6, 2023
1 parent 36d666e commit 18aebb6
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

import java.util.List;

import org.eclipse.tm4e.core.internal.utils.StringUtils;

/**
* @see <a href=
* "https://github.com/microsoft/vscode/blob/8e2ec5a7ee1ae5500c645c05145359f2a814611c/src/vs/editor/common/languages/languageConfiguration.ts#L201">
Expand All @@ -26,4 +28,12 @@ public AutoClosingPairConditional(final String open, final String close, final L
super(open, close);
this.notIn = notIn;
}

@Override
public String toString() {
return StringUtils.toString(this, sb -> sb
.append("open=").append(open).append(", ")
.append("close=").append(close).append(", ")
.append("notIn=").append(notIn));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*/
package org.eclipse.tm4e.languageconfiguration.internal.model;

import org.eclipse.tm4e.core.internal.utils.StringUtils;

/**
* A tuple of two characters, like a pair of opening and closing brackets.
*
Expand All @@ -27,4 +29,11 @@ public CharacterPair(final String opening, final String closing) {
this.open = opening;
this.close = closing;
}

@Override
public String toString() {
return StringUtils.toString(this, sb -> sb
.append("open=").append(open).append(", ")
.append("close=").append(close));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package org.eclipse.tm4e.languageconfiguration.internal.model;

import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tm4e.core.internal.utils.StringUtils;

/**
* Describes how comments for a language work.
Expand All @@ -38,4 +39,11 @@ public CommentRule(@Nullable final String lineComment, @Nullable final Character
this.lineComment = lineComment;
this.blockComment = blockComment;
}

@Override
public String toString() {
return StringUtils.toString(this, sb -> sb
.append("lineComment=").append(lineComment).append(", ")
.append("blockComment=").append(blockComment));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*/
package org.eclipse.tm4e.languageconfiguration.internal.model;

import org.eclipse.tm4e.core.internal.utils.StringUtils;

/**
* @see <a href=
* "https://github.com/microsoft/vscode/blob/8e2ec5a7ee1ae5500c645c05145359f2a814611c/src/vs/editor/common/languages/languageConfiguration.ts#L250">
Expand All @@ -29,4 +31,13 @@ public CompleteEnterAction(final EnterAction action, final String indentation) {
this.appendText = action.appendText;
this.removeText = action.removeText;
}

@Override
public String toString() {
return StringUtils.toString(this, sb -> sb
.append("indentAction=").append(indentAction).append(", ")
.append("appendText=").append(appendText).append(", ")
.append("removeText=").append(removeText).append(", ")
.append("indentation=").append(indentation));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package org.eclipse.tm4e.languageconfiguration.internal.model;

import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tm4e.core.internal.utils.StringUtils;

/**
* Describes what to do when pressing Enter.
Expand Down Expand Up @@ -100,4 +101,12 @@ EnterAction withRemoveText(@Nullable final Integer removeText) {
this.removeText = removeText;
return this;
}

@Override
public String toString() {
return StringUtils.toString(this, sb -> sb
.append("indentAction=").append(indentAction).append(", ")
.append("appendText=").append(appendText).append(", ")
.append("removeText=").append(removeText));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

import java.util.regex.Pattern;

import org.eclipse.tm4e.core.internal.utils.StringUtils;

/**
* Describes folding rules for a language.
*
Expand All @@ -36,4 +38,12 @@ public FoldingRules(final boolean offSide, final Pattern markersStart, final Pat
this.markersStart = markersStart;
this.markersEnd = markersEnd;
}

@Override
public String toString() {
return StringUtils.toString(this, sb -> sb
.append("markersStart=").append(markersStart).append(", ")
.append("markersEnd=").append(markersEnd).append(", ")
.append("offSide=").append(offSide));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.regex.Pattern;

import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tm4e.core.internal.utils.StringUtils;

/**
* Describes a rule to be evaluated when pressing Enter.
Expand Down Expand Up @@ -65,4 +66,13 @@ public OnEnterRule(final Pattern beforeText, @Nullable final Pattern afterText,
this.previousLineText = previousLineText == null ? null : Pattern.compile(previousLineText);
this.action = action;
}

@Override
public String toString() {
return StringUtils.toString(this, sb -> sb
.append("beforeText=").append(beforeText).append(", ")
.append("afterText=").append(afterText).append(", ")
.append("previousLineText=").append(previousLineText).append(", ")
.append("action=").append(action));
}
}

0 comments on commit 18aebb6

Please sign in to comment.