Changeset 3384 for devel-tools/trunk


Ignore:
Timestamp:
Feb 7, 2008, 2:44:46 PM (13 years ago)
Author:
yura
Message:
  • Globa searcher - returns stack of AstNode?.
Location:
devel-tools/trunk/eclipse/org.refal.plus.rfpdt.editor/src/org/refal/plus/rfpdt/editor
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt.editor/src/org/refal/plus/rfpdt/editor/RfpEditor.java

    r3382 r3384  
    4242import org.refal.plus.rfpdt.comp.ast.AstFuncDef;
    4343import org.refal.plus.rfpdt.comp.ast.AstImplem;
     44import org.refal.plus.rfpdt.comp.ast.AstName;
    4445import org.refal.plus.rfpdt.comp.ast.AstNode;
    4546import org.refal.plus.rfpdt.comp.ast.AstRef;
    4647import org.refal.plus.rfpdt.comp.ast.AstVar;
     48import org.refal.plus.rfpdt.comp.ast.Searcher;
    4749import org.refal.plus.rfpdt.editor.PresentationVisitor.StylePosition;
    4850import org.refal.plus.rfpdt.editor.color.ColorManager;
     
    7173
    7274        private AstNode[] getNodeList (AstImplem astImplem, int offset) {
    73             AstNode astNode = SearchVisitor.search(astImplem, offset);
    74             if (astNode instanceof AstVar) {
    75                 AstVar astVar = ((AstVar) astNode).varDefinition;
     75            ArrayList<AstNode> astNodeList = Searcher.search(astImplem, offset);
     76            int size = astNodeList.size();
     77            AstVar astVar = null;
     78            if (size > 0 && astNodeList.get(size-1) instanceof AstVar)
     79                astVar = (AstVar) astNodeList.get(size-1);
     80            else if (size > 1 && astNodeList.get(size-2) instanceof AstVar)
     81                astVar = (AstVar) astNodeList.get(size-2);
     82            if (astVar != null) {
     83                astVar = astVar.varDefinition;
    7684                if (astVar == null || astVar.varUses == null)
    7785                    return empty;
    7886                return astVar.varUses.toArray(new AstNode[astVar.varUses.size()]);
    79             } else if (astNode instanceof AstFence) {
    80                 AstFence astFence = (AstFence) astNode;
     87            }
     88            else if (size > 0 && astNodeList.get(size-1) instanceof AstFence) {
     89                AstFence astFence = (AstFence) astNodeList.get(size-1);
    8190                if (astFence.uses == null)
    8291                    return empty;
    8392                return astFence.uses.toArray(new AstNode[astFence.uses.size()]);
    84             } else if (astNode instanceof AstCut) {
    85                 AstFence astFence = ((AstCut) astNode).fence;
     93            } else if (size > 0 && astNodeList.get(size-1) instanceof AstCut) {
     94                AstFence astFence = ((AstCut) astNodeList.get(size-1)).fence;
    8695                if (astFence == null || astFence.uses == null)
    8796                    return empty;
    8897                return astFence.uses.toArray(new AstNode[astFence.uses.size()]);
    89             } else {
     98            } else if (size > 1 && astNodeList.get(size-1) instanceof AstName){
     99                AstNode astNode =  astNodeList.get(size-2);
    90100                AstDecl astDecl = null;
    91101                if (astNode instanceof AstDecl)
     
    103113                return astDecl.uses.toArray(new AstNode[astDecl.uses.size()]);
    104114            }
     115            return null;
    105116        }
    106117
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt.editor/src/org/refal/plus/rfpdt/editor/RfpTextHover.java

    r3379 r3384  
    11package org.refal.plus.rfpdt.editor;
     2
     3import java.util.ArrayList;
    24
    35import org.eclipse.jface.text.DefaultTextHover;
     
    810import org.eclipse.ui.texteditor.MarkerAnnotation;
    911import org.refal.plus.rfpdt.comp.ast.AstImplem;
     12import org.refal.plus.rfpdt.comp.ast.AstName;
    1013import org.refal.plus.rfpdt.comp.ast.AstNode;
    1114import org.refal.plus.rfpdt.comp.ast.IHoverInfo;
     15import org.refal.plus.rfpdt.comp.ast.Searcher;
    1216
    1317public class RfpTextHover extends DefaultTextHover {
     
    2832        if (astImplem == null)
    2933            return null;
    30         AstNode astNode = SearchVisitor.search(astImplem, hoverRegion.getOffset());
    31         if (!(astNode instanceof IHoverInfo))
    32             return null;
    33         return ((IHoverInfo) astNode).getHoverInfo();
     34        ArrayList<AstNode> astNodeList = Searcher.search(astImplem, hoverRegion.getOffset());
     35        int size = astNodeList.size();
     36        if (size > 1 && astNodeList.get(size-1) instanceof AstName && astNodeList.get(size-2) instanceof IHoverInfo)
     37            return ((IHoverInfo) astNodeList.get(size-2) ).getHoverInfo();
     38        return null;
    3439    }
    3540
Note: See TracChangeset for help on using the changeset viewer.