}
public void apply(ICompletionReporter reporter) throws BadLocationException {
ICompletionContext context = getContext();
AbstractCompletionContext abstractContext = (AbstractCompletionContext) context;
CompletionRequestor requestor = abstractContext
.getCompletionRequestor();
if (abstractContext.getPrefixWithoutProcessing().trim().length() == 0) {
return;
}
String prefix = abstractContext.getPrefix();
if (prefix.startsWith("$")) { //$NON-NLS-1$
return;
}
MatchRule matchRule = MatchRule.PREFIX;
if (requestor.isContextInformationMode()) {
matchRule = MatchRule.EXACT;
}
ISourceModule sourceModule = abstractContext.getSourceModule();
IType enclosingType = null;
try {
IModelElement enclosingElement = sourceModule
.getElementAt(abstractContext.getOffset());
if (enclosingElement != null && enclosingElement instanceof IType) {
enclosingType = (IType) enclosingElement;
}
} catch (ModelException e) {
PHPCorePlugin.log(e);
}
IDLTKSearchScope scope = null;
IModelElement[] enclosingTypeConstants = null;
if (enclosingType != null
&& isStartOfStatement(prefix, abstractContext,
abstractContext.getOffset())) {
// See the case of testClassStatement1.pdtt and
// testClassStatement2.pdtt
scope = SearchEngine.createSearchScope(enclosingType);
} else {
scope = getSearchScope(abstractContext);