if (!(context instanceof MethodNameContext)) {
return;
}
MethodNameContext concreteContext = (MethodNameContext) context;
CompletionRequestor requestor = concreteContext
.getCompletionRequestor();
String prefix = concreteContext.getPrefix();
boolean exactName = requestor.isContextInformationMode();
IType declaringClass = concreteContext.getDeclaringClass();
String suffix = getSuffix(concreteContext);
SourceRange replaceRange = null;
if (suffix.equals("")) { //$NON-NLS-1$
replaceRange = getReplacementRange(concreteContext);
} else {
replaceRange = getReplacementRangeWithBraces(concreteContext);
}
try {
ITypeHierarchy hierarchy = getCompanion().getSuperTypeHierarchy(
declaringClass, null);
IMethod[] superClassMethods = PHPModelUtils
.getSuperTypeHierarchyMethod(declaringClass, hierarchy,
prefix, exactName, null);
for (IMethod superMethod : superClassMethods) {
if (declaringClass.getMethod(superMethod.getElementName())
.exists()) {
continue;
}
int flags = superMethod.getFlags();
if (!PHPFlags.isFinal(flags) && !PHPFlags.isPrivate(flags)
&& !PHPFlags.isStatic(flags)) {
reporter.reportMethod(superMethod, CONSTRUCTOR_SUFFIX,
replaceRange);
}
}
} catch (CoreException e) {
PHPCorePlugin.log(e);
}
PHPVersion phpVersion = concreteContext.getPhpVersion();
// Add magic methods:
Set<String> functions = new TreeSet<String>();
functions.addAll(Arrays.asList(PHPMagicMethods.getMethods(phpVersion)));
// Add constructors:
functions.add(declaringClass.getElementName());
if (phpVersion.isGreaterThan(PHPVersion.PHP4)) {
functions.add("__construct"); //$NON-NLS-1$
functions.add("__destruct"); //$NON-NLS-1$
}
for (String function : functions) {
if (CodeAssistUtils.startsWithIgnoreCase(function, prefix)) {
if (!requestor.isContextInformationMode()
|| function.length() == prefix.length()) {
FakeMethod fakeMethod = new FakeMethod(
(ModelElement) declaringClass, function);
if (function.equals("__construct")) { //$NON-NLS-1$
fakeMethod.setConstructor(true);