1 package net.mograsim.plugin.asm.editor;
3 import org.eclipse.jface.text.BadLocationException;
4 import org.eclipse.jface.text.DocumentCommand;
5 import org.eclipse.jface.text.IAutoEditStrategy;
6 import org.eclipse.jface.text.IDocument;
7 import org.eclipse.jface.text.IRegion;
9 public class AsmAutoEditStrategy implements IAutoEditStrategy
13 public void customizeDocumentCommand(IDocument document, DocumentCommand command)
15 if (!">".equals(command.text))
21 IRegion region = document.getLineInformationOfOffset(command.offset);
22 String line = document.get(region.getOffset(), command.offset - region.getOffset());
23 int index = line.lastIndexOf('<');
24 if (index != -1 && (index != line.length() - 1) && line.charAt(index + 1) != '/')
26 String tag = line.substring(index + 1);
27 command.caretOffset = command.offset + 1;
28 command.text += "</" + tag + command.text; // NON-NLS-1
29 command.shiftsCaret = false;
32 catch (@SuppressWarnings("unused") BadLocationException e)