This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 187271
Collapse All | Expand All

(-)15457e75b376 (+123 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2011 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.parsing.impl;
43
44
import java.net.URL;
45
import java.util.Map;
46
import org.netbeans.modules.parsing.spi.indexing.BinaryIndexer;
47
import org.netbeans.modules.parsing.spi.indexing.BinaryIndexerFactory;
48
import org.netbeans.modules.parsing.spi.indexing.Context;
49
50
/**
51
 *
52
 * @author Jaroslav Tulach <jtulach@netbeans.org>
53
 */
54
public final class GenericBinaryIndexerFactory extends BinaryIndexerFactory {
55
    private Map<?,?> map;
56
    private BinaryIndexerFactory delegate;
57
    
58
    private GenericBinaryIndexerFactory(Map<?,?> map) {
59
        this.map = map;
60
    }
61
    
62
    public static BinaryIndexerFactory create(Map<?,?> map) {
63
        return new GenericBinaryIndexerFactory(map);
64
    }
65
66
    @Override
67
    public BinaryIndexer createIndexer() {
68
        Object obj = initDelegate(true);
69
        if (obj instanceof BinaryIndexer) {
70
            return (BinaryIndexer)obj;
71
        }
72
        return delegate.createIndexer();
73
    }
74
75
    @Override
76
    public void rootsRemoved(Iterable<? extends URL> removedRoots) {
77
        initDelegate(false);
78
        if (delegate != null) {
79
            delegate.rootsRemoved(removedRoots);
80
            return;
81
        }
82
    }
83
84
    @Override
85
    public String getIndexerName() {
86
        return (String)map.get("indexerName"); // NOI18N
87
    }
88
89
    @Override
90
    public int getIndexVersion() {
91
        return (Integer)map.get("indexerVersion"); // NOI18N
92
    }
93
94
    @Override
95
    public boolean scanStarted(Context context) {
96
        initDelegate(false);
97
        if (delegate == null) {
98
            return true;
99
        }
100
        return delegate.scanStarted(context);
101
    }
102
103
    @Override
104
    public void scanFinished(Context context) {
105
        initDelegate(false);
106
        if (delegate != null) {
107
            delegate.scanFinished(context);
108
        }
109
    }
110
111
    private Object initDelegate(boolean always) {
112
        if (delegate == null && (Boolean.TRUE.equals(map.get("factory")) || always)) {
113
            Object obj = map.get("delegate");
114
            if (obj instanceof BinaryIndexerFactory) {
115
                delegate = (BinaryIndexerFactory) obj;
116
            }
117
            return obj;
118
        }
119
        return delegate;
120
    }
121
    
122
    
123
}
(-)15457e75b376 (+94 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2011 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.parsing.impl;
43
44
import java.util.Collections;
45
import java.util.Set;
46
import javax.annotation.processing.Processor;
47
import javax.annotation.processing.RoundEnvironment;
48
import javax.annotation.processing.SupportedSourceVersion;
49
import javax.lang.model.SourceVersion;
50
import javax.lang.model.element.Element;
51
import javax.lang.model.element.TypeElement;
52
import org.netbeans.modules.parsing.spi.indexing.BinaryIndexerFactory;
53
import org.netbeans.modules.parsing.spi.indexing.IndexerRegistration;
54
import org.openide.filesystems.annotations.LayerBuilder.File;
55
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
56
import org.openide.filesystems.annotations.LayerGenerationException;
57
import org.openide.util.lookup.ServiceProvider;
58
59
/**
60
 *
61
 * @author Jaroslav Tulach <jtulach@netbeans.org>
62
 */
63
@ServiceProvider(service=Processor.class)
64
@SupportedSourceVersion(SourceVersion.RELEASE_6)
65
public class IndexerRegistrationProcessor extends LayerGeneratingProcessor {
66
67
    @Override
68
    public Set<String> getSupportedAnnotationTypes() {
69
        return Collections.singleton(IndexerRegistration.class.getName());
70
    }
71
    
72
    @Override
73
    protected boolean handleProcess(
74
        Set<? extends TypeElement> annotations, RoundEnvironment roundEnv
75
    ) throws LayerGenerationException {
76
        TypeElement bif = processingEnv.getElementUtils().getTypeElement(BinaryIndexerFactory.class.getName());
77
        for (Element e : roundEnv.getElementsAnnotatedWith(IndexerRegistration.class)) {
78
            IndexerRegistration ir = e.getAnnotation(IndexerRegistration.class);
79
            
80
            boolean isBif = processingEnv.getTypeUtils().isAssignable(e.asType(), bif.asType());
81
            
82
            File f = layer(e).instanceFile("Editors", null);
83
            f.methodvalue("instanceCreate", GenericBinaryIndexerFactory.class.getName(), "create");
84
            f.stringvalue("instanceClass", BinaryIndexerFactory.class.getName());
85
            f.instanceAttribute("delegate", null);
86
            f.stringvalue("indexerName", ir.name());
87
            f.intvalue("indexerVersion", ir.version());
88
            f.boolvalue("factory", isBif);
89
            f.write();
90
        }
91
        return true;
92
    }
93
    
94
}
(-)15457e75b376 (+59 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2011 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.parsing.spi.indexing;
43
44
import java.lang.annotation.ElementType;
45
import java.lang.annotation.Retention;
46
import java.lang.annotation.RetentionPolicy;
47
import java.lang.annotation.Target;
48
49
/** Annotation to annotate {@link BinaryIndexer}, {@link BinaryIndexerFactory},
50
 * or TBD...
51
 *
52
 * @author Jaroslav Tulach <jtulach@netbeans.org>
53
 */
54
@Retention(RetentionPolicy.SOURCE)
55
@Target(ElementType.TYPE)
56
public @interface IndexerRegistration {
57
    String name();
58
    int version();
59
}
(-)a/spring.beans/src/org/netbeans/modules/spring/beans/index/SpringBinaryIndexer.java (-28 / +2 lines)
Lines 42-58 Link Here
42
42
43
package org.netbeans.modules.spring.beans.index;
43
package org.netbeans.modules.spring.beans.index;
44
44
45
import java.net.URL;
46
import java.util.ArrayList;
45
import java.util.ArrayList;
47
import java.util.Collection;
46
import java.util.Collection;
48
import java.util.Enumeration;
47
import java.util.Enumeration;
49
import java.util.Locale;
50
import java.util.logging.Level;
48
import java.util.logging.Level;
51
import java.util.logging.Logger;
49
import java.util.logging.Logger;
52
import org.netbeans.api.java.classpath.ClassPath;
50
import org.netbeans.api.java.classpath.ClassPath;
53
import org.netbeans.modules.parsing.spi.indexing.BinaryIndexer;
51
import org.netbeans.modules.parsing.spi.indexing.BinaryIndexer;
54
import org.netbeans.modules.parsing.spi.indexing.BinaryIndexerFactory;
55
import org.netbeans.modules.parsing.spi.indexing.Context;
52
import org.netbeans.modules.parsing.spi.indexing.Context;
53
import org.netbeans.modules.parsing.spi.indexing.IndexerRegistration;
56
import org.netbeans.modules.parsing.spi.indexing.support.IndexDocument;
54
import org.netbeans.modules.parsing.spi.indexing.support.IndexDocument;
57
import org.netbeans.modules.parsing.spi.indexing.support.IndexingSupport;
55
import org.netbeans.modules.parsing.spi.indexing.support.IndexingSupport;
58
import org.netbeans.modules.spring.api.SpringUtilities;
56
import org.netbeans.modules.spring.api.SpringUtilities;
Lines 70-76 Link Here
70
 *
68
 *
71
 * @author alexeybutenko
69
 * @author alexeybutenko
72
 */
70
 */
73
71
@IndexerRegistration(name=SpringBinaryIndexer.INDEXER_NAME, version=SpringBinaryIndexer.INDEX_VERSION)
74
public class SpringBinaryIndexer extends BinaryIndexer {
72
public class SpringBinaryIndexer extends BinaryIndexer {
75
73
76
    private static final Logger LOGGER = Logger.getLogger(SpringBinaryIndexer.class.getSimpleName());
74
    private static final Logger LOGGER = Logger.getLogger(SpringBinaryIndexer.class.getSimpleName());
Lines 175-202 Link Here
175
        }
173
        }
176
        return null;
174
        return null;
177
    }
175
    }
178
179
    public static class Factory extends BinaryIndexerFactory {
180
181
        @Override
182
        public BinaryIndexer createIndexer() {
183
            return new SpringBinaryIndexer();
184
        }
185
186
        @Override
187
        public void rootsRemoved(Iterable<? extends URL> removedRoots) {
188
//            throw new UnsupportedOperationException("Not supported yet.");
189
        }
190
191
        @Override
192
        public String getIndexerName() {
193
            return INDEXER_NAME;
194
        }
195
196
        @Override
197
        public int getIndexVersion() {
198
            return INDEX_VERSION;
199
        }
200
    }
201
202
}
176
}
(-)a/spring.beans/src/org/netbeans/modules/spring/beans/resources/layer.xml (-3 lines)
Lines 153-161 Link Here
153
        </folder>
153
        </folder>
154
    </folder>
154
    </folder>
155
    <folder name="Editors">
155
    <folder name="Editors">
156
        <file name="org-netbeans-modules-spring-beans-index-SpringBinaryIndexer$Factory.instance">
157
            <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.indexing.BinaryIndexerFactory"/>
158
        </file>
159
        <folder name="text">
156
        <folder name="text">
160
            <folder name="x-springconfig+xml">
157
            <folder name="x-springconfig+xml">
161
                <folder name="HyperlinkProviders">
158
                <folder name="HyperlinkProviders">

Return to bug 187271