X-Git-Url: http://secure.phpeclipse.com
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/DeclarationEngine.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/DeclarationEngine.java
index 0483613..fa9aba0 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/DeclarationEngine.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/DeclarationEngine.java
@@ -29,14 +29,17 @@ public class DeclarationEngine {
private ContextType fContextType;
/** The result proposals. */
private ArrayList fProposals = new ArrayList();
+ /** Use only methods or variables inside a class*/
+ private boolean fUseClassEntries;
/**
* Creates the template engine for a particular context type.
* See TemplateContext
for supported context types.
*/
- public DeclarationEngine(ContextType contextType) {
+ public DeclarationEngine(ContextType contextType, boolean useClassEntries) {
// Assert.isNotNull(contextType);
fContextType = contextType;
+ fUseClassEntries = useClassEntries;
}
/**
@@ -63,10 +66,7 @@ public class DeclarationEngine {
* @param completionPosition the context position in the document of the text viewer
* @param compilationUnit the compilation unit (may be null
)
*/
- public void complete(ITextViewer viewer, int completionPosition, SortedMap map)
- //,ICompilationUnit compilationUnit)
- //hrows JavaModelException
- {
+ public void complete(ITextViewer viewer, int completionPosition, SortedMap map) {
IDocument document = viewer.getDocument();
if (!(fContextType instanceof CompilationUnitContextType))
@@ -75,6 +75,7 @@ public class DeclarationEngine {
Point selection = viewer.getSelectedRange();
// remember selected text
String selectedText = null;
+
if (selection.y != 0) {
try {
selectedText = document.get(selection.x, selection.y);
@@ -82,14 +83,14 @@ public class DeclarationEngine {
}
}
- ((CompilationUnitContextType) fContextType).setContextParameters(document, completionPosition, selection.y); //mpilationUnit);
+ ((CompilationUnitContextType) fContextType).setContextParameters(document, completionPosition, selection.y);
PHPUnitContext context = (PHPUnitContext) fContextType.createContext();
int start = context.getStart();
int end = context.getEnd();
String prefix = context.getKey();
IRegion region = new Region(start, end - start);
-
+
String identifier = null;
SortedMap subMap = map.subMap(prefix, prefix + '\255');
@@ -102,10 +103,21 @@ public class DeclarationEngine {
if (context.canEvaluate(identifier)) {
list = (ArrayList) subMap.get(identifier);
for (int i = 0; i < list.size(); i++) {
+ location = (PHPIdentifierLocation) list.get(i);
+ int type = location.getType();
+ if (fUseClassEntries) {
+ if (type != PHPIdentifierLocation.METHOD && type != PHPIdentifierLocation.VARIABLE) {
+ continue; // for loop
+ }
+ } else {
+ if (type == PHPIdentifierLocation.METHOD || type == PHPIdentifierLocation.VARIABLE) {
+ continue; // for loop
+ }
+ }
if (maxProposals-- < 0) {
return;
}
- fProposals.add(new DeclarationProposal(identifier, (PHPIdentifierLocation) list.get(i), context, region, viewer));
+ fProposals.add(new DeclarationProposal(identifier, location, context, region, viewer));
}
}
}