- pull-up common search code - added python search support
diff --git a/plugins/org.eclipse.dltk.python.core/plugin.xml b/plugins/org.eclipse.dltk.python.core/plugin.xml index 4965198..ea9ae0a 100644 --- a/plugins/org.eclipse.dltk.python.core/plugin.xml +++ b/plugins/org.eclipse.dltk.python.core/plugin.xml
@@ -16,7 +16,6 @@ class="org.eclipse.dltk.python.core.PythonLanguageToolkit" nature="org.eclipse.dltk.python.core.nature" priority="0"> - <problemReporting></problemReporting> </language> </extension> <extension @@ -51,4 +50,13 @@ </content-type> </extension> + <extension + point="org.eclipse.dltk.core.search"> + <seachFactory + class="org.eclipse.dltk.python.internal.core.search.PythonSearchFactory" + nature="org.eclipse.dltk.python.core.nature" + priority="0"> + </seachFactory> + </extension> + </plugin>
diff --git a/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/core/PythonMatchLocatorParser.java b/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/core/PythonMatchLocatorParser.java deleted file mode 100644 index 3395b0a..0000000 --- a/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/core/PythonMatchLocatorParser.java +++ /dev/null
@@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - - *******************************************************************************/ -package org.eclipse.dltk.python.core; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.dltk.ast.declarations.ModuleDeclaration; -import org.eclipse.dltk.ast.parser.ISourceParser; -import org.eclipse.dltk.core.DLTKLanguageManager; -import org.eclipse.dltk.core.search.IMatchLocatorParser; -import org.eclipse.dltk.core.search.matching.MatchLocator; -import org.eclipse.dltk.core.search.matching.MatchLocatorParser; -import org.eclipse.dltk.core.search.matching.PossibleMatch; - -public class PythonMatchLocatorParser extends MatchLocatorParser implements IMatchLocatorParser { - private ISourceParser parser; - public PythonMatchLocatorParser(MatchLocator locator) { - super(locator); - try { - parser = DLTKLanguageManager.getSourceParser(PythonNature.NATURE_ID); - } catch (CoreException e) { - e.printStackTrace(); - } - } - - public ModuleDeclaration parse(PossibleMatch possibleMatch) { - return parser.parse(possibleMatch.getFileName(), possibleMatch.getSourceContents().toCharArray(), null); - } - - public void parseBodies(ModuleDeclaration unit) { - // TODO Auto-generated method stub - } -}
diff --git a/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/search/PythonMatchLocationParser.java b/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/search/PythonMatchLocationParser.java new file mode 100644 index 0000000..4360b07 --- /dev/null +++ b/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/search/PythonMatchLocationParser.java
@@ -0,0 +1,11 @@ +package org.eclipse.dltk.python.internal.core.search; + +import org.eclipse.dltk.core.search.matching.MatchLocator; +import org.eclipse.dltk.core.search.matching.MatchLocatorParser; + +public class PythonMatchLocationParser extends MatchLocatorParser { + + protected PythonMatchLocationParser(MatchLocator locator) { + super(locator); + } +}
diff --git a/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/search/PythonMatchLocator.java b/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/search/PythonMatchLocator.java new file mode 100644 index 0000000..007e643 --- /dev/null +++ b/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/search/PythonMatchLocator.java
@@ -0,0 +1,15 @@ +package org.eclipse.dltk.python.internal.core.search; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.dltk.core.search.IDLTKSearchScope; +import org.eclipse.dltk.core.search.SearchPattern; +import org.eclipse.dltk.core.search.SearchRequestor; +import org.eclipse.dltk.core.search.matching.MatchLocator; + +public class PythonMatchLocator extends MatchLocator { + + public PythonMatchLocator(SearchPattern pattern, SearchRequestor requestor, + IDLTKSearchScope scope, IProgressMonitor progressMonitor) { + super(pattern, requestor, scope, progressMonitor); + } +}
diff --git a/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/search/PythonSearchFactory.java b/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/search/PythonSearchFactory.java new file mode 100644 index 0000000..cb6ba5e --- /dev/null +++ b/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/search/PythonSearchFactory.java
@@ -0,0 +1,34 @@ +package org.eclipse.dltk.python.internal.core.search; + +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.dltk.core.search.AbstractSearchFactory; +import org.eclipse.dltk.core.search.IDLTKSearchScope; +import org.eclipse.dltk.core.search.IMatchLocatorParser; +import org.eclipse.dltk.core.search.SearchPattern; +import org.eclipse.dltk.core.search.SearchRequestor; +import org.eclipse.dltk.core.search.matching.MatchLocator; + +/** + * Python search factory + */ +public class PythonSearchFactory extends AbstractSearchFactory { + + /* + * @see org.eclipse.dltk.core.ISearchFactory#createMatchLocator(org.eclipse.dltk.core.search.SearchPattern, + * org.eclipse.dltk.core.search.SearchRequestor, + * org.eclipse.dltk.core.search.IDLTKSearchScope, + * org.eclipse.core.runtime.SubProgressMonitor) + */ + public MatchLocator createMatchLocator(SearchPattern pattern, + SearchRequestor requestor, IDLTKSearchScope scope, + SubProgressMonitor monitor) { + return new PythonMatchLocator(pattern, requestor, scope, monitor); + } + + /* + * @see org.eclipse.dltk.core.ISearchFactory#createMatchParser(org.eclipse.dltk.core.search.matching.MatchLocator) + */ + public IMatchLocatorParser createMatchParser(MatchLocator locator) { + return new PythonMatchLocationParser(locator); + } +}