import net.sourceforge.phpdt.core.formatter.DefaultCodeFormatterConstants;
//incastrix
//import net.sourceforge.phpdt.internal.corext.Assert;
-import org.eclipse.core.runtime.Assert;
+//import org.eclipse.core.runtime.Assert;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.Position;
+//import org.eclipse.jface.text.BadLocationException;
+//import org.eclipse.jface.text.BadPositionCategoryException;
+//import org.eclipse.jface.text.DefaultPositionUpdater;
+//import org.eclipse.jface.text.Document;
+//import org.eclipse.jface.text.Position;
//import org.eclipse.text.edits.DeleteEdit;
//import org.eclipse.text.edits.InsertEdit;
//import org.eclipse.text.edits.MultiTextEdit;
//import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.text.edits.TextEdit;
+//import org.eclipse.text.edits.TextEdit;
public class CodeFormatterUtil {
* If the positions are not inside the string, a
* IllegalArgumentException is thrown.
*/
- public static String evaluateFormatterEdit(String string, TextEdit edit,
- Position[] positions) {
- try {
- Document doc = createDocument(string, positions);
- edit.apply(doc, 0);
- if (positions != null) {
- for (int i = 0; i < positions.length; i++) {
- Assert.isTrue(!positions[i].isDeleted,
- "Position got deleted"); //$NON-NLS-1$
- }
- }
- return doc.get();
- } catch (BadLocationException e) {
- PHPeclipsePlugin.log(e); // bug in the formatter
- Assert
- .isTrue(
- false,
- "Fromatter created edits with wrong positions: " + e.getMessage()); //$NON-NLS-1$
- }
- return null;
- }
+// public static String evaluateFormatterEdit(String string, TextEdit edit,
+// Position[] positions) {
+// try {
+// Document doc = createDocument(string, positions);
+// edit.apply(doc, 0);
+// if (positions != null) {
+// for (int i = 0; i < positions.length; i++) {
+// Assert.isTrue(!positions[i].isDeleted,
+// "Position got deleted"); //$NON-NLS-1$
+// }
+// }
+// return doc.get();
+// } catch (BadLocationException e) {
+// PHPeclipsePlugin.log(e); // bug in the formatter
+// Assert
+// .isTrue(
+// false,
+// "Fromatter created edits with wrong positions: " + e.getMessage()); //$NON-NLS-1$
+// }
+// return null;
+// }
/**
* Creates edits that describe how to format the given string. Returns
// return newEdit;
// }
- private static Document createDocument(String string, Position[] positions)
- throws IllegalArgumentException {
- Document doc = new Document(string);
- try {
- if (positions != null) {
- final String POS_CATEGORY = "myCategory"; //$NON-NLS-1$
-
- doc.addPositionCategory(POS_CATEGORY);
- doc
- .addPositionUpdater(new DefaultPositionUpdater(
- POS_CATEGORY) {
- protected boolean notDeleted() {
- if (fOffset < fPosition.offset
- && (fPosition.offset + fPosition.length < fOffset
- + fLength)) {
- fPosition.offset = fOffset + fLength; // deleted
- // positions:
- // set
- // to
- // end
- // of
- // remove
- return false;
- }
- return true;
- }
- });
- for (int i = 0; i < positions.length; i++) {
- try {
- doc.addPosition(POS_CATEGORY, positions[i]);
- } catch (BadLocationException e) {
- throw new IllegalArgumentException(
- "Position outside of string. offset: " + positions[i].offset + ", length: " + positions[i].length + ", string size: " + string.length()); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- }
- }
- }
- } catch (BadPositionCategoryException cannotHappen) {
- // can not happen: category is correctly set up
- }
- return doc;
- }
+// private static Document createDocument(String string, Position[] positions)
+// throws IllegalArgumentException {
+// Document doc = new Document(string);
+// try {
+// if (positions != null) {
+// final String POS_CATEGORY = "myCategory"; //$NON-NLS-1$
+//
+// doc.addPositionCategory(POS_CATEGORY);
+// doc
+// .addPositionUpdater(new DefaultPositionUpdater(
+// POS_CATEGORY) {
+// protected boolean notDeleted() {
+// if (fOffset < fPosition.offset
+// && (fPosition.offset + fPosition.length < fOffset
+// + fLength)) {
+// fPosition.offset = fOffset + fLength; // deleted
+// // positions:
+// // set
+// // to
+// // end
+// // of
+// // remove
+// return false;
+// }
+// return true;
+// }
+// });
+// for (int i = 0; i < positions.length; i++) {
+// try {
+// doc.addPosition(POS_CATEGORY, positions[i]);
+// } catch (BadLocationException e) {
+// throw new IllegalArgumentException(
+// "Position outside of string. offset: " + positions[i].offset + ", length: " + positions[i].length + ", string size: " + string.length()); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+// }
+// }
+// }
+// } catch (BadPositionCategoryException cannotHappen) {
+// // can not happen: category is correctly set up
+// }
+// return doc;
+// }
}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package net.sourceforge.phpdt.internal.corext.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-
-// import net.sourceforge.phpdt.internal.ui.JavaPlugin;
-
-public class IOCloser {
- public static void perform(Reader reader, InputStream stream) {
- try {
- rethrows(reader, stream);
- } catch (IOException e) {
- PHPeclipsePlugin.log(e);
- }
- }
-
- public static void rethrows(Reader reader, InputStream stream)
- throws IOException {
- if (reader != null) {
- reader.close();
- return;
- }
- if (stream != null) {
- stream.close();
- return;
- }
- }
-}
import java.util.StringTokenizer;
-import net.sourceforge.phpdt.core.Flags;
+//import net.sourceforge.phpdt.core.Flags;
import net.sourceforge.phpdt.core.ICompilationUnit;
import net.sourceforge.phpdt.core.IField;
import net.sourceforge.phpdt.core.IJavaElement;
import net.sourceforge.phpdt.core.IMember;
import net.sourceforge.phpdt.core.IMethod;
-import net.sourceforge.phpdt.core.IPackageFragment;
+//import net.sourceforge.phpdt.core.IPackageFragment;
import net.sourceforge.phpdt.core.IPackageFragmentRoot;
import net.sourceforge.phpdt.core.IType;
import net.sourceforge.phpdt.core.JavaModelException;
import net.sourceforge.phpdt.core.Signature;
-import net.sourceforge.phpdt.core.compiler.CharOperation;
+//import net.sourceforge.phpdt.core.compiler.CharOperation;
//import net.sourceforge.phpdt.ui.JavaUI;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
//import net.sourceforge.phpeclipse.phpeditor.EditorUtility;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
+//import org.eclipse.core.runtime.CoreException;
+//import org.eclipse.core.runtime.IPath;
/**
* Utility methods for the Java Model.
* (separated by dots))
* @return the type found, or null if not existing
*/
- public static IType findTypeInCompilationUnit(ICompilationUnit cu,
- String typeQualifiedName) throws JavaModelException {
- IType[] types = cu.getAllTypes();
- for (int i = 0; i < types.length; i++) {
- String currName = getTypeQualifiedName(types[i]);
- if (typeQualifiedName.equals(currName)) {
- return types[i];
- }
- }
- return null;
- }
+// public static IType findTypeInCompilationUnit(ICompilationUnit cu,
+// String typeQualifiedName) throws JavaModelException {
+// IType[] types = cu.getAllTypes();
+// for (int i = 0; i < types.length; i++) {
+// String currName = getTypeQualifiedName(types[i]);
+// if (typeQualifiedName.equals(currName)) {
+// return types[i];
+// }
+// }
+// return null;
+// }
/**
* Finds a a member in a compilation unit. Typical usage is to find the
* uses '$' as separators. As '$' is also a valid character in an id this is
* ambiguous. JavaCore PR: 1GCFUNT
*/
- public static String getFullyQualifiedName(IType type) {
- return type.getFullyQualifiedName('.');
- }
+// public static String getFullyQualifiedName(IType type) {
+// return type.getFullyQualifiedName('.');
+// }
/**
* Returns the fully qualified name of a type's container. (package name or
* enclosing type name)
*/
- public static String getTypeContainerName(IType type) {
- IType outerType = type.getDeclaringType();
- if (outerType != null) {
- return outerType.getFullyQualifiedName('.');
- } else {
- return type.getPackageFragment().getElementName();
- }
- }
+// public static String getTypeContainerName(IType type) {
+// IType outerType = type.getDeclaringType();
+// if (outerType != null) {
+// return outerType.getFullyQualifiedName('.');
+// } else {
+// return type.getPackageFragment().getElementName();
+// }
+// }
/**
* Concatenates two names. Uses a dot for separation. Both strings can be
* empty or <code>null</code>.
*/
- public static String concatenateName(String name1, String name2) {
- StringBuffer buf = new StringBuffer();
- if (name1 != null && name1.length() > 0) {
- buf.append(name1);
- }
- if (name2 != null && name2.length() > 0) {
- if (buf.length() > 0) {
- buf.append('.');
- }
- buf.append(name2);
- }
- return buf.toString();
- }
+// public static String concatenateName(String name1, String name2) {
+// StringBuffer buf = new StringBuffer();
+// if (name1 != null && name1.length() > 0) {
+// buf.append(name1);
+// }
+// if (name2 != null && name2.length() > 0) {
+// if (buf.length() > 0) {
+// buf.append('.');
+// }
+// buf.append(name2);
+// }
+// return buf.toString();
+// }
/**
* Concatenates two names. Uses a dot for separation. Both strings can be
* empty or <code>null</code>.
*/
- public static String concatenateName(char[] name1, char[] name2) {
- StringBuffer buf = new StringBuffer();
- if (name1 != null && name1.length > 0) {
- buf.append(name1);
- }
- if (name2 != null && name2.length > 0) {
- if (buf.length() > 0) {
- buf.append('.');
- }
- buf.append(name2);
- }
- return buf.toString();
- }
+// public static String concatenateName(char[] name1, char[] name2) {
+// StringBuffer buf = new StringBuffer();
+// if (name1 != null && name1.length > 0) {
+// buf.append(name1);
+// }
+// if (name2 != null && name2.length > 0) {
+// if (buf.length() > 0) {
+// buf.append('.');
+// }
+// buf.append(name2);
+// }
+// return buf.toString();
+// }
/**
* Evaluates if a member (possible from another package) is visible from
* @param pack
* The package in focus
*/
- public static boolean isVisible(IMember member, IPackageFragment pack)
- throws JavaModelException {
- int otherflags = member.getFlags();
-
- if (Flags.isPublic(otherflags)) {
- return true;
- } else if (Flags.isPrivate(otherflags)) {
- return false;
- }
-
- IPackageFragment otherpack = (IPackageFragment) findParentOfKind(
- member, IJavaElement.PACKAGE_FRAGMENT);
- return (pack != null && pack.equals(otherpack));
- }
+// public static boolean isVisible(IMember member, IPackageFragment pack)
+// throws JavaModelException {
+// int otherflags = member.getFlags();
+//
+// if (Flags.isPublic(otherflags)) {
+// return true;
+// } else if (Flags.isPrivate(otherflags)) {
+// return false;
+// }
+//
+// IPackageFragment otherpack = (IPackageFragment) findParentOfKind(
+// member, IJavaElement.PACKAGE_FRAGMENT);
+// return (pack != null && pack.equals(otherpack));
+// }
/**
* Returns the package fragment root of <code>IJavaElement</code>. If the
*
* @deprecated Use element.getParent().getAncestor(kind);
*/
- public static IJavaElement findParentOfKind(IJavaElement element, int kind) {
- if (element != null && element.getParent() != null) {
- return element.getParent().getAncestor(kind);
- }
- return null;
- }
+// public static IJavaElement findParentOfKind(IJavaElement element, int kind) {
+// if (element != null && element.getParent() != null) {
+// return element.getParent().getAncestor(kind);
+// }
+// return null;
+// }
/**
* Finds a method in a type. This searches for a method with the same name
/**
* Checks whether the given type has a valid main method or not.
*/
- public static boolean hasMainMethod(IType type) throws JavaModelException {
- IMethod[] methods = type.getMethods();
- for (int i = 0; i < methods.length; i++) {
- if (methods[i].isMainMethod()) {
- return true;
- }
- }
- return false;
- }
+// public static boolean hasMainMethod(IType type) throws JavaModelException {
+// IMethod[] methods = type.getMethods();
+// for (int i = 0; i < methods.length; i++) {
+// if (methods[i].isMainMethod()) {
+// return true;
+// }
+// }
+// return false;
+// }
/**
* Checks if the field is boolean.
* a working copy or the member does not exist in the working copy the input
* is returned.
*/
- public static IMember toWorkingCopy(IMember member) {
- ICompilationUnit cu = member.getCompilationUnit();
- if (cu != null && !cu.isWorkingCopy()) {
- ICompilationUnit workingCopy = /*EditorUtility.*/getWorkingCopy(cu);
- if (workingCopy != null) {
- IJavaElement[] members = workingCopy.findElements(member);
- if (members != null && members.length > 0) {
- return (IMember) members[0];
- }
- }
- }
- return member;
- }
+// public static IMember toWorkingCopy(IMember member) {
+// ICompilationUnit cu = member.getCompilationUnit();
+// if (cu != null && !cu.isWorkingCopy()) {
+// ICompilationUnit workingCopy = /*EditorUtility.*/getWorkingCopy(cu);
+// if (workingCopy != null) {
+// IJavaElement[] members = workingCopy.findElements(member);
+// if (members != null && members.length > 0) {
+// return (IMember) members[0];
+// }
+// }
+// }
+// return member;
+// }
/**
* Returns the working copy CU of the given CU. If the CU is already a
* So we should not log not present exceptions when they happen in working
* copies.
*/
- public static boolean filterNotPresentException(CoreException exception) {
- if (!(exception instanceof JavaModelException))
- return true;
- JavaModelException je = (JavaModelException) exception;
- if (!je.isDoesNotExist())
- return true;
- IJavaElement[] elements = je.getJavaModelStatus().getElements();
- for (int i = 0; i < elements.length; i++) {
- IJavaElement element = elements[i];
- ICompilationUnit unit = (ICompilationUnit) element
- .getAncestor(IJavaElement.COMPILATION_UNIT);
- if (unit == null)
- return true;
- if (!unit.isWorkingCopy())
- return true;
- }
- return false;
- }
+// public static boolean filterNotPresentException(CoreException exception) {
+// if (!(exception instanceof JavaModelException))
+// return true;
+// JavaModelException je = (JavaModelException) exception;
+// if (!je.isDoesNotExist())
+// return true;
+// IJavaElement[] elements = je.getJavaModelStatus().getElements();
+// for (int i = 0; i < elements.length; i++) {
+// IJavaElement element = elements[i];
+// ICompilationUnit unit = (ICompilationUnit) element
+// .getAncestor(IJavaElement.COMPILATION_UNIT);
+// if (unit == null)
+// return true;
+// if (!unit.isWorkingCopy())
+// return true;
+// }
+// return false;
+// }
// public static IType[] getAllSuperTypes(IType type, IProgressMonitor pm)
// throws JavaModelException {
// }
// }
- public static boolean isExcludedPath(IPath resourcePath,
- IPath[] exclusionPatterns) {
- char[] path = resourcePath.toString().toCharArray();
- for (int i = 0, length = exclusionPatterns.length; i < length; i++) {
- char[] pattern = exclusionPatterns[i].toString().toCharArray();
- if (CharOperation.pathMatch(pattern, path, true, '/')) {
- return true;
- }
- }
- return false;
- }
+// public static boolean isExcludedPath(IPath resourcePath,
+// IPath[] exclusionPatterns) {
+// char[] path = resourcePath.toString().toCharArray();
+// for (int i = 0, length = exclusionPatterns.length; i < length; i++) {
+// char[] pattern = exclusionPatterns[i].toString().toCharArray();
+// if (CharOperation.pathMatch(pattern, path, true, '/')) {
+// return true;
+// }
+// }
+// return false;
+// }
/*
* Returns whether the given resource path matches one of the exclusion
*
* @see IClasspathEntry#getExclusionPatterns
*/
- public final static boolean isExcluded(IPath resourcePath,
- char[][] exclusionPatterns) {
- if (exclusionPatterns == null)
- return false;
- char[] path = resourcePath.toString().toCharArray();
- for (int i = 0, length = exclusionPatterns.length; i < length; i++)
- if (CharOperation.pathMatch(exclusionPatterns[i], path, true, '/'))
- return true;
- return false;
- }
+// public final static boolean isExcluded(IPath resourcePath,
+// char[][] exclusionPatterns) {
+// if (exclusionPatterns == null)
+// return false;
+// char[] path = resourcePath.toString().toCharArray();
+// for (int i = 0, length = exclusionPatterns.length; i < length; i++)
+// if (CharOperation.pathMatch(exclusionPatterns[i], path, true, '/'))
+// return true;
+// return false;
+// }
private static final String ARGUMENTS_DELIMITER = "#"; //$NON-NLS-1$
* @return the corresponding member in the shared working copy or
* <code>null</code> if not found
*/
- public static IMember getWorkingCopy(IMember member)
- throws JavaModelException {
- ICompilationUnit cu = member.getCompilationUnit();
- if (cu != null) {
- ICompilationUnit workingCopy = getWorkingCopy(cu);
- if (workingCopy != null) {
- return JavaModelUtil.findMemberInCompilationUnit(workingCopy,
- member);
- }
- }
- return null;
- }
+// public static IMember getWorkingCopy(IMember member)
+// throws JavaModelException {
+// ICompilationUnit cu = member.getCompilationUnit();
+// if (cu != null) {
+// ICompilationUnit workingCopy = getWorkingCopy(cu);
+// if (workingCopy != null) {
+// return JavaModelUtil.findMemberInCompilationUnit(workingCopy,
+// member);
+// }
+// }
+// return null;
+// }
}
import java.lang.reflect.Modifier;
import net.sourceforge.phpdt.core.Flags;
-import net.sourceforge.phpdt.core.IJavaElement;
+//import net.sourceforge.phpdt.core.IJavaElement;
import net.sourceforge.phpdt.core.IMember;
-import net.sourceforge.phpdt.core.IType;
+//import net.sourceforge.phpdt.core.IType;
import net.sourceforge.phpdt.core.JavaModelException;
//incastrix
//import net.sourceforge.phpdt.internal.corext.Assert;
public static final int VISIBILITY_CODE_INVALID = -1;
- public static boolean isAbstract(IMember member) throws JavaModelException {
- if (isInterfaceMethod(member))
- return true;
- return Flags.isAbstract(member.getFlags());
- }
+// public static boolean isAbstract(IMember member) throws JavaModelException {
+// if (isInterfaceMethod(member))
+// return true;
+// return Flags.isAbstract(member.getFlags());
+// }
// public static boolean isAbstract(IMethodBinding member) {
// if (isInterfaceMember(member))
// return Modifier.isAbstract(member.getModifiers());
// }
- public static boolean isDeprecated(IMember member)
- throws JavaModelException {
- return Flags.isDeprecated(member.getFlags());
- }
+// public static boolean isDeprecated(IMember member)
+// throws JavaModelException {
+// return Flags.isDeprecated(member.getFlags());
+// }
- public static boolean isFinal(IMember member) throws JavaModelException {
- if (isInterfaceField(member))
- return true;
- if (isAnonymousType(member))
- return true;
- return Flags.isFinal(member.getFlags());
- }
+// public static boolean isFinal(IMember member) throws JavaModelException {
+// if (isInterfaceField(member))
+// return true;
+// if (isAnonymousType(member))
+// return true;
+// return Flags.isFinal(member.getFlags());
+// }
// public static boolean isNative(IMember member) throws JavaModelException{
// return Flags.isNative(member.getFlags());
// }
- public static boolean isPackageVisible(IMember member)
- throws JavaModelException {
- return (!isPrivate(member) && !isProtected(member) && !isPublic(member));
- }
+// public static boolean isPackageVisible(IMember member)
+// throws JavaModelException {
+// return (!isPrivate(member) && !isProtected(member) && !isPublic(member));
+// }
// public static boolean isPackageVisible(BodyDeclaration bodyDeclaration) {
// return (! isPrivate(bodyDeclaration) && ! isProtected(bodyDeclaration) &&
// return Modifier.isPublic(bodyDeclaration.getModifiers());
// }
- public static boolean isStatic(IMember member) throws JavaModelException {
- if (isNestedInterface(member))
- return true;
- if (member.getElementType() != IJavaElement.METHOD
- && isInterfaceMember(member))
- return true;
- return Flags.isStatic(member.getFlags());
- }
+// public static boolean isStatic(IMember member) throws JavaModelException {
+// if (isNestedInterface(member))
+// return true;
+// if (member.getElementType() != IJavaElement.METHOD
+// && isInterfaceMember(member))
+// return true;
+// return Flags.isStatic(member.getFlags());
+// }
// public static boolean isStatic(IMethodBinding methodBinding){
// return Modifier.isStatic(methodBinding.getModifiers());
// return Flags.isVolatile(member.getFlags());
// }
- private static boolean isInterfaceMethod(IMember member)
- throws JavaModelException {
- return member.getElementType() == IJavaElement.METHOD
- && isInterfaceMember(member);
- }
-
- private static boolean isInterfaceField(IMember member)
- throws JavaModelException {
- return member.getElementType() == IJavaElement.FIELD
- && isInterfaceMember(member);
- }
+// private static boolean isInterfaceMethod(IMember member)
+// throws JavaModelException {
+// return member.getElementType() == IJavaElement.METHOD
+// && isInterfaceMember(member);
+// }
+//
+// private static boolean isInterfaceField(IMember member)
+// throws JavaModelException {
+// return member.getElementType() == IJavaElement.FIELD
+// && isInterfaceMember(member);
+// }
private static boolean isInterfaceMember(IMember member)
throws JavaModelException {
// ((TypeDeclaration)bodyDeclaration.getParent()).isInterface();
// }
- private static boolean isNestedInterface(IMember member)
- throws JavaModelException {
- return member.getElementType() == IJavaElement.TYPE
- && member.getDeclaringType() != null
- && ((IType) member).isInterface();
- }
-
- private static boolean isAnonymousType(IMember member)
- throws JavaModelException {
- return member.getElementType() == IJavaElement.TYPE
- && ((IType) member).isAnonymous();
- }
+// private static boolean isNestedInterface(IMember member)
+// throws JavaModelException {
+// return member.getElementType() == IJavaElement.TYPE
+// && member.getDeclaringType() != null
+// && ((IType) member).isInterface();
+// }
+//
+// private static boolean isAnonymousType(IMember member)
+// throws JavaModelException {
+// return member.getElementType() == IJavaElement.TYPE
+// && ((IType) member).isAnonymous();
+// }
public static int getVisibilityCode(IMember member)
throws JavaModelException {
}
}
- public static int getLowerVisibility(int visibility1, int visibility2) {
- if (isHigherVisibility(visibility1, visibility2))
- return visibility2;
- else
- return visibility1;
- }
-
- public static int clearAccessModifiers(int flags) {
- return clearFlag(Modifier.PROTECTED | Modifier.PUBLIC
- | Modifier.PRIVATE, flags);
- }
-
- public static int clearFlag(int flag, int flags) {
- return flags & ~flag;
- }
+// public static int getLowerVisibility(int visibility1, int visibility2) {
+// if (isHigherVisibility(visibility1, visibility2))
+// return visibility2;
+// else
+// return visibility1;
+// }
+
+// public static int clearAccessModifiers(int flags) {
+// return clearFlag(Modifier.PROTECTED | Modifier.PUBLIC
+// | Modifier.PRIVATE, flags);
+// }
+
+// public static int clearFlag(int flag, int flags) {
+// return flags & ~flag;
+// }
}
*/
public class PHPUIStatus extends Status {
- public PHPUIStatus(int code) {
- this(code, ""); //$NON-NLS-1$
- }
+// public PHPUIStatus(int code) {
+// this(code, ""); //$NON-NLS-1$
+// }
private PHPUIStatus(int severity, int code, String message,
Throwable throwable) {
throwable);
}
- public PHPUIStatus(int code, String message) {
- this(code, message, null);
- }
+// public PHPUIStatus(int code, String message) {
+// this(code, message, null);
+// }
- public PHPUIStatus(int code, String message, Throwable throwable) {
- super(IStatus.ERROR, PHPeclipsePlugin.getPluginId(), code, message,
- throwable);
- }
+// public PHPUIStatus(int code, String message, Throwable throwable) {
+// super(IStatus.ERROR, PHPeclipsePlugin.getPluginId(), code, message,
+// throwable);
+// }
public static IStatus createError(int code, Throwable throwable) {
String message = throwable.getMessage();
return new PHPUIStatus(IStatus.ERROR, code, message, throwable);
}
- public static IStatus createError(int code, String message,
- Throwable throwable) {
- return new PHPUIStatus(IStatus.ERROR, code, message, throwable);
- }
+// public static IStatus createError(int code, String message,
+// Throwable throwable) {
+// return new PHPUIStatus(IStatus.ERROR, code, message, throwable);
+// }
- public static IStatus createInfo(int code, String message,
- Throwable throwable) {
- return new PHPUIStatus(IStatus.INFO, code, message, throwable);
- }
+// public static IStatus createInfo(int code, String message,
+// Throwable throwable) {
+// return new PHPUIStatus(IStatus.INFO, code, message, throwable);
+// }
- public static IStatus createWarning(int code, String message,
- Throwable throwable) {
- return new PHPUIStatus(IStatus.WARNING, code, message, throwable);
- }
+// public static IStatus createWarning(int code, String message,
+// Throwable throwable) {
+// return new PHPUIStatus(IStatus.WARNING, code, message, throwable);
+// }
}
/**
* tests if a char is lower case. Fix for 26529
*/
- public static boolean isLowerCase(char ch) {
- return Character.toLowerCase(ch) == ch;
- }
+// public static boolean isLowerCase(char ch) {
+// return Character.toLowerCase(ch) == ch;
+// }
/**
* Line delimiter chars are '\n' and '\r'.
return ch == '\n' || ch == '\r';
}
- public static String removeNewLine(String message) {
- StringBuffer result = new StringBuffer();
- int current = 0;
- int index = message.indexOf('\n', 0);
- while (index != -1) {
- result.append(message.substring(current, index));
- if (current < index && index != 0)
- result.append(' ');
- current = index + 1;
- index = message.indexOf('\n', current);
- }
- result.append(message.substring(current));
- return result.toString();
- }
+// public static String removeNewLine(String message) {
+// StringBuffer result = new StringBuffer();
+// int current = 0;
+// int index = message.indexOf('\n', 0);
+// while (index != -1) {
+// result.append(message.substring(current, index));
+// if (current < index && index != 0)
+// result.append(' ');
+// current = index + 1;
+// index = message.indexOf('\n', current);
+// }
+// result.append(message.substring(current));
+// return result.toString();
+// }
/**
* Converts the given string into an array of lines. The lines don't contain
* null</code>
* if the input string can't be converted in an array of lines.
*/
- public static String[] convertIntoLines(String input) {
- try {
- ILineTracker tracker = new DefaultLineTracker();
- tracker.set(input);
- int size = tracker.getNumberOfLines();
- String result[] = new String[size];
- for (int i = 0; i < size; i++) {
- IRegion region = tracker.getLineInformation(i);
- int offset = region.getOffset();
- result[i] = input
- .substring(offset, offset + region.getLength());
- }
- return result;
- } catch (BadLocationException e) {
- return null;
- }
- }
+// public static String[] convertIntoLines(String input) {
+// try {
+// ILineTracker tracker = new DefaultLineTracker();
+// tracker.set(input);
+// int size = tracker.getNumberOfLines();
+// String result[] = new String[size];
+// for (int i = 0; i < size; i++) {
+// IRegion region = tracker.getLineInformation(i);
+// int offset = region.getOffset();
+// result[i] = input
+// .substring(offset, offset + region.getLength());
+// }
+// return result;
+// } catch (BadLocationException e) {
+// return null;
+// }
+// }
/**
* Returns <code>true</code> if the given string only consists of white
return line.substring(start);
}
- public static String trimTrailingTabsAndSpaces(String line) {
- int size = line.length();
- int end = size;
- for (int i = size - 1; i >= 0; i--) {
- char c = line.charAt(i);
- if (isIndentChar(c)) {
- end = i;
- } else {
- break;
- }
- }
- if (end == size)
- return line;
- else if (end == 0)
- return ""; //$NON-NLS-1$
- else
- return line.substring(0, end);
- }
+// public static String trimTrailingTabsAndSpaces(String line) {
+// int size = line.length();
+// int end = size;
+// for (int i = size - 1; i >= 0; i--) {
+// char c = line.charAt(i);
+// if (isIndentChar(c)) {
+// end = i;
+// } else {
+// break;
+// }
+// }
+// if (end == size)
+// return line;
+// else if (end == 0)
+// return ""; //$NON-NLS-1$
+// else
+// return line.substring(0, end);
+// }
/**
* Returns the indent of the given string.
* Removes all leading indents from the given line. If the line doesn't
* contain any indents the line itself is returned.
*/
- public static String trimIndents(String s, int tabWidth) {
- int indent = computeIndent(s, tabWidth);
- if (indent == 0)
- return s;
- return trimIndent(s, indent, tabWidth);
- }
+// public static String trimIndents(String s, int tabWidth) {
+// int indent = computeIndent(s, tabWidth);
+// if (indent == 0)
+// return s;
+// return trimIndent(s, indent, tabWidth);
+// }
/**
* Removes the common number of indents from all lines. If a line only
* consists out of white space it is ignored.
*/
- public static void trimIndentation(String[] lines, int tabWidth) {
- trimIndentation(lines, tabWidth, true);
- }
+// public static void trimIndentation(String[] lines, int tabWidth) {
+// trimIndentation(lines, tabWidth, true);
+// }
/**
* Removes the common number of indents from all lines. If a line only
* considerFirstLine</code>
* is false the first line will be ignored.
*/
- public static void trimIndentation(String[] lines, int tabWidth,
- boolean considerFirstLine) {
- String[] toDo = new String[lines.length];
- // find indentation common to all lines
- int minIndent = Integer.MAX_VALUE; // very large
- for (int i = considerFirstLine ? 0 : 1; i < lines.length; i++) {
- String line = lines[i];
- if (containsOnlyWhitespaces(line))
- continue;
- toDo[i] = line;
- int indent = computeIndent(line, tabWidth);
- if (indent < minIndent) {
- minIndent = indent;
- }
- }
+// public static void trimIndentation(String[] lines, int tabWidth,
+// boolean considerFirstLine) {
+// String[] toDo = new String[lines.length];
+// // find indentation common to all lines
+// int minIndent = Integer.MAX_VALUE; // very large
+// for (int i = considerFirstLine ? 0 : 1; i < lines.length; i++) {
+// String line = lines[i];
+// if (containsOnlyWhitespaces(line))
+// continue;
+// toDo[i] = line;
+// int indent = computeIndent(line, tabWidth);
+// if (indent < minIndent) {
+// minIndent = indent;
+// }
+// }
+//
+// if (minIndent > 0) {
+// // remove this indent from all lines
+// for (int i = considerFirstLine ? 0 : 1; i < toDo.length; i++) {
+// String s = toDo[i];
+// if (s != null)
+// lines[i] = trimIndent(s, minIndent, tabWidth);
+// else {
+// String line = lines[i];
+// int indent = computeIndent(line, tabWidth);
+// if (indent > minIndent)
+// lines[i] = trimIndent(line, minIndent, tabWidth);
+// else
+// lines[i] = trimLeadingTabsAndSpaces(line);
+// }
+// }
+// }
+// }
- if (minIndent > 0) {
- // remove this indent from all lines
- for (int i = considerFirstLine ? 0 : 1; i < toDo.length; i++) {
- String s = toDo[i];
- if (s != null)
- lines[i] = trimIndent(s, minIndent, tabWidth);
- else {
- String line = lines[i];
- int indent = computeIndent(line, tabWidth);
- if (indent > minIndent)
- lines[i] = trimIndent(line, minIndent, tabWidth);
- else
- lines[i] = trimLeadingTabsAndSpaces(line);
- }
- }
- }
- }
+// public static String getIndentString(String line, int tabWidth) {
+// int size = line.length();
+// int end = 0;
+// int blanks = 0;
+// for (int i = 0; i < size; i++) {
+// char c = line.charAt(i);
+// if (c == '\t') {
+// end = i + 1;
+// blanks = 0;
+// } else if (isIndentChar(c)) {
+// blanks++;
+// if (blanks == tabWidth) {
+// end = i + 1;
+// blanks = 0;
+// }
+// } else {
+// break;
+// }
+// }
+// if (end == 0)
+// return ""; //$NON-NLS-1$
+// else if (end == size)
+// return line;
+// else
+// return line.substring(0, end);
+// }
- public static String getIndentString(String line, int tabWidth) {
- int size = line.length();
- int end = 0;
- int blanks = 0;
- for (int i = 0; i < size; i++) {
- char c = line.charAt(i);
- if (c == '\t') {
- end = i + 1;
- blanks = 0;
- } else if (isIndentChar(c)) {
- blanks++;
- if (blanks == tabWidth) {
- end = i + 1;
- blanks = 0;
- }
- } else {
- break;
- }
- }
- if (end == 0)
- return ""; //$NON-NLS-1$
- else if (end == size)
- return line;
- else
- return line.substring(0, end);
- }
+// public static String[] removeTrailingEmptyLines(String[] sourceLines) {
+// int lastNonEmpty = findLastNonEmptyLineIndex(sourceLines);
+// String[] result = new String[lastNonEmpty + 1];
+// for (int i = 0; i < result.length; i++) {
+// result[i] = sourceLines[i];
+// }
+// return result;
+// }
- public static String[] removeTrailingEmptyLines(String[] sourceLines) {
- int lastNonEmpty = findLastNonEmptyLineIndex(sourceLines);
- String[] result = new String[lastNonEmpty + 1];
- for (int i = 0; i < result.length; i++) {
- result[i] = sourceLines[i];
- }
- return result;
- }
-
- private static int findLastNonEmptyLineIndex(String[] sourceLines) {
- for (int i = sourceLines.length - 1; i >= 0; i--) {
- if (!sourceLines[i].trim().equals(""))//$NON-NLS-1$
- return i;
- }
- return -1;
- }
+// private static int findLastNonEmptyLineIndex(String[] sourceLines) {
+// for (int i = sourceLines.length - 1; i >= 0; i--) {
+// if (!sourceLines[i].trim().equals(""))//$NON-NLS-1$
+// return i;
+// }
+// return -1;
+// }
/**
* Change the indent of, possible muti-line, code range. The current indent
* Concatenate the given strings into one strings using the passed line
* delimiter as a delimiter. No delimiter is added to the last line.
*/
- public static String concatenate(String[] lines, String delimiter) {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < lines.length; i++) {
- if (i > 0)
- buffer.append(delimiter);
- buffer.append(lines[i]);
- }
- return buffer.toString();
- }
+// public static String concatenate(String[] lines, String delimiter) {
+// StringBuffer buffer = new StringBuffer();
+// for (int i = 0; i < lines.length; i++) {
+// if (i > 0)
+// buffer.append(delimiter);
+// buffer.append(lines[i]);
+// }
+// return buffer.toString();
+// }
public static boolean equals(String s, char[] c) {
if (s.length() != c.length)