<commit_before>package com.redhat.ceylon.eclipse.imp.editor;

import static com.redhat.ceylon.eclipse.imp.core.CeylonReferenceResolver.getReferencedDeclaration;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.eclipse.imp.language.ILanguageService;
import org.eclipse.imp.parser.IParseController;
import org.eclipse.imp.services.IOccurrenceMarker;

import com.redhat.ceylon.compiler.typechecker.model.Declaration;
import com.redhat.ceylon.compiler.typechecker.tree.Node;
import com.redhat.ceylon.compiler.typechecker.tree.Tree;
import com.redhat.ceylon.eclipse.util.FindDeclarationVisitor;
import com.redhat.ceylon.eclipse.util.FindReferenceVisitor;

public class CeylonOccurrenceMarker implements ILanguageService, IOccurrenceMarker {
    
    private List<Object> fOccurrences = Collections.emptyList();
    
    public String getKindName() {
        return "Ceylon Occurence Marker";
    }
    
    public List<Object> getOccurrencesOf(IParseController parseController, Object node) {
        
        if (node instanceof Node) {
            
            // Check whether we even have an AST in which to find occurrences
            Tree.CompilationUnit root = (Tree.CompilationUnit) parseController.getCurrentAst();
            if (root == null) {
                return Collections.emptyList();
            }
            
            fOccurrences = new ArrayList<Object>();
            Declaration declaration = getReferencedDeclaration((Node) node);
            if (declaration != null) {
                FindReferenceVisitor frv = new FindReferenceVisitor(declaration);
                root.visit(frv);
                fOccurrences.addAll(frv.getNodes());
                FindDeclarationVisitor fdv = new FindDeclarationVisitor(declaration);
                root.visit(fdv);
                fOccurrences.add(fdv.getDeclarationNode());
            }
            return fOccurrences;
            
        }
        else {
            return Collections.emptyList();
        }
        
    }
    
}<commit_msg>fix bug where extra occurrence annotation appeared at offset 0<commit_after>package com.redhat.ceylon.eclipse.imp.editor;

import static com.redhat.ceylon.eclipse.imp.core.CeylonReferenceResolver.getReferencedDeclaration;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.eclipse.imp.language.ILanguageService;
import org.eclipse.imp.parser.IParseController;
import org.eclipse.imp.services.IOccurrenceMarker;

import com.redhat.ceylon.compiler.typechecker.model.Declaration;
import com.redhat.ceylon.compiler.typechecker.tree.Node;
import com.redhat.ceylon.compiler.typechecker.tree.Tree;
import com.redhat.ceylon.eclipse.util.FindDeclarationVisitor;
import com.redhat.ceylon.eclipse.util.FindReferenceVisitor;

public class CeylonOccurrenceMarker implements ILanguageService, IOccurrenceMarker {
    
    private List<Object> fOccurrences = Collections.emptyList();
    
    public String getKindName() {
        return "Ceylon Occurence Marker";
    }
    
    public List<Object> getOccurrencesOf(IParseController parseController, Object node) {
        
        if (node instanceof Node) {
            
            // Check whether we even have an AST in which to find occurrences
            Tree.CompilationUnit root = (Tree.CompilationUnit) parseController.getCurrentAst();
            if (root == null) {
                return Collections.emptyList();
            }
            
            fOccurrences = new ArrayList<Object>();
            Declaration declaration = getReferencedDeclaration((Node) node);
            if (declaration != null) {
                FindReferenceVisitor frv = new FindReferenceVisitor(declaration);
                root.visit(frv);
                fOccurrences.addAll(frv.getNodes());
                FindDeclarationVisitor fdv = new FindDeclarationVisitor(declaration);
                root.visit(fdv);
                if (fdv.getDeclarationNode()!=null) {
                    fOccurrences.add(fdv.getDeclarationNode());
                }
            }
            return fOccurrences;
            
        }
        else {
            return Collections.emptyList();
        }
        
    }
    
}
{'fraction_non_alphanumeric': 0.08602403959462644, 'fraction_numerical': 0.00023568230025925054, 'mean_word_length': 2.563392107472712, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5634069', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1106, 'n_words': 215}