net.sourceforge.phpdt.internal.core.util;x-internal:=true,
net.sourceforge.phpdt.internal.corext;x-internal:=true,
net.sourceforge.phpdt.internal.corext.phpdoc,
- net.sourceforge.phpdt.internal.corext.refactoring.util;x-internal:=true,
net.sourceforge.phpdt.internal.corext.template;x-internal:=true,
net.sourceforge.phpdt.internal.corext.template.php;x-internal:=true,
net.sourceforge.phpdt.internal.corext.textmanipulation;x-internal:=true,
net.sourceforge.phpdt.internal.corext.util;x-internal:=true,
net.sourceforge.phpdt.internal.formatter;x-internal:=true,
- net.sourceforge.phpdt.internal.formatter.align;x-internal:=true,
net.sourceforge.phpdt.internal.formatter.impl;x-internal:=true,
net.sourceforge.phpdt.ltk.core,
net.sourceforge.phpeclipse,
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.corext.refactoring.nls;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+//incastrix
+//import org.eclipse.jface.text.Assert;
+import org.eclipse.core.runtime.Assert;
+
+public class NLSLine {
+
+ private int fLineNumber;
+
+ private List fElements;
+
+ public NLSLine(int lineNumber) {
+ fLineNumber = lineNumber;
+ Assert.isTrue(fLineNumber >= 0);
+ fElements = new ArrayList();
+ }
+
+ public int getLineNumber() {
+ return fLineNumber;
+ }
+
+ /**
+ * Adds a NLS element to this line.
+ */
+ public void add(NLSElement element) {
+ Assert.isNotNull(element);
+ fElements.add(element);
+ }
+
+ public NLSElement[] getElements() {
+ return (NLSElement[]) fElements
+ .toArray(new NLSElement[fElements.size()]);
+ }
+
+ public NLSElement get(int index) {
+ return (NLSElement) fElements.get(index);
+ }
+
+ public boolean exists(int index) {
+ return index >= 0 && index < fElements.size();
+ }
+
+ public int size() {
+ return fElements.size();
+ }
+
+ /*
+ * non javaDoc only for debugging
+ *
+ * @see Object#toString()
+ */
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append("Line: " + fLineNumber + "\n"); //$NON-NLS-2$ //$NON-NLS-1$
+ for (Iterator iter = fElements.iterator(); iter.hasNext();) {
+ result.append("\t"); //$NON-NLS-1$
+ result.append(iter.next().toString());
+ result.append("\n"); //$NON-NLS-1$
+ }
+ return result.toString();
+ }
+}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package net.sourceforge.phpdt.internal.corext.phpdoc;
-
-import net.sourceforge.phpdt.core.IBuffer;
-import net.sourceforge.phpdt.internal.corext.util.Strings;
-
-/**
- * Reads a phpdoc comment from a phpdoc comment. Skips star-character on begin
- * of line
- */
-public class PHPDocBufferCommentReader extends SingleCharReader {
-
- private IBuffer fBuffer;
-
- private int fCurrPos;
-
- private int fStartPos;
-
- private int fEndPos;
-
- private boolean fWasNewLine;
-
- public PHPDocBufferCommentReader(IBuffer buf, int start, int end) {
- fBuffer = buf;
- fStartPos = start + 3;
- fEndPos = end - 2;
-
- reset();
- }
-
- /**
- * @see java.io.Reader#read()
- */
- public int read() {
- if (fCurrPos < fEndPos) {
- char ch;
- if (fWasNewLine) {
- do {
- ch = fBuffer.getChar(fCurrPos++);
- } while (fCurrPos < fEndPos && Character.isWhitespace(ch));
- if (ch == '*') {
- if (fCurrPos < fEndPos) {
- do {
- ch = fBuffer.getChar(fCurrPos++);
- } while (ch == '*');
- } else {
- return -1;
- }
- }
- } else {
- ch = fBuffer.getChar(fCurrPos++);
- }
- fWasNewLine = Strings.isLineDelimiterChar(ch);
-
- return ch;
- }
- return -1;
- }
-
- /**
- * @see java.io.Reader#close()
- */
- public void close() {
- fBuffer = null;
- }
-
- /**
- * @see java.io.Reader#reset()
- */
- public void reset() {
- fCurrPos = fStartPos;
- fWasNewLine = true;
- }
-
-}
}
}
- static String getEncoding(String filename) {
- String encoding = null;
- IFile file = PHPeclipsePlugin.getWorkspace().getRoot()
- .getFileForLocation(new Path(filename));
- if (file != null) {
- try {
- encoding = file.getCharset();
- } catch (CoreException e) {
- // TODO: should log the fact that we could not get the encoding?
- }
- }
- return encoding;
- }
+// static String getEncoding(String filename) {
+// String encoding = null;
+// IFile file = PHPeclipsePlugin.getWorkspace().getRoot()
+// .getFileForLocation(new Path(filename));
+// if (file != null) {
+// try {
+// encoding = file.getCharset();
+// } catch (CoreException e) {
+// // TODO: should log the fact that we could not get the encoding?
+// }
+// }
+// return encoding;
+// }
public static String getUsage(String filename,
PHPIdentifierLocation location) {
*******************************************************************************/
package net.sourceforge.phpdt.internal.corext.template;
-import java.text.MessageFormat;
+//import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
* @param key
* the string used to get the bundle value, must not be null
*/
- public static String getFormattedString(String key, Object arg) {
- return MessageFormat.format(getString(key), new Object[] { arg });
- }
+// public static String getFormattedString(String key, Object arg) {
+// return MessageFormat.format(getString(key), new Object[] { arg });
+// }
/**
* Gets a string from the resource bundle and formats it with arguments
*/
- public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
+// public static String getFormattedString(String key, Object[] args) {
+// return MessageFormat.format(getString(key), args);
+// }
}
* the member (eg. from the original)
* @return the member found, or null if not existing
*/
- public static IMember findMemberInCompilationUnit(ICompilationUnit cu,
- IMember member) throws JavaModelException {
- IJavaElement[] elements = cu.findElements(member);
- if (elements != null && elements.length > 0) {
- return (IMember) elements[0];
- }
- return null;
- }
+// public static IMember findMemberInCompilationUnit(ICompilationUnit cu,
+// IMember member) throws JavaModelException {
+// IJavaElement[] elements = cu.findElements(member);
+// if (elements != null && elements.length > 0) {
+// return (IMember) elements[0];
+// }
+// return null;
+// }
/**
* Returns the element of the given compilation unit which is "equal" to the
* If the method is a constructor
* @return The first found method or <code>null</code>, if nothing found
*/
- public static IMethod findMethod(String name, String[] paramTypes,
- boolean isConstructor, IType type) throws JavaModelException {
- return findMethod(name, paramTypes, isConstructor, type.getMethods());
- }
+// public static IMethod findMethod(String name, String[] paramTypes,
+// boolean isConstructor, IType type) throws JavaModelException {
+// return findMethod(name, paramTypes, isConstructor, type.getMethods());
+// }
/**
* Finds a method by name. This searches for a method with a name and
* The methods to search in
* @return The found method or <code>null</code>, if nothing found
*/
- public static IMethod findMethod(String name, String[] paramTypes,
- boolean isConstructor, IMethod[] methods) throws JavaModelException {
- for (int i = methods.length - 1; i >= 0; i--) {
- if (isSameMethodSignature(name, paramTypes, isConstructor,
- methods[i])) {
- return methods[i];
- }
- }
- return null;
- }
+// public static IMethod findMethod(String name, String[] paramTypes,
+// boolean isConstructor, IMethod[] methods) throws JavaModelException {
+// for (int i = methods.length - 1; i >= 0; i--) {
+// if (isSameMethodSignature(name, paramTypes, isConstructor,
+// methods[i])) {
+// return methods[i];
+// }
+// }
+// return null;
+// }
/**
* Finds a method declararion in a type's hierarchy. The search is top down,
* @return Returns <code>true</code> if the method has the given name and
* parameter types and constructor state.
*/
- public static boolean isSameMethodSignature(String name,
- String[] paramTypes, boolean isConstructor, IMethod curr)
- throws JavaModelException {
- if (isConstructor || name.equals(curr.getElementName())) {
- if (isConstructor == curr.isConstructor()) {
- String[] currParamTypes = curr.getParameterTypes();
- if (paramTypes.length == currParamTypes.length) {
- for (int i = 0; i < paramTypes.length; i++) {
- String t1 = Signature.getSimpleName(Signature
- .toString(paramTypes[i]));
- String t2 = Signature.getSimpleName(Signature
- .toString(currParamTypes[i]));
- if (!t1.equals(t2)) {
- return false;
- }
- }
- return true;
- }
- }
- }
- return false;
- }
+// public static boolean isSameMethodSignature(String name,
+// String[] paramTypes, boolean isConstructor, IMethod curr)
+// throws JavaModelException {
+// if (isConstructor || name.equals(curr.getElementName())) {
+// if (isConstructor == curr.isConstructor()) {
+// String[] currParamTypes = curr.getParameterTypes();
+// if (paramTypes.length == currParamTypes.length) {
+// for (int i = 0; i < paramTypes.length; i++) {
+// String t1 = Signature.getSimpleName(Signature
+// .toString(paramTypes[i]));
+// String t2 = Signature.getSimpleName(Signature
+// .toString(currParamTypes[i]));
+// if (!t1.equals(t2)) {
+// return false;
+// }
+// }
+// return true;
+// }
+// }
+// }
+// return false;
+// }
/**
* Checks whether the given type has a valid main method or not.
// return VISIBILITY_CODE_INVALID;
// }
- public static String getVisibilityString(int visibilityCode) {
- if (Modifier.isPublic(visibilityCode))
- return VISIBILITY_STRING_PUBLIC;
- if (Modifier.isProtected(visibilityCode))
- return VISIBILITY_STRING_PROTECTED;
- if (Modifier.isPrivate(visibilityCode))
- return VISIBILITY_STRING_PRIVATE;
- return VISIBILITY_STRING_PACKAGE;
- }
+// public static String getVisibilityString(int visibilityCode) {
+// if (Modifier.isPublic(visibilityCode))
+// return VISIBILITY_STRING_PUBLIC;
+// if (Modifier.isProtected(visibilityCode))
+// return VISIBILITY_STRING_PROTECTED;
+// if (Modifier.isPrivate(visibilityCode))
+// return VISIBILITY_STRING_PRIVATE;
+// return VISIBILITY_STRING_PACKAGE;
+// }
public static void assertVisibility(int visibility) {
Assert.isTrue(visibility == Modifier.PUBLIC
visibility == Modifier.PRIVATE);
}
- public static boolean isHigherVisibility(int newVisibility,
- int oldVisibility) {
- assertVisibility(oldVisibility);
- assertVisibility(newVisibility);
- switch (oldVisibility) {
- case Modifier.PRIVATE:
- return // newVisibility == Modifier.NONE ||
- newVisibility == Modifier.PUBLIC
- || newVisibility == Modifier.PROTECTED;
- // case Modifier.NONE :
- // return newVisibility == Modifier.PUBLIC
- // || newVisibility == Modifier.PROTECTED;
-
- case Modifier.PROTECTED:
- return newVisibility == Modifier.PUBLIC;
-
- case Modifier.PUBLIC:
- return false;
- default:
- // Assert.isTrue(false);
- return false;
- }
- }
+// public static boolean isHigherVisibility(int newVisibility,
+// int oldVisibility) {
+// assertVisibility(oldVisibility);
+// assertVisibility(newVisibility);
+// switch (oldVisibility) {
+// case Modifier.PRIVATE:
+// return // newVisibility == Modifier.NONE ||
+// newVisibility == Modifier.PUBLIC
+// || newVisibility == Modifier.PROTECTED;
+// // case Modifier.NONE :
+// // return newVisibility == Modifier.PUBLIC
+// // || newVisibility == Modifier.PROTECTED;
+//
+// case Modifier.PROTECTED:
+// return newVisibility == Modifier.PUBLIC;
+//
+// case Modifier.PUBLIC:
+// return false;
+// default:
+// // Assert.isTrue(false);
+// return false;
+// }
+// }
// public static int getLowerVisibility(int visibility1, int visibility2) {
// if (isHigherVisibility(visibility1, visibility2))
*******************************************************************************/
package net.sourceforge.phpdt.internal.corext.util;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultLineTracker;
-import org.eclipse.jface.text.ILineTracker;
-import org.eclipse.jface.text.IRegion;
+//import org.eclipse.jface.text.BadLocationException;
+//import org.eclipse.jface.text.DefaultLineTracker;
+//import org.eclipse.jface.text.ILineTracker;
+//import org.eclipse.jface.text.IRegion;
/**
* Helper class to provide String manipulation functions not available in
* doesn't contain any leading tabs or spaces then the string itself is
* returned.
*/
- public static String trimLeadingTabsAndSpaces(String line) {
- int size = line.length();
- int start = size;
- for (int i = 0; i < size; i++) {
- char c = line.charAt(i);
- if (!isIndentChar(c)) {
- start = i;
- break;
- }
- }
- if (start == 0)
- return line;
- else if (start == size)
- return ""; //$NON-NLS-1$
- else
- return line.substring(start);
- }
+// public static String trimLeadingTabsAndSpaces(String line) {
+// int size = line.length();
+// int start = size;
+// for (int i = 0; i < size; i++) {
+// char c = line.charAt(i);
+// if (!isIndentChar(c)) {
+// start = i;
+// break;
+// }
+// }
+// if (start == 0)
+// return line;
+// else if (start == size)
+// return ""; //$NON-NLS-1$
+// else
+// return line.substring(start);
+// }
// public static String trimTrailingTabsAndSpaces(String line) {
// int size = line.length();
* changed. (It is considered to have no indent as it might start in the
* middle of a line)
*/
- public static String changeIndent(String code, int codeIndentLevel,
- int tabWidth, String newIndent, String lineDelim) {
- try {
- ILineTracker tracker = new DefaultLineTracker();
- tracker.set(code);
- int nLines = tracker.getNumberOfLines();
- if (nLines == 1) {
- return code;
- }
-
- StringBuffer buf = new StringBuffer();
-
- for (int i = 0; i < nLines; i++) {
- IRegion region = tracker.getLineInformation(i);
- int start = region.getOffset();
- int end = start + region.getLength();
- String line = code.substring(start, end);
-
- if (i == 0) { // no indent for first line (contained in the
- // formatted string)
- buf.append(line);
- } else { // no new line after last line
- buf.append(lineDelim);
- buf.append(newIndent);
- buf.append(trimIndent(line, codeIndentLevel, tabWidth));
- }
- }
- return buf.toString();
- } catch (BadLocationException e) {
- // can not happen
- return code;
- }
- }
+// public static String changeIndent(String code, int codeIndentLevel,
+// int tabWidth, String newIndent, String lineDelim) {
+// try {
+// ILineTracker tracker = new DefaultLineTracker();
+// tracker.set(code);
+// int nLines = tracker.getNumberOfLines();
+// if (nLines == 1) {
+// return code;
+// }
+//
+// StringBuffer buf = new StringBuffer();
+//
+// for (int i = 0; i < nLines; i++) {
+// IRegion region = tracker.getLineInformation(i);
+// int start = region.getOffset();
+// int end = start + region.getLength();
+// String line = code.substring(start, end);
+//
+// if (i == 0) { // no indent for first line (contained in the
+// // formatted string)
+// buf.append(line);
+// } else { // no new line after last line
+// buf.append(lineDelim);
+// buf.append(newIndent);
+// buf.append(trimIndent(line, codeIndentLevel, tabWidth));
+// }
+// }
+// return buf.toString();
+// } catch (BadLocationException e) {
+// // can not happen
+// return code;
+// }
+// }
/**
* Concatenate the given strings into one strings using the passed line
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
+//import org.eclipse.core.runtime.Path;
//import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
/*private MembersOrderPreferenceCache fMembersOrderPreferenceCache;*/
- private IFile fLastEditorFile = null;
+ //private IFile fLastEditorFile = null;
/* private JavaEditorTextHoverDescriptor[] fJavaEditorTextHoverDescriptors;*/
// return getDefault().internalGetImageDescriptorRegistry();
// }
- static IPath getInstallLocation() {
- return new Path(getDefault().getBundle().getEntry("/").getFile());
- }
+// static IPath getInstallLocation() {
+// return new Path(getDefault().getBundle().getEntry("/").getFile());
+// }
// public static int getJVM() {
// return jvm;
// return fJavaTextTools;
// }
- public IFile getLastEditorFile() {
- return fLastEditorFile;
- }
+// public IFile getLastEditorFile() {
+// return fLastEditorFile;
+// }
/**
* Returns the string from the plugin's resource bundle, or 'key' if not
// }
public void setLastEditorFile(IFile textEditor) {
- this.fLastEditorFile = textEditor;
+ //this.fLastEditorFile = textEditor;
}
/*