Пример #1
0
 private void selectionOnVariable(ModuleDeclaration parsedUnit, VariableReference e) {
   String name = e.getName();
   if (name.startsWith("@")) { // $NON-NLS-1$
     IField[] fields =
         RubyModelUtils.findFields(mixinModel, sourceModule, parsedUnit, name, e.sourceStart());
     addArrayToCollection(fields, selectionElements);
   } else {
     /*
      * local vars (legacy, saved for speed reasons: we don't need to use
      * mixin model for local vars)
      */
     ASTNode parentScope = null;
     for (int i = wayToNode.length; --i >= 0; ) {
       final ASTNode node = wayToNode[i];
       if (node instanceof MethodDeclaration
           || node instanceof TypeDeclaration
           || node instanceof ModuleDeclaration
           || node instanceof RubyForStatement2) {
         parentScope = node;
         break;
       }
     }
     if (parentScope != null) {
       RubyAssignment[] assignments =
           RubyTypeInferencingUtils.findLocalVariableAssignments(parentScope, e, name);
       if (assignments.length > 0) {
         final ASTNode left = assignments[0].getLeft();
         selectionElements.add(createLocalVariable(name, left.sourceStart(), left.sourceEnd()));
       } else {
         selectionElements.add(createLocalVariable(name, e.sourceStart(), e.sourceEnd()));
       }
     }
   }
 }
 private void handleVariableReference(VariableReference ref) {
   final String varName = ref.getName();
   if (varName.length() != 0) {
     if (varName.charAt(0) == '$') {
       requestor.addPosition(ref.sourceStart(), ref.sourceEnd(), HL_GLOBAL_VARIABLE);
     } else if (varName.charAt(0) == '@') {
       if (varName.length() > 2 && varName.charAt(1) == '@') {
         requestor.addPosition(ref.sourceStart(), ref.sourceEnd(), HL_CLASS_VARIABLE);
       } else {
         requestor.addPosition(ref.sourceStart(), ref.sourceEnd(), HL_INSTANCE_VARIABLE);
       }
     } else {
       requestor.addPosition(ref.sourceStart(), ref.sourceEnd(), HL_LOCAL_VARIABLE);
     }
   }
 }
Пример #3
0
 public boolean visit(VariableReference s) throws Exception {
   Map<String, String> parameters = createInitialParameters(s);
   parameters.put("name", s.getName());
   xmlWriter.startTag("VariableReference", parameters);
   return true;
 }