import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.text.Assert;
+//incastrix
+//import org.eclipse.jface.text.Assert;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DocumentCommand;
import org.eclipse.jface.text.IDocument;
* @param isTabAction
* whether the action should insert tabs if over the indentation
*/
- public IndentAction(ResourceBundle bundle, String prefix,
- ITextEditor editor, boolean isTabAction) {
- super(bundle, prefix, editor);
+ public IndentAction (ResourceBundle bundle,
+ String prefix,
+ ITextEditor editor,
+ boolean isTabAction) {
+ super (bundle, prefix, editor);
+
fIsTabAction = isTabAction;
}
else {
int size = 0;
int l = indent.length();
- int tabSize = PHPeclipsePlugin
- .getDefault()
- .getPreferenceStore()
- .getInt(
+ int tabSize = PHPeclipsePlugin.getDefault().getPreferenceStore().getInt(
AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
for (int i = 0; i < l; i++)
*/
private boolean isValidSelection() {
ITextSelection selection = getSelection();
- if (selection.isEmpty())
+
+ if (selection.isEmpty()) {
return false;
+ }
int offset = selection.getOffset();
int length = selection.getLength();
IDocument document = getDocument();
- if (document == null)
+
+ if (document == null) {
return false;
+ }
try {
IRegion firstLine = document.getLineInformationOfOffset(offset);
// either the selection has to be empty and the caret in the WS at
// the line start
// or the selection has to extend over multiple lines
- if (length == 0)
- return document.get(lineOffset, offset - lineOffset).trim()
- .length() == 0;
- else
+ if (length == 0) {
+ boolean bRet;
+
+ bRet = document.get (lineOffset, offset - lineOffset).trim().length() == 0;
+
+ return bRet;
+ }
+ else {
// return lineOffset + firstLine.getLength() < offset + length;
return false; // only enable for empty selections for now
+ }
} catch (BadLocationException e) {
}
*
* @return the current document or <code>null</code>
*/
- private IDocument getDocument() {
-
- ITextEditor editor = getTextEditor();
+ private IDocument getDocument() { ITextEditor editor = getTextEditor();
if (editor != null) {
-
IDocumentProvider provider = editor.getDocumentProvider();
IEditorInput input = editor.getEditorInput();
- if (provider != null && input != null)
+
+ if (provider != null && input != null) {
return provider.getDocument(input);
-
+ }
}
+
return null;
}