Skip to main content
summaryrefslogtreecommitdiffstats
blob: 5ed9a1aaf6fe199d4c78b687d4d7e3b4072c9f28 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*******************************************************************************
* Copyright (c) 2007 IBM Corporation.
* 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
*
* Contributors:
*    Robert Fuhrer (rfuhrer@watson.ibm.com) - initial API and implementation

*******************************************************************************/

package org.eclipse.imp.indexing;

import org.eclipse.imp.language.ILanguageService;


/**
 * Base class for implementations of the indexContributor language service extension point.
 * @author Dr. Robert M. Fuhrer
 *
 */
public abstract class IndexContributorBase implements ILanguageService {
    public IndexContributorBase() {
        super();
    }

    /**
     * Create index entries for entities in the given AST and add them to the given Indexer,
     * by means of calls to Indexer.addEntry().
     */
    public abstract void contributeEntries(Object ast, Indexer indexer);

    /**
     * Parse the given entry string
     * @param s
     * @return
     */
    public IndexEntry parseEntry(String s) {
        char kind= s.charAt(0);
        IndexEntry entry;

        if (kind == DefinitionIndexEntry.DEFINITION_TYPE)
            entry= new DefinitionIndexEntry();
        else if (kind == ReferenceIndexEntry.REFERENCE_TYPE)
            entry= new ReferenceIndexEntry();
        else
            return null;

        entry.parseFromString(s);
        return entry;
    }
}

Back to the top