i've created a patch that passes the SourceModule over to the extension (attached).

Would this implementation be ok for you?

regards

-robert




On 6/29/11 3:38 PM, 赵忠伟 wrote:
hi,

Do not worry,I think it is not a big problem that we pass SourceModule to PHPIndexingVisitor:)

2011/6/29 Robert Gründler <[email protected] <mailto:[email protected]>>

    On 6/29/11 6:01 AM, 赵忠伟 wrote:
    I think you need ask this question in dltk group,after
    debugging,I think the DLTK indexer only can visit ISourceModule

    ok, this isn't a big problem, i can still use my own indexer then
    for non-php files.



    as your another question,we can not get ISourceModule from
    PhpIndexingVisitor,so you still can not visit the XML/Yaml config
    files:(

    hm, this is bad news for me ;)

    The reason is because Symfony2 declares the same framework
    elements in different places, like Route-Patterns for example. They
    can be declared in XML/Yaml files and also inside PHP DocBlocks.

    So my custom index looks a little bit different than the DLTK
    index, where each ModelElement found during indexing
    is tied to the parent container/resource.

    Which means that all my custom model elements need to have the
    IScriptProject as their parent, so when i search for them, i basically
    always search inside a project-scope.

    When i don't have a handle to the Project / SourceModule inside
    the PHPIndexingVisitor, i cant' make this relation to my custom
    elements.

    I hope my explanation is somewhat understandable ;)

    Is there maybe another way to get the containing SourceModule or
    at least the IScriptProject from within an PHPIndexingVisitor? Maybe
    by using some Utility class i haven't found yet?

    I've already searched a lot through the DLTK/PDT code, but
    unfortunately i couldn't find a way to do this.


    thanks again for your help!


    regards

    -robert






    2011/6/27 Robert Gründler <[email protected]
    <mailto:[email protected]>>

        Hi,

        the framework i'm writing a plugin for uses XML/Yaml config
        files. Those files define domainspecific
        elements, which i'm currently indexing using a custom H2/SQL
        implementation.

        I'm wondering if it's possible to get the DLTK/PHP indexer to
        also visit those XML/Yaml files, so i can
        use the existing Indexing framwork - probably store those
        elements as IModelElement.USER_ELEMENT
        and encode everything i need into the metadata (i'm doing
        this already for TemplateVariables).

        All i'm need to do is to parse some xml/yaml attributes,
        which can then later be used for code-hints
        and Hyperlink-detection etc.

        I've tried already a couple of things, even to provide my own
        LanguageToolkit, but it seems DLTK
        only allows one toolkit per IScriptProject.


        Any hints if this is possible? Or should i stay with my own
        indexer?


        regards

        -robert


        _______________________________________________
        pdt-dev mailing list
        [email protected] <mailto:[email protected]>
        https://dev.eclipse.org/mailman/listinfo/pdt-dev




--
    Thanks!

    Best Regards!

    Zhao


    _______________________________________________
    pdt-dev mailing list
    [email protected]  <mailto:[email protected]>
    https://dev.eclipse.org/mailman/listinfo/pdt-dev


    _______________________________________________
    pdt-dev mailing list
    [email protected] <mailto:[email protected]>
    https://dev.eclipse.org/mailman/listinfo/pdt-dev




--

Thanks!

Best Regards!

Zhao


_______________________________________________
pdt-dev mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/pdt-dev

### Eclipse Workspace Patch 1.0
#P org.eclipse.php.core
Index: src/org/eclipse/php/core/index/PhpIndexingVisitorExtension.java
===================================================================
RCS file: 
/cvsroot/tools/org.eclipse.pdt/plugins/org.eclipse.php.core/src/org/eclipse/php/core/index/PhpIndexingVisitorExtension.java,v
retrieving revision 1.2
diff -u -r1.2 PhpIndexingVisitorExtension.java
--- src/org/eclipse/php/core/index/PhpIndexingVisitorExtension.java     27 Jun 
2011 12:27:02 -0000      1.2
+++ src/org/eclipse/php/core/index/PhpIndexingVisitorExtension.java     29 Jun 
2011 18:46:26 -0000
@@ -13,6 +13,7 @@
 
 import org.eclipse.dltk.ast.ASTNode;
 import org.eclipse.dltk.ast.ASTVisitor;
+import org.eclipse.dltk.core.ISourceModule;
 import org.eclipse.dltk.core.index2.IIndexingRequestor;
 import org.eclipse.dltk.core.index2.IIndexingRequestor.DeclarationInfo;
 import org.eclipse.dltk.core.index2.IIndexingRequestor.ReferenceInfo;
@@ -26,6 +27,7 @@
 public abstract class PhpIndexingVisitorExtension extends ASTVisitor {
 
        protected IIndexingRequestor requestor;
+       protected ISourceModule sourceModule;
 
        /**
         * This is a last chance before modifying element declaration 
information
@@ -55,4 +57,10 @@
 
                this.requestor = requestor;
        }
+
+       public void setSourceModule(ISourceModule module) {
+
+               this.sourceModule = module;
+
+       }
 }
Index: src/org/eclipse/php/internal/core/index/PhpIndexingParser.java
===================================================================
RCS file: 
/cvsroot/tools/org.eclipse.pdt/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/index/PhpIndexingParser.java,v
retrieving revision 1.3
diff -u -r1.3 PhpIndexingParser.java
--- src/org/eclipse/php/internal/core/index/PhpIndexingParser.java      6 Oct 
2009 11:38:57 -0000       1.3
+++ src/org/eclipse/php/internal/core/index/PhpIndexingParser.java      29 Jun 
2011 18:46:26 -0000
@@ -27,7 +27,7 @@
                                .getModuleDeclaration(module);
                if (moduleDeclaration != null) {
                        try {
-                               moduleDeclaration.traverse(new 
PhpIndexingVisitor(requestor));
+                               moduleDeclaration.traverse(new 
PhpIndexingVisitor(requestor, module));
                        } catch (Exception e) {
                                if (DLTKCore.DEBUG) {
                                        e.printStackTrace();
Index: src/org/eclipse/php/internal/core/index/PhpIndexingVisitor.java
===================================================================
RCS file: 
/cvsroot/tools/org.eclipse.pdt/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/index/PhpIndexingVisitor.java,v
retrieving revision 1.14
diff -u -r1.14 PhpIndexingVisitor.java
--- src/org/eclipse/php/internal/core/index/PhpIndexingVisitor.java     27 Jun 
2011 12:27:02 -0000      1.14
+++ src/org/eclipse/php/internal/core/index/PhpIndexingVisitor.java     29 Jun 
2011 18:46:27 -0000
@@ -32,6 +32,7 @@
 import org.eclipse.dltk.ast.references.VariableReference;
 import org.eclipse.dltk.ast.statements.Statement;
 import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.ISourceModule;
 import org.eclipse.dltk.core.index2.IIndexingRequestor;
 import org.eclipse.dltk.core.index2.IIndexingRequestor.DeclarationInfo;
 import org.eclipse.dltk.core.index2.IIndexingRequestor.ReferenceInfo;
@@ -92,7 +93,7 @@
 
        protected IIndexingRequestor requestor;
 
-       public PhpIndexingVisitor(IIndexingRequestor requestor) {
+       public PhpIndexingVisitor(IIndexingRequestor requestor, ISourceModule 
module) {
                this.requestor = requestor;
 
                List<PhpIndexingVisitorExtension> extensions = new 
ArrayList<PhpIndexingVisitorExtension>(
@@ -102,6 +103,9 @@
                                PhpIndexingVisitorExtension ext = 
(PhpIndexingVisitorExtension) element
                                                
.createExecutableExtension(CLASS_ATTR);
                                ext.setRequestor(requestor);
+                               // pass the ISourceModule over to the extension
+                               // in case it needs it during indexing
+                               ext.setSourceModule(module);
                                extensions.add(ext);
                        } catch (CoreException e) {
                                Logger.logException(e);
_______________________________________________
pdt-dev mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/pdt-dev

Reply via email to