import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWT;
+//import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IPartListener;
// IDocument document = ((ITextEditor) editorPart)
// .getDocumentProvider().getDocument(editorInput);
int lineNumber = textSelection.getStartLine() + 1;
- int offset = textSelection.getOffset();
+ //int offset = textSelection.getOffset();
try {
// if (type == null) {
// IClassFile classFile=
* @throws CoreException
* an exception throwed by the MarkerUtilities
*/
- private void setMarker(final IFile file, final String message,
- final int charStart, final int charEnd, final int errorLevel,
- final String location) throws CoreException {
- if (file != null) {
- final Hashtable attributes = new Hashtable();
- MarkerUtilities.setMessage(attributes, message);
- switch (errorLevel) {
- case ERROR:
- attributes.put(IMarker.SEVERITY, new Integer(
- IMarker.SEVERITY_ERROR));
- break;
- case WARNING:
- attributes.put(IMarker.SEVERITY, new Integer(
- IMarker.SEVERITY_WARNING));
- break;
- case INFO:
- attributes.put(IMarker.SEVERITY, new Integer(
- IMarker.SEVERITY_INFO));
- break;
- case TASK:
- attributes.put(IMarker.SEVERITY, new Integer(IMarker.TASK));
- break;
- }
- attributes.put(IMarker.LOCATION, location);
- MarkerUtilities.setCharStart(attributes, charStart);
- MarkerUtilities.setCharEnd(attributes, charEnd);
- MarkerUtilities.createMarker(file, attributes, PROBLEM_ID); // IMarker.PROBLEM);
- }
- }
+// private void setMarker(final IFile file, final String message,
+// final int charStart, final int charEnd, final int errorLevel,
+// final String location) throws CoreException {
+// if (file != null) {
+// final Hashtable attributes = new Hashtable();
+// MarkerUtilities.setMessage(attributes, message);
+// switch (errorLevel) {
+// case ERROR:
+// attributes.put(IMarker.SEVERITY, new Integer(
+// IMarker.SEVERITY_ERROR));
+// break;
+// case WARNING:
+// attributes.put(IMarker.SEVERITY, new Integer(
+// IMarker.SEVERITY_WARNING));
+// break;
+// case INFO:
+// attributes.put(IMarker.SEVERITY, new Integer(
+// IMarker.SEVERITY_INFO));
+// break;
+// case TASK:
+// attributes.put(IMarker.SEVERITY, new Integer(IMarker.TASK));
+// break;
+// }
+// attributes.put(IMarker.LOCATION, location);
+// MarkerUtilities.setCharStart(attributes, charStart);
+// MarkerUtilities.setCharEnd(attributes, charEnd);
+// MarkerUtilities.createMarker(file, attributes, PROBLEM_ID); // IMarker.PROBLEM);
+// }
+// }
private String getParserOutput(String command, String consoleMessage) {
try {
private MessageConsoleStream stream;
- private boolean hasMessages;
+ //private boolean hasMessages;
public PHPConsole() {
- hasMessages = false;
+ //hasMessages = false;
myConsole = new MessageConsole("PHPeclipse Console", null);
ConsolePlugin.getDefault().getConsoleManager().addConsoles(
new IConsole[] { myConsole });
* @param message
*/
public void print(String message) {
- hasMessages = true;
+ //hasMessages = true;
stream.print(message);
}
*
*/
public void println() {
- hasMessages = true;
+ //hasMessages = true;
stream.println();
}
* @param message
*/
public void println(String message) {
- hasMessages = true;
+ //hasMessages = true;
stream.println(message);
}
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.jface.text,
- org.eclipse.ui.workbench.texteditor,
net.sourceforge.phpeclipse,
net.sourceforge.phpeclipse.debug.core,
org.eclipse.debug.ui,
package net.sourceforge.phpdt.internal.launching;
-import net.sourceforge.phpdt.core.JavaModelException;
-import net.sourceforge.phpeclipse.phpeditor.EditorUtility;
+//import net.sourceforge.phpdt.core.JavaModelException;
+//import net.sourceforge.phpeclipse.phpeditor.EditorUtility;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
+//import org.eclipse.core.resources.IFile;
+//import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.ui.console.IConsole;
import org.eclipse.debug.ui.console.IConsoleLineTracker;
import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
+//import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.texteditor.ITextEditor;
+//import org.eclipse.ui.IEditorPart;
+//import org.eclipse.ui.PartInitException;
+//import org.eclipse.ui.texteditor.ITextEditor;
public class ConsoleLineTracker implements IConsoleLineTracker {
- private static class JavadocConsoleHyperLink /*
- * TODO XXX Disabled for 3.1
- * implements
- * IConsoleHyperlink
- */{
-
- private IPath fExternalPath;
-
- private int fLineNumber;
-
- public JavadocConsoleHyperLink(IPath externalPath, int lineNumber) {
- fExternalPath = externalPath;
- fLineNumber = lineNumber;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.ui.console.IConsoleHyperlink#linkEntered()
- */
- public void linkEntered() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.ui.console.IConsoleHyperlink#linkExited()
- */
- public void linkExited() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.ui.console.IConsoleHyperlink#linkActivated()
- */
- public void linkActivated() {
- try {
- IFile[] files = ResourcesPlugin.getWorkspace().getRoot()
- .findFilesForLocation(fExternalPath);
- if (files.length > 0) {
- for (int i = 0; i < files.length; i++) {
- IFile curr = files[0];
- IEditorPart part = EditorUtility.openInEditor(curr,
- true);
- if (part != null) {
- if (part instanceof ITextEditor) {
- revealLine((ITextEditor) part, fLineNumber);
- }
- return;
- }
- }
- }
- } catch (BadLocationException e) {
- PHPLaunchingPlugin.log(e);
- } catch (PartInitException e) {
- PHPLaunchingPlugin.log(e);
- } catch (JavaModelException e) {
- PHPLaunchingPlugin.log(e);
- }
- }
-
- private void revealLine(ITextEditor editor, int lineNumber)
- throws BadLocationException {
- IDocument document = editor.getDocumentProvider().getDocument(
- editor.getEditorInput());
- IRegion region = document.getLineInformation(lineNumber - 1);
- editor.selectAndReveal(region.getOffset(), 0);
- }
-
- }
+// private static class JavadocConsoleHyperLink /*
+// * TODO XXX Disabled for 3.1
+// * implements
+// * IConsoleHyperlink
+// */{
+//
+// private IPath fExternalPath;
+//
+// private int fLineNumber;
+//
+// public JavadocConsoleHyperLink(IPath externalPath, int lineNumber) {
+// fExternalPath = externalPath;
+// fLineNumber = lineNumber;
+// }
+//
+// /*
+// * (non-Javadoc)
+// *
+// * @see org.eclipse.debug.ui.console.IConsoleHyperlink#linkEntered()
+// */
+// public void linkEntered() {
+// }
+//
+// /*
+// * (non-Javadoc)
+// *
+// * @see org.eclipse.debug.ui.console.IConsoleHyperlink#linkExited()
+// */
+// public void linkExited() {
+// }
+//
+// /*
+// * (non-Javadoc)
+// *
+// * @see org.eclipse.debug.ui.console.IConsoleHyperlink#linkActivated()
+// */
+// public void linkActivated() {
+// try {
+// IFile[] files = ResourcesPlugin.getWorkspace().getRoot()
+// .findFilesForLocation(fExternalPath);
+// if (files.length > 0) {
+// for (int i = 0; i < files.length; i++) {
+// IFile curr = files[0];
+// IEditorPart part = EditorUtility.openInEditor(curr,
+// true);
+// if (part != null) {
+// if (part instanceof ITextEditor) {
+// revealLine((ITextEditor) part, fLineNumber);
+// }
+// return;
+// }
+// }
+// }
+// } catch (BadLocationException e) {
+// PHPLaunchingPlugin.log(e);
+// } catch (PartInitException e) {
+// PHPLaunchingPlugin.log(e);
+// } catch (JavaModelException e) {
+// PHPLaunchingPlugin.log(e);
+// }
+// }
+//
+// private void revealLine(ITextEditor editor, int lineNumber)
+// throws BadLocationException {
+// IDocument document = editor.getDocumentProvider().getDocument(
+// editor.getEditorInput());
+// IRegion region = document.getLineInformation(lineNumber - 1);
+// editor.selectAndReveal(region.getOffset(), 0);
+// }
+//
+// }
private IConsole fConsole;
private Button okButton;
- private Text fName;
+ //private Text fName;
- private Text fUrl;
+ //private Text fUrl;
// private Text fPassword;
// WorkbenchHelp.setHelp(composite, ContextIds.PREF_DIALOG);
createLabel(composite, PHPHelpPlugin.getResource("%name"));
- fName = createText(composite, fConfiguration.getName() + "",
- new StringModifyListener() {
- public void valueChanged(String name) {
- fConfiguration.setName(name);
- validateFields();
- }
- });
+// fName = createText(composite, fConfiguration.getName() + "",
+// new StringModifyListener() {
+// public void valueChanged(String name) {
+// fConfiguration.setName(name);
+// validateFields();
+// }
+// });
Group group = new Group(composite, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
// });
createLabel(group, PHPHelpPlugin.getResource("%url"));
- fUrl = createText(group, fConfiguration.getURL(),
- new StringModifyListener() {
- public void valueChanged(String s) {
- fConfiguration.setURL(s);
- validateFields();
- }
- });
+// fUrl = createText(group, fConfiguration.getURL(),
+// new StringModifyListener() {
+// public void valueChanged(String s) {
+// fConfiguration.setURL(s);
+// validateFields();
+// }
+// });
createLabel(group, PHPHelpPlugin.getResource("%parseType"));
createTypeCombo(group, PHPHelpPlugin.getTypes(), fConfiguration
org.eclipse.jface.text,
net.sourceforge.phpeclipse.ui,
org.eclipse.ui.editors;bundle-version="3.4.0",
- org.eclipse.core.resources;bundle-version="3.4.1",
org.eclipse.core.runtime;bundle-version="3.4.0",
org.eclipse.ui.ide
Bundle-RequiredExecutionEnvironment: J2SE-1.4
*******************************************************************************/
package net.sourceforge.phpdt.internal.corext.codemanipulation;
-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);
+// }
}
*******************************************************************************/
package net.sourceforge.phpdt.internal.corext.codemanipulation;
-import net.sourceforge.phpdt.core.Flags;
+//import net.sourceforge.phpdt.core.Flags;
import net.sourceforge.phpdt.core.IField;
import net.sourceforge.phpdt.core.IJavaProject;
-import net.sourceforge.phpdt.core.IMethod;
-import net.sourceforge.phpdt.core.IType;
+//import net.sourceforge.phpdt.core.IMethod;
+//import net.sourceforge.phpdt.core.IType;
import net.sourceforge.phpdt.core.JavaModelException;
import net.sourceforge.phpdt.core.NamingConventions;
-import net.sourceforge.phpdt.core.Signature;
+//import net.sourceforge.phpdt.core.Signature;
import net.sourceforge.phpdt.internal.corext.util.JavaModelUtil;
-import net.sourceforge.phpdt.internal.corext.util.JdtFlags;
-import net.sourceforge.phpdt.ui.CodeGeneration;
-import net.sourceforge.phpdt.ui.PreferenceConstants;
+//import net.sourceforge.phpdt.internal.corext.util.JdtFlags;
+//import net.sourceforge.phpdt.ui.CodeGeneration;
+//import net.sourceforge.phpdt.ui.PreferenceConstants;
-import org.eclipse.core.runtime.CoreException;
+//import org.eclipse.core.runtime.CoreException;
public class GetterSetterUtil {
private GetterSetterUtil() {
}
- public static String getGetterName(IField field, String[] excludedNames)
- throws JavaModelException {
- boolean useIs = PreferenceConstants.getPreferenceStore().getBoolean(
- PreferenceConstants.CODEGEN_IS_FOR_GETTERS);
- return getGetterName(field, excludedNames, useIs);
- }
-
- private static String getGetterName(IField field, String[] excludedNames,
- boolean useIsForBoolGetters) throws JavaModelException {
- if (excludedNames == null) {
- excludedNames = EMPTY;
- }
- return getGetterName(field.getJavaProject(), field.getElementName(),
- field.getFlags(), useIsForBoolGetters
- && JavaModelUtil.isBoolean(field), excludedNames);
- }
+// public static String getGetterName(IField field, String[] excludedNames)
+// throws JavaModelException {
+// boolean useIs = PreferenceConstants.getPreferenceStore().getBoolean(
+// PreferenceConstants.CODEGEN_IS_FOR_GETTERS);
+// return getGetterName(field, excludedNames, useIs);
+// }
+
+// private static String getGetterName(IField field, String[] excludedNames,
+// boolean useIsForBoolGetters) throws JavaModelException {
+// if (excludedNames == null) {
+// excludedNames = EMPTY;
+// }
+// return getGetterName(field.getJavaProject(), field.getElementName(),
+// field.getFlags(), useIsForBoolGetters
+// && JavaModelUtil.isBoolean(field), excludedNames);
+// }
public static String getGetterName(IJavaProject project, String fieldName,
int flags, boolean isBoolean, String[] excludedNames) {
isBoolean, excludedNames);
}
- public static String getSetterName(IJavaProject project, String fieldName,
- int flags, boolean isBoolean, String[] excludedNames) {
- return NamingConventions.suggestSetterName(project, fieldName, flags,
- isBoolean, excludedNames);
- }
+// public static String getSetterName(IJavaProject project, String fieldName,
+// int flags, boolean isBoolean, String[] excludedNames) {
+// return NamingConventions.suggestSetterName(project, fieldName, flags,
+// isBoolean, excludedNames);
+// }
public static String getSetterName(IField field, String[] excludedNames)
throws JavaModelException {
.isBoolean(field), excludedNames);
}
- public static IMethod getGetter(IField field) throws JavaModelException {
- IMethod primaryCandidate = JavaModelUtil.findMethod(getGetterName(
- field, EMPTY, true), new String[0], false, field
- .getDeclaringType());
- if (!JavaModelUtil.isBoolean(field)
- || (primaryCandidate != null && primaryCandidate.exists()))
- return primaryCandidate;
- // bug 30906 describes why we need to look for other alternatives here
- String secondCandidateName = getGetterName(field, EMPTY, false);
- return JavaModelUtil.findMethod(secondCandidateName, new String[0],
- false, field.getDeclaringType());
- }
-
- public static IMethod getSetter(IField field) throws JavaModelException {
- String[] args = new String[] { field.getTypeSignature() };
- return JavaModelUtil.findMethod(getSetterName(field, EMPTY), args,
- false, field.getDeclaringType());
- }
+// public static IMethod getGetter(IField field) throws JavaModelException {
+// IMethod primaryCandidate = JavaModelUtil.findMethod(getGetterName(
+// field, EMPTY, true), new String[0], false, field
+// .getDeclaringType());
+// if (!JavaModelUtil.isBoolean(field)
+// || (primaryCandidate != null && primaryCandidate.exists()))
+// return primaryCandidate;
+// // bug 30906 describes why we need to look for other alternatives here
+// String secondCandidateName = getGetterName(field, EMPTY, false);
+// return JavaModelUtil.findMethod(secondCandidateName, new String[0],
+// false, field.getDeclaringType());
+// }
+
+// public static IMethod getSetter(IField field) throws JavaModelException {
+// String[] args = new String[] { field.getTypeSignature() };
+// return JavaModelUtil.findMethod(getSetterName(field, EMPTY), args,
+// false, field.getDeclaringType());
+// }
/**
* Create a stub for a getter of the given field using getter/setter
* @return Returns the generated stub.
* @throws CoreException
*/
- public static String getSetterStub(IField field, String setterName,
- boolean addComments, int flags) throws CoreException {
-
- String fieldName = field.getElementName();
- IType parentType = field.getDeclaringType();
-
- String returnSig = field.getTypeSignature();
- String typeName = Signature.toString(returnSig);
-
- IJavaProject project = field.getJavaProject();
-
- String accessorName = NamingConventions
- .removePrefixAndSuffixForFieldName(project, fieldName, field
- .getFlags());
- String argname = StubUtility.suggestArgumentName(project, accessorName,
- EMPTY);
-
- boolean isStatic = Flags.isStatic(flags);
- // boolean isSync= Flags.isSynchronized(flags);
- boolean isFinal = Flags.isFinal(flags);
-
- // create the setter stub
- StringBuffer buf = new StringBuffer();
- if (addComments) {
- String comment = CodeGeneration.getSetterComment(field
- .getCompilationUnit(),
- parentType.getTypeQualifiedName('.'), setterName, field
- .getElementName(), typeName, argname, accessorName,
- String.valueOf('\n'));
- if (comment != null) {
- buf.append(comment);
- buf.append('\n');
- }
- }
- buf.append(JdtFlags.getVisibilityString(flags));
- buf.append(' ');
- if (isStatic)
- buf.append("static "); //$NON-NLS-1$
- // if (isSync)
- // buf.append("synchronized "); //$NON-NLS-1$
- if (isFinal)
- buf.append("final "); //$NON-NLS-1$
-
- buf.append("void "); //$NON-NLS-1$
- buf.append(setterName);
- buf.append('(');
- buf.append(typeName);
- buf.append(' ');
- buf.append(argname);
- buf.append(") {\n"); //$NON-NLS-1$
-
- boolean useThis = PreferenceConstants.getPreferenceStore().getBoolean(
- PreferenceConstants.CODEGEN_KEYWORD_THIS);
- if (argname.equals(fieldName) || (useThis && !isStatic)) {
- if (isStatic)
- fieldName = parentType.getElementName() + '.' + fieldName;
- else
- fieldName = "this." + fieldName; //$NON-NLS-1$
- }
- String body = CodeGeneration.getSetterMethodBodyContent(field
- .getCompilationUnit(), parentType.getTypeQualifiedName('.'),
- setterName, fieldName, argname, String.valueOf('\n'));
- if (body != null) {
- buf.append(body);
- }
- buf.append("}\n"); //$NON-NLS-1$
- return buf.toString();
- }
+// public static String getSetterStub(IField field, String setterName,
+// boolean addComments, int flags) throws CoreException {
+//
+// String fieldName = field.getElementName();
+// IType parentType = field.getDeclaringType();
+//
+// String returnSig = field.getTypeSignature();
+// String typeName = Signature.toString(returnSig);
+//
+// IJavaProject project = field.getJavaProject();
+//
+// String accessorName = NamingConventions
+// .removePrefixAndSuffixForFieldName(project, fieldName, field
+// .getFlags());
+// String argname = StubUtility.suggestArgumentName(project, accessorName,
+// EMPTY);
+//
+// boolean isStatic = Flags.isStatic(flags);
+// // boolean isSync= Flags.isSynchronized(flags);
+// boolean isFinal = Flags.isFinal(flags);
+//
+// // create the setter stub
+// StringBuffer buf = new StringBuffer();
+// if (addComments) {
+// String comment = CodeGeneration.getSetterComment(field
+// .getCompilationUnit(),
+// parentType.getTypeQualifiedName('.'), setterName, field
+// .getElementName(), typeName, argname, accessorName,
+// String.valueOf('\n'));
+// if (comment != null) {
+// buf.append(comment);
+// buf.append('\n');
+// }
+// }
+// buf.append(JdtFlags.getVisibilityString(flags));
+// buf.append(' ');
+// if (isStatic)
+// buf.append("static "); //$NON-NLS-1$
+// // if (isSync)
+// // buf.append("synchronized "); //$NON-NLS-1$
+// if (isFinal)
+// buf.append("final "); //$NON-NLS-1$
+//
+// buf.append("void "); //$NON-NLS-1$
+// buf.append(setterName);
+// buf.append('(');
+// buf.append(typeName);
+// buf.append(' ');
+// buf.append(argname);
+// buf.append(") {\n"); //$NON-NLS-1$
+//
+// boolean useThis = PreferenceConstants.getPreferenceStore().getBoolean(
+// PreferenceConstants.CODEGEN_KEYWORD_THIS);
+// if (argname.equals(fieldName) || (useThis && !isStatic)) {
+// if (isStatic)
+// fieldName = parentType.getElementName() + '.' + fieldName;
+// else
+// fieldName = "this." + fieldName; //$NON-NLS-1$
+// }
+// String body = CodeGeneration.getSetterMethodBodyContent(field
+// .getCompilationUnit(), parentType.getTypeQualifiedName('.'),
+// setterName, fieldName, argname, String.valueOf('\n'));
+// if (body != null) {
+// buf.append(body);
+// }
+// buf.append("}\n"); //$NON-NLS-1$
+// return buf.toString();
+// }
/**
* Create a stub for a getter of the given field using getter/setter
* @return Returns the generated stub.
* @throws CoreException
*/
- public static String getGetterStub(IField field, String getterName,
- boolean addComments, int flags) throws CoreException {
- String fieldName = field.getElementName();
- IType parentType = field.getDeclaringType();
-
- boolean isStatic = Flags.isStatic(flags);
- // boolean isSync= Flags.isSynchronized(flags);
- boolean isFinal = Flags.isFinal(flags);
-
- String typeName = Signature.toString(field.getTypeSignature());
- String accessorName = NamingConventions
- .removePrefixAndSuffixForFieldName(field.getJavaProject(),
- fieldName, field.getFlags());
-
- // create the getter stub
- StringBuffer buf = new StringBuffer();
- if (addComments) {
- String comment = CodeGeneration.getGetterComment(field
- .getCompilationUnit(),
- parentType.getTypeQualifiedName('.'), getterName, field
- .getElementName(), typeName, accessorName, String
- .valueOf('\n'));
- if (comment != null) {
- buf.append(comment);
- buf.append('\n');
- }
- }
-
- buf.append(JdtFlags.getVisibilityString(flags));
- buf.append(' ');
- if (isStatic)
- buf.append("static "); //$NON-NLS-1$
- // if (isSync)
- // buf.append("synchronized "); //$NON-NLS-1$
- if (isFinal)
- buf.append("final "); //$NON-NLS-1$
-
- buf.append(typeName);
- buf.append(' ');
- buf.append(getterName);
- buf.append("() {\n"); //$NON-NLS-1$
-
- boolean useThis = PreferenceConstants.getPreferenceStore().getBoolean(
- PreferenceConstants.CODEGEN_KEYWORD_THIS);
- if (useThis && !isStatic) {
- fieldName = "this." + fieldName; //$NON-NLS-1$
- }
-
- String body = CodeGeneration.getGetterMethodBodyContent(field
- .getCompilationUnit(), parentType.getTypeQualifiedName('.'),
- getterName, fieldName, String.valueOf('\n'));
- if (body != null) {
- buf.append(body);
- }
- buf.append("}\n"); //$NON-NLS-1$
- return buf.toString();
- }
+// public static String getGetterStub(IField field, String getterName,
+// boolean addComments, int flags) throws CoreException {
+// String fieldName = field.getElementName();
+// IType parentType = field.getDeclaringType();
+//
+// boolean isStatic = Flags.isStatic(flags);
+// // boolean isSync= Flags.isSynchronized(flags);
+// boolean isFinal = Flags.isFinal(flags);
+//
+// String typeName = Signature.toString(field.getTypeSignature());
+// String accessorName = NamingConventions
+// .removePrefixAndSuffixForFieldName(field.getJavaProject(),
+// fieldName, field.getFlags());
+//
+// // create the getter stub
+// StringBuffer buf = new StringBuffer();
+// if (addComments) {
+// String comment = CodeGeneration.getGetterComment(field
+// .getCompilationUnit(),
+// parentType.getTypeQualifiedName('.'), getterName, field
+// .getElementName(), typeName, accessorName, String
+// .valueOf('\n'));
+// if (comment != null) {
+// buf.append(comment);
+// buf.append('\n');
+// }
+// }
+//
+// buf.append(JdtFlags.getVisibilityString(flags));
+// buf.append(' ');
+// if (isStatic)
+// buf.append("static "); //$NON-NLS-1$
+// // if (isSync)
+// // buf.append("synchronized "); //$NON-NLS-1$
+// if (isFinal)
+// buf.append("final "); //$NON-NLS-1$
+//
+// buf.append(typeName);
+// buf.append(' ');
+// buf.append(getterName);
+// buf.append("() {\n"); //$NON-NLS-1$
+//
+// boolean useThis = PreferenceConstants.getPreferenceStore().getBoolean(
+// PreferenceConstants.CODEGEN_KEYWORD_THIS);
+// if (useThis && !isStatic) {
+// fieldName = "this." + fieldName; //$NON-NLS-1$
+// }
+//
+// String body = CodeGeneration.getGetterMethodBodyContent(field
+// .getCompilationUnit(), parentType.getTypeQualifiedName('.'),
+// getterName, fieldName, String.valueOf('\n'));
+// if (body != null) {
+// buf.append(body);
+// }
+// buf.append("}\n"); //$NON-NLS-1$
+// return buf.toString();
+// }
}
//import java.util.Arrays;
//import java.util.Comparator;
//import java.util.List;
-import java.util.StringTokenizer;
+//import java.util.StringTokenizer;
-import net.sourceforge.phpdt.core.Flags;
-import net.sourceforge.phpdt.core.IBuffer;
+//import net.sourceforge.phpdt.core.Flags;
+//import net.sourceforge.phpdt.core.IBuffer;
import net.sourceforge.phpdt.core.ICodeFormatter;
import net.sourceforge.phpdt.core.ICompilationUnit;
-import net.sourceforge.phpdt.core.IJavaElement;
+//import net.sourceforge.phpdt.core.IJavaElement;
import net.sourceforge.phpdt.core.IJavaProject;
import net.sourceforge.phpdt.core.IMethod;
import net.sourceforge.phpdt.core.IPackageFragment;
import org.eclipse.jface.text.templates.TemplateBuffer;
import org.eclipse.jface.text.templates.TemplateException;
import org.eclipse.jface.text.templates.TemplateVariable;
-import org.eclipse.swt.SWT;
+//import org.eclipse.swt.SWT;
public class StubUtility {
* type names are qualified.
* @throws JavaModelException
*/
- public static String genStub(ICompilationUnit cu, String destTypeName,
- IMethod method, IType definingType, GenStubSettings settings)
- throws CoreException {
- // IImportsStructure imports) throws CoreException {
- String methName = method.getElementName();
- String[] paramNames = suggestArgumentNames(method.getJavaProject(),
- method.getParameterNames());
- String returnType = method.isConstructor() ? null : method
- .getReturnType();
- String lineDelimiter = String.valueOf('\n'); // reformatting required
-
- StringBuffer buf = new StringBuffer();
- // add method comment
- if (settings.createComments && cu != null) {
- IMethod overridden = null;
- if (settings.methodOverwrites && returnType != null) {
- overridden = JavaModelUtil.findMethod(methName, method
- .getParameterTypes(), false, definingType.getMethods());
- }
- String comment = getMethodComment(cu, destTypeName, methName,
- paramNames, method.getExceptionTypes(), returnType,
- overridden, lineDelimiter);
- if (comment != null) {
- buf.append(comment);
- } else {
- buf.append("/**").append(lineDelimiter); //$NON-NLS-1$
- buf.append(" *").append(lineDelimiter); //$NON-NLS-1$
- buf.append(" */").append(lineDelimiter); //$NON-NLS-1$
- }
- buf.append(lineDelimiter);
- }
- // add method declaration
- String bodyContent = null;
- if (!settings.noBody) {
- String bodyStatement = getDefaultMethodBodyStatement(methName,
- paramNames, returnType, settings.callSuper);
- bodyContent = getMethodBodyContent(returnType == null, method
- .getJavaProject(), destTypeName, methName, bodyStatement,
- lineDelimiter);
- if (bodyContent == null) {
- bodyContent = ""; //$NON-NLS-1$
- }
- }
- int flags = settings.methodModifiers;
- if (flags == -1) {
- flags = method.getFlags();
- }
-
- genMethodDeclaration(destTypeName, method, flags, bodyContent, buf); // imports,
- // buf);
- return buf.toString();
- }
+// public static String genStub(ICompilationUnit cu, String destTypeName,
+// IMethod method, IType definingType, GenStubSettings settings)
+// throws CoreException {
+// // IImportsStructure imports) throws CoreException {
+// String methName = method.getElementName();
+// String[] paramNames = suggestArgumentNames(method.getJavaProject(),
+// method.getParameterNames());
+// String returnType = method.isConstructor() ? null : method
+// .getReturnType();
+// String lineDelimiter = String.valueOf('\n'); // reformatting required
+//
+// StringBuffer buf = new StringBuffer();
+// // add method comment
+// if (settings.createComments && cu != null) {
+// IMethod overridden = null;
+// if (settings.methodOverwrites && returnType != null) {
+// overridden = JavaModelUtil.findMethod(methName, method
+// .getParameterTypes(), false, definingType.getMethods());
+// }
+// String comment = getMethodComment(cu, destTypeName, methName,
+// paramNames, method.getExceptionTypes(), returnType,
+// overridden, lineDelimiter);
+// if (comment != null) {
+// buf.append(comment);
+// } else {
+// buf.append("/**").append(lineDelimiter); //$NON-NLS-1$
+// buf.append(" *").append(lineDelimiter); //$NON-NLS-1$
+// buf.append(" */").append(lineDelimiter); //$NON-NLS-1$
+// }
+// buf.append(lineDelimiter);
+// }
+// // add method declaration
+// String bodyContent = null;
+// if (!settings.noBody) {
+// String bodyStatement = getDefaultMethodBodyStatement(methName,
+// paramNames, returnType, settings.callSuper);
+// bodyContent = getMethodBodyContent(returnType == null, method
+// .getJavaProject(), destTypeName, methName, bodyStatement,
+// lineDelimiter);
+// if (bodyContent == null) {
+// bodyContent = ""; //$NON-NLS-1$
+// }
+// }
+// int flags = settings.methodModifiers;
+// if (flags == -1) {
+// flags = method.getFlags();
+// }
+//
+// genMethodDeclaration(destTypeName, method, flags, bodyContent, buf); // imports,
+// // buf);
+// return buf.toString();
+// }
/**
* Generates a method stub not including the method comment. Given a
* The buffer to append the gerenated code.
* @throws JavaModelException
*/
- public static void genMethodDeclaration(String destTypeName,
- IMethod method, String bodyContent, StringBuffer buf)
- throws CoreException { // IImportsStructure imports, StringBuffer
- // buf) throws CoreException {
- genMethodDeclaration(destTypeName, method, method.getFlags(),
- bodyContent, buf);
- }
+// public static void genMethodDeclaration(String destTypeName,
+// IMethod method, String bodyContent, StringBuffer buf)
+// throws CoreException { // IImportsStructure imports, StringBuffer
+// // buf) throws CoreException {
+// genMethodDeclaration(destTypeName, method, method.getFlags(),
+// bodyContent, buf);
+// }
/**
* Generates a method stub not including the method comment. Given a
* The buffer to append the gerenated code.
* @throws JavaModelException
*/
- public static void genMethodDeclaration(String destTypeName,
- IMethod method, int flags, String bodyContent, StringBuffer buf)
- throws CoreException {
- // IImportsStructure imports, StringBuffer buf) throws CoreException {
- IType parentType = method.getDeclaringType();
- String methodName = method.getElementName();
- String[] paramTypes = method.getParameterTypes();
- String[] paramNames = suggestArgumentNames(parentType.getJavaProject(),
- method.getParameterNames());
-
- String[] excTypes = method.getExceptionTypes();
-
- boolean isConstructor = method.isConstructor();
- String retTypeSig = isConstructor ? null : method.getReturnType();
-
- int lastParam = paramTypes.length - 1;
-
- if (Flags.isPublic(flags)
- || (parentType.isInterface() && bodyContent != null)) {
- buf.append("public "); //$NON-NLS-1$
- } else if (Flags.isProtected(flags)) {
- buf.append("protected "); //$NON-NLS-1$
- } else if (Flags.isPrivate(flags)) {
- buf.append("private "); //$NON-NLS-1$
- }
- // if (Flags.isSynchronized(flags)) {
- // buf.append("synchronized "); //$NON-NLS-1$
- // }
- // if (Flags.isVolatile(flags)) {
- // buf.append("volatile "); //$NON-NLS-1$
- // }
- // if (Flags.isStrictfp(flags)) {
- // buf.append("strictfp "); //$NON-NLS-1$
- // }
- if (Flags.isStatic(flags)) {
- buf.append("static "); //$NON-NLS-1$
- }
-
- if (isConstructor) {
- buf.append(destTypeName);
- } else {
- String retTypeFrm;
- if (!isPrimitiveType(retTypeSig)) {
- retTypeFrm = resolveAndAdd(retTypeSig, parentType);
- } else {
- retTypeFrm = Signature.toString(retTypeSig);
- }
- buf.append(retTypeFrm);
- buf.append(' ');
- buf.append(methodName);
- }
- buf.append('(');
- for (int i = 0; i <= lastParam; i++) {
- String paramTypeSig = paramTypes[i];
- String paramTypeFrm;
-
- if (!isPrimitiveType(paramTypeSig)) {
- paramTypeFrm = resolveAndAdd(paramTypeSig, parentType);
- } else {
- paramTypeFrm = Signature.toString(paramTypeSig);
- }
- buf.append(paramTypeFrm);
- buf.append(' ');
- buf.append(paramNames[i]);
- if (i < lastParam) {
- buf.append(", "); //$NON-NLS-1$
- }
- }
- buf.append(')');
-
- int lastExc = excTypes.length - 1;
- if (lastExc >= 0) {
- buf.append(" throws "); //$NON-NLS-1$
- for (int i = 0; i <= lastExc; i++) {
- String excTypeSig = excTypes[i];
- String excTypeFrm = resolveAndAdd(excTypeSig, parentType);
- buf.append(excTypeFrm);
- if (i < lastExc) {
- buf.append(", "); //$NON-NLS-1$
- }
- }
- }
- if (bodyContent == null) {
- buf.append(";\n\n"); //$NON-NLS-1$
- } else {
- buf.append(" {\n\t"); //$NON-NLS-1$
- if ((bodyContent != null) && (bodyContent.length() > 0)) {
- buf.append(bodyContent);
- buf.append('\n');
- }
- buf.append("}\n"); //$NON-NLS-1$
- }
- }
+// public static void genMethodDeclaration(String destTypeName,
+// IMethod method, int flags, String bodyContent, StringBuffer buf)
+// throws CoreException {
+// // IImportsStructure imports, StringBuffer buf) throws CoreException {
+// IType parentType = method.getDeclaringType();
+// String methodName = method.getElementName();
+// String[] paramTypes = method.getParameterTypes();
+// String[] paramNames = suggestArgumentNames(parentType.getJavaProject(),
+// method.getParameterNames());
+//
+// String[] excTypes = method.getExceptionTypes();
+//
+// boolean isConstructor = method.isConstructor();
+// String retTypeSig = isConstructor ? null : method.getReturnType();
+//
+// int lastParam = paramTypes.length - 1;
+//
+// if (Flags.isPublic(flags)
+// || (parentType.isInterface() && bodyContent != null)) {
+// buf.append("public "); //$NON-NLS-1$
+// } else if (Flags.isProtected(flags)) {
+// buf.append("protected "); //$NON-NLS-1$
+// } else if (Flags.isPrivate(flags)) {
+// buf.append("private "); //$NON-NLS-1$
+// }
+// // if (Flags.isSynchronized(flags)) {
+// // buf.append("synchronized "); //$NON-NLS-1$
+// // }
+// // if (Flags.isVolatile(flags)) {
+// // buf.append("volatile "); //$NON-NLS-1$
+// // }
+// // if (Flags.isStrictfp(flags)) {
+// // buf.append("strictfp "); //$NON-NLS-1$
+// // }
+// if (Flags.isStatic(flags)) {
+// buf.append("static "); //$NON-NLS-1$
+// }
+//
+// if (isConstructor) {
+// buf.append(destTypeName);
+// } else {
+// String retTypeFrm;
+// if (!isPrimitiveType(retTypeSig)) {
+// retTypeFrm = resolveAndAdd(retTypeSig, parentType);
+// } else {
+// retTypeFrm = Signature.toString(retTypeSig);
+// }
+// buf.append(retTypeFrm);
+// buf.append(' ');
+// buf.append(methodName);
+// }
+// buf.append('(');
+// for (int i = 0; i <= lastParam; i++) {
+// String paramTypeSig = paramTypes[i];
+// String paramTypeFrm;
+//
+// if (!isPrimitiveType(paramTypeSig)) {
+// paramTypeFrm = resolveAndAdd(paramTypeSig, parentType);
+// } else {
+// paramTypeFrm = Signature.toString(paramTypeSig);
+// }
+// buf.append(paramTypeFrm);
+// buf.append(' ');
+// buf.append(paramNames[i]);
+// if (i < lastParam) {
+// buf.append(", "); //$NON-NLS-1$
+// }
+// }
+// buf.append(')');
+//
+// int lastExc = excTypes.length - 1;
+// if (lastExc >= 0) {
+// buf.append(" throws "); //$NON-NLS-1$
+// for (int i = 0; i <= lastExc; i++) {
+// String excTypeSig = excTypes[i];
+// String excTypeFrm = resolveAndAdd(excTypeSig, parentType);
+// buf.append(excTypeFrm);
+// if (i < lastExc) {
+// buf.append(", "); //$NON-NLS-1$
+// }
+// }
+// }
+// if (bodyContent == null) {
+// buf.append(";\n\n"); //$NON-NLS-1$
+// } else {
+// buf.append(" {\n\t"); //$NON-NLS-1$
+// if ((bodyContent != null) && (bodyContent.length() > 0)) {
+// buf.append(bodyContent);
+// buf.append('\n');
+// }
+// buf.append("}\n"); //$NON-NLS-1$
+// }
+// }
- public static String getDefaultMethodBodyStatement(String methodName,
- String[] paramNames, String retTypeSig, boolean callSuper) {
- StringBuffer buf = new StringBuffer();
- if (callSuper) {
- if (retTypeSig != null) {
- if (!Signature.SIG_VOID.equals(retTypeSig)) {
- buf.append("return "); //$NON-NLS-1$
- }
- buf.append("super."); //$NON-NLS-1$
- buf.append(methodName);
- } else {
- buf.append("super"); //$NON-NLS-1$
- }
- buf.append('(');
- for (int i = 0; i < paramNames.length; i++) {
- if (i > 0) {
- buf.append(", "); //$NON-NLS-1$
- }
- buf.append(paramNames[i]);
- }
- buf.append(");"); //$NON-NLS-1$
- } else {
- if (retTypeSig != null && !retTypeSig.equals(Signature.SIG_VOID)) {
- if (!isPrimitiveType(retTypeSig)
- || Signature.getArrayCount(retTypeSig) > 0) {
- buf.append("return null;"); //$NON-NLS-1$
- } else if (retTypeSig.equals(Signature.SIG_BOOLEAN)) {
- buf.append("return false;"); //$NON-NLS-1$
- } else {
- buf.append("return 0;"); //$NON-NLS-1$
- }
- }
- }
- return buf.toString();
- }
+// public static String getDefaultMethodBodyStatement(String methodName,
+// String[] paramNames, String retTypeSig, boolean callSuper) {
+// StringBuffer buf = new StringBuffer();
+// if (callSuper) {
+// if (retTypeSig != null) {
+// if (!Signature.SIG_VOID.equals(retTypeSig)) {
+// buf.append("return "); //$NON-NLS-1$
+// }
+// buf.append("super."); //$NON-NLS-1$
+// buf.append(methodName);
+// } else {
+// buf.append("super"); //$NON-NLS-1$
+// }
+// buf.append('(');
+// for (int i = 0; i < paramNames.length; i++) {
+// if (i > 0) {
+// buf.append(", "); //$NON-NLS-1$
+// }
+// buf.append(paramNames[i]);
+// }
+// buf.append(");"); //$NON-NLS-1$
+// } else {
+// if (retTypeSig != null && !retTypeSig.equals(Signature.SIG_VOID)) {
+// if (!isPrimitiveType(retTypeSig)
+// || Signature.getArrayCount(retTypeSig) > 0) {
+// buf.append("return null;"); //$NON-NLS-1$
+// } else if (retTypeSig.equals(Signature.SIG_BOOLEAN)) {
+// buf.append("return false;"); //$NON-NLS-1$
+// } else {
+// buf.append("return 0;"); //$NON-NLS-1$
+// }
+// }
+// }
+// return buf.toString();
+// }
public static String getMethodBodyContent(boolean isConstructor,
IJavaProject project, String destTypeName, String methodName,
return evaluateTemplate(context, template);
}
- public static String getCatchBodyContent(ICompilationUnit cu,
- String exceptionType, String variableName, String lineDelimiter)
- throws CoreException {
- Template template = WebUI.getDefault()
- .getCodeTemplateStore().findTemplate(
- CodeTemplateContextType.CATCHBLOCK);
- if (template == null) {
- return null;
- }
-
- CodeTemplateContext context = new CodeTemplateContext(template
- .getContextTypeId(), cu.getJavaProject(), lineDelimiter);
- context.setVariable(CodeTemplateContextType.EXCEPTION_TYPE,
- exceptionType);
- context
- .setVariable(CodeTemplateContextType.EXCEPTION_VAR,
- variableName); //$NON-NLS-1$
- return evaluateTemplate(context, template);
- }
+// public static String getCatchBodyContent(ICompilationUnit cu,
+// String exceptionType, String variableName, String lineDelimiter)
+// throws CoreException {
+// Template template = WebUI.getDefault()
+// .getCodeTemplateStore().findTemplate(
+// CodeTemplateContextType.CATCHBLOCK);
+// if (template == null) {
+// return null;
+// }
+//
+// CodeTemplateContext context = new CodeTemplateContext(template
+// .getContextTypeId(), cu.getJavaProject(), lineDelimiter);
+// context.setVariable(CodeTemplateContextType.EXCEPTION_TYPE,
+// exceptionType);
+// context
+// .setVariable(CodeTemplateContextType.EXCEPTION_VAR,
+// variableName); //$NON-NLS-1$
+// return evaluateTemplate(context, template);
+// }
/**
* @see net.sourceforge.phpdt.ui.CodeGeneration#getTypeComment(ICompilationUnit,
textBuffer.replace(offset, length, buf.toString());
}
- private static boolean isPrimitiveType(String typeName) {
- char first = Signature.getElementType(typeName).charAt(0);
- return (first != Signature.C_RESOLVED && first != Signature.C_UNRESOLVED);
- }
+// private static boolean isPrimitiveType(String typeName) {
+// char first = Signature.getElementType(typeName).charAt(0);
+// return (first != Signature.C_RESOLVED && first != Signature.C_UNRESOLVED);
+// }
- private static String resolveAndAdd(String refTypeSig, IType declaringType)
- throws JavaModelException {// , IImportsStructure imports) throws
- // JavaModelException {
- String resolvedTypeName = JavaModelUtil.getResolvedTypeName(refTypeSig,
- declaringType);
- if (resolvedTypeName != null) {
- StringBuffer buf = new StringBuffer();
- // if (imports != null) {
- // buf.append(imports.addImport(resolvedTypeName));
- // } else {
- buf.append(resolvedTypeName);
- // }
- int arrayCount = Signature.getArrayCount(refTypeSig);
- for (int i = 0; i < arrayCount; i++) {
- buf.append("[]"); //$NON-NLS-1$
- }
- return buf.toString();
- }
- return Signature.toString(refTypeSig);
- }
+// private static String resolveAndAdd(String refTypeSig, IType declaringType)
+// throws JavaModelException {// , IImportsStructure imports) throws
+// // JavaModelException {
+// String resolvedTypeName = JavaModelUtil.getResolvedTypeName(refTypeSig,
+// declaringType);
+// if (resolvedTypeName != null) {
+// StringBuffer buf = new StringBuffer();
+// // if (imports != null) {
+// // buf.append(imports.addImport(resolvedTypeName));
+// // } else {
+// buf.append(resolvedTypeName);
+// // }
+// int arrayCount = Signature.getArrayCount(refTypeSig);
+// for (int i = 0; i < arrayCount; i++) {
+// buf.append("[]"); //$NON-NLS-1$
+// }
+// return buf.toString();
+// }
+// return Signature.toString(refTypeSig);
+// }
/**
* Finds a method in a list of methods.
/**
* Examines a string and returns the first line delimiter found.
*/
- public static String getLineDelimiterUsed(IJavaElement elem)
- throws JavaModelException {
- ICompilationUnit cu = (ICompilationUnit) elem
- .getAncestor(IJavaElement.COMPILATION_UNIT);
- if (cu != null && cu.exists()) {
- IBuffer buf = cu.getBuffer();
- int length = buf.getLength();
- for (int i = 0; i < length; i++) {
- char ch = buf.getChar(i);
- if (ch == SWT.CR) {
- if (i + 1 < length) {
- if (buf.getChar(i + 1) == SWT.LF) {
- return "\r\n"; //$NON-NLS-1$
- }
- }
- return "\r"; //$NON-NLS-1$
- } else if (ch == SWT.LF) {
- return "\n"; //$NON-NLS-1$
- }
- }
- }
- return System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
- }
+// public static String getLineDelimiterUsed(IJavaElement elem)
+// throws JavaModelException {
+// ICompilationUnit cu = (ICompilationUnit) elem
+// .getAncestor(IJavaElement.COMPILATION_UNIT);
+// if (cu != null && cu.exists()) {
+// IBuffer buf = cu.getBuffer();
+// int length = buf.getLength();
+// for (int i = 0; i < length; i++) {
+// char ch = buf.getChar(i);
+// if (ch == SWT.CR) {
+// if (i + 1 < length) {
+// if (buf.getChar(i + 1) == SWT.LF) {
+// return "\r\n"; //$NON-NLS-1$
+// }
+// }
+// return "\r"; //$NON-NLS-1$
+// } else if (ch == SWT.LF) {
+// return "\n"; //$NON-NLS-1$
+// }
+// }
+// }
+// return System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+// }
/**
* Embodies the policy which line delimiter to use when inserting into a
return baseName;
}
- public static String[] suggestArgumentNames(IJavaProject project,
- String[] paramNames) {
- String prefixes = project.getOption(
- JavaCore.CODEASSIST_ARGUMENT_PREFIXES, true);
- String suffixes = project.getOption(
- JavaCore.CODEASSIST_ARGUMENT_SUFFIXES, true);
- if (prefixes.length() + suffixes.length() == 0) {
- return paramNames;
- }
-
- String[] newNames = new String[paramNames.length];
- // Ensure that the codegeneration preferences are respected
- for (int i = 0; i < paramNames.length; i++) {
- String curr = paramNames[i];
- if (!hasPrefixOrSuffix(prefixes, suffixes, curr)) {
- newNames[i] = suggestArgumentName(project, paramNames[i], null);
- } else {
- newNames[i] = curr;
- }
- }
- return newNames;
- }
-
- public static boolean hasFieldName(IJavaProject project, String name) {
- String prefixes = project.getOption(JavaCore.CODEASSIST_FIELD_PREFIXES,
- true);
- String suffixes = project.getOption(JavaCore.CODEASSIST_FIELD_SUFFIXES,
- true);
- String staticPrefixes = project.getOption(
- JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, true);
- String staticSuffixes = project.getOption(
- JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, true);
-
- return hasPrefixOrSuffix(prefixes, suffixes, name)
- || hasPrefixOrSuffix(staticPrefixes, staticSuffixes, name);
- }
-
- public static boolean hasParameterName(IJavaProject project, String name) {
- String prefixes = project.getOption(
- JavaCore.CODEASSIST_ARGUMENT_PREFIXES, true);
- String suffixes = project.getOption(
- JavaCore.CODEASSIST_ARGUMENT_SUFFIXES, true);
- return hasPrefixOrSuffix(prefixes, suffixes, name);
- }
+// public static String[] suggestArgumentNames(IJavaProject project,
+// String[] paramNames) {
+// String prefixes = project.getOption(
+// JavaCore.CODEASSIST_ARGUMENT_PREFIXES, true);
+// String suffixes = project.getOption(
+// JavaCore.CODEASSIST_ARGUMENT_SUFFIXES, true);
+// if (prefixes.length() + suffixes.length() == 0) {
+// return paramNames;
+// }
+//
+// String[] newNames = new String[paramNames.length];
+// // Ensure that the codegeneration preferences are respected
+// for (int i = 0; i < paramNames.length; i++) {
+// String curr = paramNames[i];
+// if (!hasPrefixOrSuffix(prefixes, suffixes, curr)) {
+// newNames[i] = suggestArgumentName(project, paramNames[i], null);
+// } else {
+// newNames[i] = curr;
+// }
+// }
+// return newNames;
+// }
- public static boolean hasLocalVariableName(IJavaProject project, String name) {
- String prefixes = project.getOption(JavaCore.CODEASSIST_LOCAL_PREFIXES,
- true);
- String suffixes = project.getOption(JavaCore.CODEASSIST_LOCAL_SUFFIXES,
- true);
- return hasPrefixOrSuffix(prefixes, suffixes, name);
- }
+// public static boolean hasFieldName(IJavaProject project, String name) {
+// String prefixes = project.getOption(JavaCore.CODEASSIST_FIELD_PREFIXES,
+// true);
+// String suffixes = project.getOption(JavaCore.CODEASSIST_FIELD_SUFFIXES,
+// true);
+// String staticPrefixes = project.getOption(
+// JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, true);
+// String staticSuffixes = project.getOption(
+// JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, true);
+//
+// return hasPrefixOrSuffix(prefixes, suffixes, name)
+// || hasPrefixOrSuffix(staticPrefixes, staticSuffixes, name);
+// }
- public static boolean hasConstantName(String name) {
- return Character.isUpperCase(name.charAt(0));
- }
+// public static boolean hasParameterName(IJavaProject project, String name) {
+// String prefixes = project.getOption(
+// JavaCore.CODEASSIST_ARGUMENT_PREFIXES, true);
+// String suffixes = project.getOption(
+// JavaCore.CODEASSIST_ARGUMENT_SUFFIXES, true);
+// return hasPrefixOrSuffix(prefixes, suffixes, name);
+// }
- private static boolean hasPrefixOrSuffix(String prefixes, String suffixes,
- String name) {
- final String listSeparartor = ","; //$NON-NLS-1$
+// public static boolean hasLocalVariableName(IJavaProject project, String name) {
+// String prefixes = project.getOption(JavaCore.CODEASSIST_LOCAL_PREFIXES,
+// true);
+// String suffixes = project.getOption(JavaCore.CODEASSIST_LOCAL_SUFFIXES,
+// true);
+// return hasPrefixOrSuffix(prefixes, suffixes, name);
+// }
- StringTokenizer tok = new StringTokenizer(prefixes, listSeparartor);
- while (tok.hasMoreTokens()) {
- String curr = tok.nextToken();
- if (name.startsWith(curr)) {
- return true;
- }
- }
+// public static boolean hasConstantName(String name) {
+// return Character.isUpperCase(name.charAt(0));
+// }
- tok = new StringTokenizer(suffixes, listSeparartor);
- while (tok.hasMoreTokens()) {
- String curr = tok.nextToken();
- if (name.endsWith(curr)) {
- return true;
- }
- }
- return false;
- }
+// private static boolean hasPrefixOrSuffix(String prefixes, String suffixes,
+// String name) {
+// final String listSeparartor = ","; //$NON-NLS-1$
+//
+// StringTokenizer tok = new StringTokenizer(prefixes, listSeparartor);
+// while (tok.hasMoreTokens()) {
+// String curr = tok.nextToken();
+// if (name.startsWith(curr)) {
+// return true;
+// }
+// }
+//
+// tok = new StringTokenizer(suffixes, listSeparartor);
+// while (tok.hasMoreTokens()) {
+// String curr = tok.nextToken();
+// if (name.endsWith(curr)) {
+// return true;
+// }
+// }
+// return false;
+// }
}
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.text.templates.Template;
+//import org.eclipse.jface.text.templates.Template;
/**
* <code>CodeTemplates</code> gives access to the available code templates.
/** Singleton. */
private static CodeTemplates fgTemplates;
- public static Template getCodeTemplate(String name) {
- return getInstance().getFirstTemplate(name);
- }
+// public static Template getCodeTemplate(String name) {
+// return getInstance().getFirstTemplate(name);
+// }
/**
* Returns an instance of templates.
/**
* Resets the template set with the default templates.
*/
- public void restoreDefaults() throws CoreException {
- clear();
- addFromStream(getDefaultsAsStream(), false, true, fgResourceBundle);
- }
+// public void restoreDefaults() throws CoreException {
+// clear();
+// addFromStream(getDefaultsAsStream(), false, true, fgResourceBundle);
+// }
/**
* Saves the template set.
*/
- public void save() throws CoreException {
- saveToFile(getTemplateFile());
- }
+// public void save() throws CoreException {
+// saveToFile(getTemplateFile());
+// }
private static InputStream getDefaultsAsStream() {
return CodeTemplates.class.getResourceAsStream(DEFAULT_FILE);
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
+//import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Vector;
+//import java.util.Vector;
import net.sourceforge.phpdt.core.CompletionRequestorAdapter;
import net.sourceforge.phpdt.core.ICompilationUnit;
}
}
- private ICompilationUnit fUnit;
+ //private ICompilationUnit fUnit;
private List fLocalVariables = new ArrayList();
private Map fTypes = new HashMap();
- private boolean fError;
+ //private boolean fError;
/**
* Creates a compilation unit completion.
* the compilation unit, may be <code>null</code>.
*/
public void reset(ICompilationUnit unit) {
- fUnit = unit;
+ //fUnit = unit;
fLocalVariables.clear();
fTypes.clear();
- fError = false;
+ //fError = false;
}
/*
* @see ICompletionRequestor#acceptError(IProblem)
*/
public void acceptError(IProblem error) {
- fError = true;
+ //fError = true;
}
/*
/**
* Tests if the code completion process produced errors.
*/
- public boolean hasErrors() {
- return fError;
- }
-
- boolean existsLocalName(String name) {
- for (Iterator iterator = fLocalVariables.iterator(); iterator.hasNext();) {
- LocalVariable localVariable = (LocalVariable) iterator.next();
-
- if (localVariable.name.equals(name))
- return true;
- }
-
- return false;
- }
-
- String[] getLocalVariableNames() {
- String[] res = new String[fLocalVariables.size()];
- int i = 0;
- for (Iterator iterator = fLocalVariables.iterator(); iterator.hasNext();) {
- LocalVariable localVariable = (LocalVariable) iterator.next();
- res[i++] = localVariable.name;
- }
- return res;
- }
-
- LocalVariable[] findLocalArrays() {
- Vector vector = new Vector();
-
- for (Iterator iterator = fLocalVariables.iterator(); iterator.hasNext();) {
- LocalVariable localVariable = (LocalVariable) iterator.next();
-
- if (isArray(localVariable.typeName))
- vector.add(localVariable);
- }
-
- return (LocalVariable[]) vector
- .toArray(new LocalVariable[vector.size()]);
- }
+// public boolean hasErrors() {
+// return fError;
+// }
+
+// boolean existsLocalName(String name) {
+// for (Iterator iterator = fLocalVariables.iterator(); iterator.hasNext();) {
+// LocalVariable localVariable = (LocalVariable) iterator.next();
+//
+// if (localVariable.name.equals(name))
+// return true;
+// }
+//
+// return false;
+// }
+
+// String[] getLocalVariableNames() {
+// String[] res = new String[fLocalVariables.size()];
+// int i = 0;
+// for (Iterator iterator = fLocalVariables.iterator(); iterator.hasNext();) {
+// LocalVariable localVariable = (LocalVariable) iterator.next();
+// res[i++] = localVariable.name;
+// }
+// return res;
+// }
+
+// LocalVariable[] findLocalArrays() {
+// Vector vector = new Vector();
+//
+// for (Iterator iterator = fLocalVariables.iterator(); iterator.hasNext();) {
+// LocalVariable localVariable = (LocalVariable) iterator.next();
+//
+// if (isArray(localVariable.typeName))
+// vector.add(localVariable);
+// }
+//
+// return (LocalVariable[]) vector
+// .toArray(new LocalVariable[vector.size()]);
+// }
// LocalVariable[] findLocalCollections() throws JavaModelException {
// Vector vector= new Vector();
// LocalVariable[vector.size()]);
// }
- String simplifyTypeName(String qualifiedName) {
- return (String) fTypes.get(qualifiedName);
- }
+// String simplifyTypeName(String qualifiedName) {
+// return (String) fTypes.get(qualifiedName);
+// }
- private static boolean isArray(String type) {
- return type.endsWith("[]"); //$NON-NLS-1$
- }
+// private static boolean isArray(String type) {
+// return type.endsWith("[]"); //$NON-NLS-1$
+// }
// returns fully qualified name if successful
// private String qualify(String typeName) throws JavaModelException {
/**
* 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);
+// }
}
/**
* Returns all templates.
*/
- public Template[] getTemplates() {
- return (Template[]) fTemplates.toArray(new Template[fTemplates.size()]);
- }
+// public Template[] getTemplates() {
+// return (Template[]) fTemplates.toArray(new Template[fTemplates.size()]);
+// }
/**
* Returns all templates with a given name.
/**
* Returns the first templates with the given name.
*/
- public Template getFirstTemplate(String name) {
- for (Iterator iterator = fTemplates.iterator(); iterator.hasNext();) {
- Template curr = (Template) iterator.next();
- if (curr.getName().equals(name)) {
- return curr;
- }
- }
- return null;
- }
+// public Template getFirstTemplate(String name) {
+// for (Iterator iterator = fTemplates.iterator(); iterator.hasNext();) {
+// Template curr = (Template) iterator.next();
+// if (curr.getName().equals(name)) {
+// return curr;
+// }
+// }
+// return null;
+// }
}
package net.sourceforge.phpdt.internal.corext.template.php;
import java.io.File;
-import java.io.InputStream;
+//import java.io.InputStream;
import java.util.ResourceBundle;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
public class Templates extends
net.sourceforge.phpdt.internal.corext.template.php.TemplateSet {
- private static final String DEFAULT_FILE = "default-templates.xml"; //$NON-NLS-1$
+ //private static final String DEFAULT_FILE = "default-templates.xml"; //$NON-NLS-1$
private static final String TEMPLATE_FILE = "templates.xml"; //$NON-NLS-1$
/**
* Resets the template set with the default templates.
*/
- public void restoreDefaults() throws CoreException {
- clear();
- addFromStream(getDefaultsAsStream(), true, true, fgResourceBundle);
- }
+// public void restoreDefaults() throws CoreException {
+// clear();
+// addFromStream(getDefaultsAsStream(), true, true, fgResourceBundle);
+// }
/**
* Saves the template set.
*/
- public void save() throws CoreException {
- saveToFile(getTemplateFile());
- }
+// public void save() throws CoreException {
+// saveToFile(getTemplateFile());
+// }
- private static InputStream getDefaultsAsStream() {
- return Templates.class.getResourceAsStream(DEFAULT_FILE);
- }
+// private static InputStream getDefaultsAsStream() {
+// return Templates.class.getResourceAsStream(DEFAULT_FILE);
+// }
private static File getTemplateFile() {
IPath path = PHPeclipsePlugin.getDefault().getStateLocation();
+++ /dev/null
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.ui;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * An exception to wrap a status. This is necessary to use the core's
- * IRunnableWithProgress support
- */
-
-public class PHPUIException extends CoreException {
-
- public PHPUIException(IStatus status) {
- super(status);
- }
-}
\ No newline at end of file
import net.sourceforge.phpdt.core.IJavaElement;
import net.sourceforge.phpdt.core.IJavaProject;
-import net.sourceforge.phpdt.core.IPackageFragment;
-import net.sourceforge.phpdt.core.IPackageFragmentRoot;
-import net.sourceforge.phpdt.internal.corext.refactoring.util.ResourceUtil;
+//import net.sourceforge.phpdt.core.IPackageFragment;
+//import net.sourceforge.phpdt.core.IPackageFragmentRoot;
+//import net.sourceforge.phpdt.internal.corext.refactoring.util.ResourceUtil;
//import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import net.sourceforge.phpeclipse.phpeditor.PHPEditor;
//import net.sourceforge.phpeclipse.ui.WebUI;
-import org.eclipse.core.resources.IFolder;
+//import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectNature;
-import org.eclipse.core.resources.IResource;
+//import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
}
// bug 31998 we will have to disable renaming of linked packages (and cus)
- public static boolean mustDisableJavaModelAction(Shell shell, Object element) {
- if (!(element instanceof IPackageFragment)
- && !(element instanceof IPackageFragmentRoot))
- return false;
-
- IResource resource = ResourceUtil.getResource(element);
- if ((resource == null) || (!(resource instanceof IFolder))
- || (!resource.isLinked()))
- return false;
-
- MessageDialog
- .openInformation(
- shell,
- ActionMessages.getString("ActionUtil.not_possible"), ActionMessages.getString("ActionUtil.no_linked")); //$NON-NLS-1$ //$NON-NLS-2$
- return true;
- }
+// public static boolean mustDisableJavaModelAction(Shell shell, Object element) {
+// if (!(element instanceof IPackageFragment)
+// && !(element instanceof IPackageFragmentRoot))
+// return false;
+//
+// IResource resource = ResourceUtil.getResource(element);
+// if ((resource == null) || (!(resource instanceof IFolder))
+// || (!resource.isLinked()))
+// return false;
+//
+// MessageDialog
+// .openInformation(
+// shell,
+// ActionMessages.getString("ActionUtil.not_possible"), ActionMessages.getString("ActionUtil.no_linked")); //$NON-NLS-1$ //$NON-NLS-2$
+// return true;
+// }
public static boolean isProcessable(Shell shell, PHPEditor editor) {
if (editor == null)
*******************************************************************************/
package net.sourceforge.phpdt.internal.ui.preferences;
-import java.util.ArrayList;
+//import java.util.ArrayList;
import java.util.Map;
import net.sourceforge.phpdt.core.IJavaProject;
//private static final String CLEAN = JavaCore.CLEAN;
- private static final String ENABLED = JavaCore.ENABLED;
+ //private static final String ENABLED = JavaCore.ENABLED;
- private static final String DISABLED = JavaCore.DISABLED;
+ //private static final String DISABLED = JavaCore.DISABLED;
// private static final String PUBLIC= JavaCore.PUBLIC;
// private static final String PROTECTED= JavaCore.PROTECTED;
//private static final String USER_CONF = "user"; //$NON-NLS-1$
- private ArrayList fComplianceControls;
+ //private ArrayList fComplianceControls;
private PixelConverter fPixelConverter;
IJavaProject project) {
super(context, project, getKeys());
- fComplianceControls = new ArrayList();
+ //fComplianceControls = new ArrayList();
// fComplianceStatus= new StatusInfo();
fMaxNumberProblemsStatus = new StatusInfo();
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.swt.SWT;
+//import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
//import org.eclipse.ui.PlatformUI;
import java.text.BreakIterator;
-import net.sourceforge.phpdt.core.ICompilationUnit;
+//import net.sourceforge.phpdt.core.ICompilationUnit;
//import net.sourceforge.phpdt.core.IJavaElement;
-import net.sourceforge.phpdt.core.IMethod;
-import net.sourceforge.phpdt.core.ISourceRange;
-import net.sourceforge.phpdt.core.IType;
-import net.sourceforge.phpdt.internal.corext.util.Strings;
-import net.sourceforge.phpdt.ui.CodeGeneration;
-import net.sourceforge.phpdt.ui.IWorkingCopyManager;
+//import net.sourceforge.phpdt.core.IMethod;
+//import net.sourceforge.phpdt.core.ISourceRange;
+//import net.sourceforge.phpdt.core.IType;
+//import net.sourceforge.phpdt.internal.corext.util.Strings;
+//import net.sourceforge.phpdt.ui.CodeGeneration;
+//import net.sourceforge.phpdt.ui.IWorkingCopyManager;
import net.sourceforge.phpdt.ui.PreferenceConstants;
//import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import net.sourceforge.phpeclipse.ui.WebUI;
-import org.eclipse.core.runtime.CoreException;
+//import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.TextUtilities;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
+//import org.eclipse.ui.IWorkbenchWindow;
+//import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
import org.eclipse.ui.texteditor.ITextEditorExtension3;
* Removes start and end of a comment and corrects indentation and line
* delimiters.
*/
- private String prepareTemplateComment(String comment, String indentation,
- String lineDelimiter) {
- // trim comment start and end if any
- if (comment.endsWith("*/")) //$NON-NLS-1$
- comment = comment.substring(0, comment.length() - 2);
- comment = comment.trim();
- if (comment.startsWith("/*")) { //$NON-NLS-1$
- if (comment.length() > 2 && comment.charAt(2) == '*') {
- comment = comment.substring(3); // remove '/**'
- } else {
- comment = comment.substring(2); // remove '/*'
- }
- }
- // return Strings.changeIndent(comment, 0,
- // CodeFormatterUtil.getTabWidth(), indentation, lineDelimiter);
- return Strings.changeIndent(comment, 0, getTabWidth(), indentation,
- lineDelimiter);
- }
+// private String prepareTemplateComment(String comment, String indentation,
+// String lineDelimiter) {
+// // trim comment start and end if any
+// if (comment.endsWith("*/")) //$NON-NLS-1$
+// comment = comment.substring(0, comment.length() - 2);
+// comment = comment.trim();
+// if (comment.startsWith("/*")) { //$NON-NLS-1$
+// if (comment.length() > 2 && comment.charAt(2) == '*') {
+// comment = comment.substring(3); // remove '/**'
+// } else {
+// comment = comment.substring(2); // remove '/*'
+// }
+// }
+// // return Strings.changeIndent(comment, 0,
+// // CodeFormatterUtil.getTabWidth(), indentation, lineDelimiter);
+// return Strings.changeIndent(comment, 0, getTabWidth(), indentation,
+// lineDelimiter);
+// }
public static int getTabWidth() {
Preferences preferences = WebUI.getDefault()
.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
}
- private String createTypeTags(IDocument document, DocumentCommand command,
- String indentation, String lineDelimiter, IType type)
- throws CoreException {
- String comment = CodeGeneration.getTypeComment(type
- .getCompilationUnit(), type.getTypeQualifiedName('.'),
- lineDelimiter);
- if (comment != null) {
- return prepareTemplateComment(comment.trim(), indentation,
- lineDelimiter);
- }
- return null;
- }
+// private String createTypeTags(IDocument document, DocumentCommand command,
+// String indentation, String lineDelimiter, IType type)
+// throws CoreException {
+// String comment = CodeGeneration.getTypeComment(type
+// .getCompilationUnit(), type.getTypeQualifiedName('.'),
+// lineDelimiter);
+// if (comment != null) {
+// return prepareTemplateComment(comment.trim(), indentation,
+// lineDelimiter);
+// }
+// return null;
+// }
- private String createMethodTags(IDocument document,
- DocumentCommand command, String indentation, String lineDelimiter,
- IMethod method) throws CoreException, BadLocationException {
- IRegion partition = TextUtilities.getPartition(document, fPartitioning,
- command.offset, false);
- ISourceRange sourceRange = method.getSourceRange();
- if (sourceRange == null
- || sourceRange.getOffset() != partition.getOffset())
- return null;
-
- // IMethod inheritedMethod= getInheritedMethod(method);
- // String comment= CodeGeneration.getMethodComment(method,
- // inheritedMethod, lineDelimiter);
- // if (comment != null) {
- // comment= comment.trim();
- // boolean javadocComment= comment.startsWith("/**"); //$NON-NLS-1$
- // boolean isJavaDoc= partition.getLength() >= 3 &&
- // document.get(partition.getOffset(), 3).equals("/**"); //$NON-NLS-1$
- // if (javadocComment == isJavaDoc) {
- // return prepareTemplateComment(comment, indentation, lineDelimiter);
- // }
- // }
- return null;
- }
+// private String createMethodTags(IDocument document,
+// DocumentCommand command, String indentation, String lineDelimiter,
+// IMethod method) throws CoreException, BadLocationException {
+// IRegion partition = TextUtilities.getPartition(document, fPartitioning,
+// command.offset, false);
+// ISourceRange sourceRange = method.getSourceRange();
+// if (sourceRange == null
+// || sourceRange.getOffset() != partition.getOffset())
+// return null;
+//
+// // IMethod inheritedMethod= getInheritedMethod(method);
+// // String comment= CodeGeneration.getMethodComment(method,
+// // inheritedMethod, lineDelimiter);
+// // if (comment != null) {
+// // comment= comment.trim();
+// // boolean javadocComment= comment.startsWith("/**"); //$NON-NLS-1$
+// // boolean isJavaDoc= partition.getLength() >= 3 &&
+// // document.get(partition.getOffset(), 3).equals("/**"); //$NON-NLS-1$
+// // if (javadocComment == isJavaDoc) {
+// // return prepareTemplateComment(comment, indentation, lineDelimiter);
+// // }
+// // }
+// return null;
+// }
/**
* Returns the method inherited from, <code>null</code> if method is newly
* Returns the compilation unit of the CompilationUnitEditor invoking the
* AutoIndentStrategy, might return <code>null</code> on error.
*/
- private static ICompilationUnit getCompilationUnit() {
-
- IWorkbenchWindow window = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow();
- if (window == null)
- return null;
-
- IWorkbenchPage page = window.getActivePage();
- if (page == null)
- return null;
-
- IEditorPart editor = page.getActiveEditor();
- if (editor == null)
- return null;
-
- IWorkingCopyManager manager = WebUI.getDefault()
- .getWorkingCopyManager();
- ICompilationUnit unit = manager.getWorkingCopy(editor.getEditorInput());
- if (unit == null)
- return null;
-
- return unit;
- }
+// private static ICompilationUnit getCompilationUnit() {
+//
+// IWorkbenchWindow window = PlatformUI.getWorkbench()
+// .getActiveWorkbenchWindow();
+// if (window == null)
+// return null;
+//
+// IWorkbenchPage page = window.getActivePage();
+// if (page == null)
+// return null;
+//
+// IEditorPart editor = page.getActiveEditor();
+// if (editor == null)
+// return null;
+//
+// IWorkingCopyManager manager = WebUI.getDefault()
+// .getWorkingCopyManager();
+// ICompilationUnit unit = manager.getWorkingCopy(editor.getEditorInput());
+// if (unit == null)
+// return null;
+//
+// return unit;
+// }
}
* Returns true iff the file extension is a valid PHP Unit name
* implementation is not creating extra strings.
*/
- public final static boolean isValidPHPUnitName(String filename) {
- return PHPFileUtil.isPHPFileName(filename);
- }
+// public final static boolean isValidPHPUnitName(String filename) {
+// return PHPFileUtil.isPHPFileName(filename);
+// }
/**
* @return Returns the PHP extensions.
* @return the file for the given absolute file path or <code>null</code>
* if no existing file can be found
*/
- public static IFile createFile(IPath absoluteFilePath, IProject project) {
- if (absoluteFilePath == null || project == null) {
- return null;
- }
-
- String projectPath = project.getFullPath().toString();
- String filePath = absoluteFilePath.toString().substring(
- projectPath.length() + 1);
- return project.getFile(filePath);
-
- }
+// public static IFile createFile(IPath absoluteFilePath, IProject project) {
+// if (absoluteFilePath == null || project == null) {
+// return null;
+// }
+//
+// String projectPath = project.getFullPath().toString();
+// String filePath = absoluteFilePath.toString().substring(
+// projectPath.length() + 1);
+// return project.getFile(filePath);
+//
+// }
/**
* Determine the path of an include name string
* Note that for pattern like "*abc*" with leading and trailing stars, position of "abc"
* is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned
*/
- public StringMatcher.Position find(String text, int start, int end) {
- if (text == null)
- throw new IllegalArgumentException();
-
- int tlen = text.length();
- if (start < 0)
- start = 0;
- if (end > tlen)
- end = tlen;
- if (end < 0 || start >= end)
- return null;
- if (fLength == 0)
- return new Position(start, start);
- if (fIgnoreWildCards) {
- int x = posIn(text, start, end);
- if (x < 0)
- return null;
- return new Position(x, x + fLength);
- }
-
- int segCount = fSegments.length;
- if (segCount == 0)// pattern contains only '*'(s)
- return new Position(start, end);
-
- int curPos = start;
- int matchStart = -1;
- int i;
- for (i = 0; i < segCount && curPos < end; ++i) {
- String current = fSegments[i];
- int nextMatch = regExpPosIn(text, curPos, end, current);
- if (nextMatch < 0)
- return null;
- if (i == 0)
- matchStart = nextMatch;
- curPos = nextMatch + current.length();
- }
- if (i < segCount)
- return null;
- return new Position(matchStart, curPos);
- }
+// public StringMatcher.Position find(String text, int start, int end) {
+// if (text == null)
+// throw new IllegalArgumentException();
+//
+// int tlen = text.length();
+// if (start < 0)
+// start = 0;
+// if (end > tlen)
+// end = tlen;
+// if (end < 0 || start >= end)
+// return null;
+// if (fLength == 0)
+// return new Position(start, start);
+// if (fIgnoreWildCards) {
+// int x = posIn(text, start, end);
+// if (x < 0)
+// return null;
+// return new Position(x, x + fLength);
+// }
+//
+// int segCount = fSegments.length;
+// if (segCount == 0)// pattern contains only '*'(s)
+// return new Position(start, end);
+//
+// int curPos = start;
+// int matchStart = -1;
+// int i;
+// for (i = 0; i < segCount && curPos < end; ++i) {
+// String current = fSegments[i];
+// int nextMatch = regExpPosIn(text, curPos, end, current);
+// if (nextMatch < 0)
+// return null;
+// if (i == 0)
+// matchStart = nextMatch;
+// curPos = nextMatch + current.length();
+// }
+// if (i < segCount)
+// return null;
+// return new Position(matchStart, curPos);
+// }
/**
* match the given <code>text</code> with the pattern
* @return the starting index in the text of the pattern , or -1 if not
* found
*/
- protected int posIn(String text, int start, int end) {// no wild card in
- // pattern
- int max = end - fLength;
-
- if (!fIgnoreCase) {
- int i = text.indexOf(fPattern, start);
- if (i == -1 || i > max)
- return -1;
- return i;
- }
-
- for (int i = start; i <= max; ++i) {
- if (text.regionMatches(true, i, fPattern, 0, fLength))
- return i;
- }
-
- return -1;
- }
+// protected int posIn(String text, int start, int end) {// no wild card in
+// // pattern
+// int max = end - fLength;
+//
+// if (!fIgnoreCase) {
+// int i = text.indexOf(fPattern, start);
+// if (i == -1 || i > max)
+// return -1;
+// return i;
+// }
+//
+// for (int i = start; i <= max; ++i) {
+// if (text.regionMatches(true, i, fPattern, 0, fLength))
+// return i;
+// }
+//
+// return -1;
+// }
/**
* @param <code>text</code>, a simple regular expression that may only
* @param ignoreCase
* specifies whether sorting is case sensitive or not.
*/
- public TwoArrayQuickSorter(boolean ignoreCase) {
- fComparator = new StringComparator(ignoreCase);
- }
+// public TwoArrayQuickSorter(boolean ignoreCase) {
+// fComparator = new StringComparator(ignoreCase);
+// }
/**
* Creates a sorter with a comparator.
private void validate() {
String txt = txtNewName.getText();
- Scanner s;
+ //Scanner s;
setPageComplete(isVariable(txt) && !txt.equals(info.getOldName()));
}
/*
* Called from createType to construct the source for this type
*/
- private String constructTypeStub(String lineDelimiter) { // ImportsManager
- // imports,
- // String
- // lineDelimiter)
- // {
- StringBuffer buf = new StringBuffer();
-
- int modifiers = getModifiers();
- buf.append(Flags.toString(modifiers));
- if (modifiers != 0) {
- buf.append(' ');
- }
- buf.append(fIsClass ? "class " : "interface "); //$NON-NLS-2$ //$NON-NLS-1$
- buf.append(getTypeName());
- // writeSuperClass(buf, imports);
- // writeSuperInterfaces(buf, imports);
- buf.append('{');
- buf.append(lineDelimiter);
- buf.append(lineDelimiter);
- buf.append('}');
- buf.append(lineDelimiter);
- return buf.toString();
- }
+// private String constructTypeStub(String lineDelimiter) { // ImportsManager
+// // imports,
+// // String
+// // lineDelimiter)
+// // {
+// StringBuffer buf = new StringBuffer();
+//
+// int modifiers = getModifiers();
+// buf.append(Flags.toString(modifiers));
+// if (modifiers != 0) {
+// buf.append(' ');
+// }
+// buf.append(fIsClass ? "class " : "interface "); //$NON-NLS-2$ //$NON-NLS-1$
+// buf.append(getTypeName());
+// // writeSuperClass(buf, imports);
+// // writeSuperInterfaces(buf, imports);
+// buf.append('{');
+// buf.append(lineDelimiter);
+// buf.append(lineDelimiter);
+// buf.append('}');
+// buf.append(lineDelimiter);
+// return buf.toString();
+// }
/**
* @deprecated Overwrite createTypeMembers(IType, IImportsManager,
}
public boolean equals(Object o) {
- String s = (String) o;
+ //String s = (String) o;
return compare(this, o) == 0;
}
}
*/
public class EditorHighlightingSynchronizer implements ILinkedModeListener {
- private final PHPEditor fEditor;
+ //private final PHPEditor fEditor;
// private final boolean fWasOccurrencesOn;
*/
public EditorHighlightingSynchronizer(PHPEditor editor) {
Assert.isLegal(editor != null);
- fEditor = editor;
+ //fEditor = editor;
// fWasOccurrencesOn= fEditor.isMarkingOccurrences();
//
// if (fWasOccurrencesOn)
import net.sourceforge.phpdt.core.JavaModelException;
import net.sourceforge.phpdt.internal.corext.util.JavaModelUtil;
import net.sourceforge.phpdt.ui.JavaUI;
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+//import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import net.sourceforge.phpeclipse.ui.WebUI;
import org.eclipse.core.resources.IFile;
*/
public class EditorUtility {
- public static boolean isEditorInput(Object element, IEditorPart editor) {
- if (editor != null) {
- try {
- return editor.getEditorInput().equals(getEditorInput(element));
- } catch (JavaModelException x) {
- PHPeclipsePlugin.log(x.getStatus());
- }
- }
- return false;
- }
+// public static boolean isEditorInput(Object element, IEditorPart editor) {
+// if (editor != null) {
+// try {
+// return editor.getEditorInput().equals(getEditorInput(element));
+// } catch (JavaModelException x) {
+// PHPeclipsePlugin.log(x.getStatus());
+// }
+// }
+// return false;
+// }
/**
* Tests if a cu is currently shown in an editor
* @return the IEditorPart if shown, null if element is not open in an
* editor
*/
- public static IEditorPart isOpenInEditor(Object inputElement) {
- IEditorInput input = null;
-
- try {
- input = getEditorInput(inputElement);
- } catch (JavaModelException x) {
- PHPeclipsePlugin.log(x.getStatus());
- }
-
- if (input != null) {
- IWorkbenchPage p = WebUI.getActivePage();
- if (p != null) {
- return p.findEditor(input);
- }
- }
-
- return null;
- }
+// public static IEditorPart isOpenInEditor(Object inputElement) {
+// IEditorInput input = null;
+//
+// try {
+// input = getEditorInput(inputElement);
+// } catch (JavaModelException x) {
+// PHPeclipsePlugin.log(x.getStatus());
+// }
+//
+// if (input != null) {
+// IWorkbenchPage p = WebUI.getActivePage();
+// if (p != null) {
+// return p.findEditor(input);
+// }
+// }
+//
+// return null;
+// }
/**
* Opens a Java editor for an element such as <code>IJavaElement</code>,
* If the current active editor edits a java element return it, else return
* null
*/
- public static IJavaElement getActiveEditorJavaInput() {
- IWorkbenchPage page = WebUI.getActivePage();
- if (page != null) {
- IEditorPart part = page.getActiveEditor();
- if (part != null) {
- IEditorInput editorInput = part.getEditorInput();
- if (editorInput != null) {
- return (IJavaElement) editorInput
- .getAdapter(IJavaElement.class);
- }
- }
- }
- return null;
- }
+// public static IJavaElement getActiveEditorJavaInput() {
+// IWorkbenchPage page = WebUI.getActivePage();
+// if (page != null) {
+// IEditorPart part = page.getActiveEditor();
+// if (part != null) {
+// IEditorInput editorInput = part.getEditorInput();
+// if (editorInput != null) {
+// return (IJavaElement) editorInput
+// .getAdapter(IJavaElement.class);
+// }
+// }
+// }
+// return null;
+// }
/**
* Gets the working copy of an compilation unit opened in an editor
* @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;
+// }
/**
* Returns the compilation unit for the given java element.
int start = document.getLineOffset(line);
int whiteend = findEndOfWhiteSpace(document, start,
command.offset);
- int offset = -1;
+ //int offset = -1;
// if (command.offset > 0 && command.offset < docLength &&
// document.getChar(command.offset-1) == '{') {
// offset = command.offset;
| IResourceChangeEvent.PRE_DELETE
| IResourceChangeEvent.PRE_CLOSE);
- ISavedState savedState = workspace.addSaveParticipant(
- /*PHPeclipsePlugin*/WebUI.this, modelManager);
+// ISavedState savedState = workspace.addSaveParticipant(
+// /*PHPeclipsePlugin*/WebUI.this, modelManager);
WorkspaceJob processSavedState = new WorkspaceJob(
Util.bind("savedState.jobName")) { //$NON-NLS-1$