예제 #1
0
  private void selectTypes(ModuleDeclaration parsedUnit, ASTNode node) {
    if (node instanceof ConstantReference) {
      selectOnConstant(parsedUnit, (ConstantReference) node);
    } else if (node instanceof RubyColonExpression) {
      selectOnColonExpression(parsedUnit, (RubyColonExpression) node);
    }

    if (selectionElements.isEmpty()) {
      TypeNameMatchRequestor requestor =
          new TypeNameMatchRequestor() {
            @Override
            public void acceptTypeNameMatch(TypeNameMatch match) {
              selectionElements.add(match.getType());
            }
          };
      String unqualifiedName = null;
      if (node instanceof RubyColonExpression) {
        RubyColonExpression expr = (RubyColonExpression) node;
        unqualifiedName = expr.getName();
      } else if (node instanceof ConstantReference) {
        ConstantReference expr = (ConstantReference) node;
        unqualifiedName = expr.getName();
      }
      if (unqualifiedName != null) {
        ScriptModelUtil.searchTypeDeclarations(
            sourceModule.getScriptProject(), unqualifiedName, requestor);
      }
    }
  }
예제 #2
0
 public boolean visit(ConstantDeclaration declaration) throws Exception {
   int modifiers = Modifiers.AccConstant | Modifiers.AccPublic | Modifiers.AccFinal;
   if (fCurrentParent != null) {
     modifiers = modifiers | PHPCoreConstants.AccClassField;
   }
   modifiers = markAsDeprecated(modifiers, declaration);
   ConstantReference constantName = declaration.getConstantName();
   int offset = constantName.sourceStart();
   int length = constantName.sourceEnd();
   StringBuilder metadata = new StringBuilder();
   if (fCurrentQualifier != null) {
     metadata.append(fCurrentQualifierCounts.get(fCurrentQualifier));
     metadata.append(";"); // $NON-NLS-1$
   }
   modifyDeclaration(
       declaration,
       new DeclarationInfo(
           IModelElement.FIELD,
           modifiers,
           offset,
           length,
           offset,
           length,
           ASTUtils.stripQuotes(constantName.getName()),
           metadata.length() == 0 ? null : metadata.toString(),
           encodeDocInfo(declaration),
           fCurrentQualifier,
           fCurrentParent));
   return visitGeneral(declaration);
 }
 public boolean visit(ConstantDeclaration declaration) throws Exception {
   final ISourceElementRequestor.FieldInfo info = new ISourceElementRequestor.FieldInfo();
   info.modifiers = Modifiers.AccConstant | Modifiers.AccPublic | Modifiers.AccFinal;
   final ConstantReference constantName = declaration.getConstantName();
   info.name = ASTUtils.stripQuotes(constantName.getName());
   info.nameSourceEnd = constantName.sourceEnd() - 1;
   info.nameSourceStart = constantName.sourceStart();
   info.declarationStart = declaration.sourceStart();
   fRequestor.enterField(info);
   return true;
 }
예제 #4
0
  public boolean visit(StaticConstantAccess access) throws Exception {
    // This is constant field access:
    if (access.getConstant() != null) {
      final ConstantReference constantReference = access.getConstant();
      final String name = constantReference.getName();

      modifyReference(
          access,
          new ReferenceInfo(
              IModelElement.FIELD,
              constantReference.sourceStart(),
              constantReference.sourceEnd() - constantReference.sourceStart(),
              name,
              null,
              null));
    }

    return visitGeneral(access);
  }
예제 #5
0
 public boolean visit(ConstantReference s) throws Exception {
   Map<String, String> parameters = createInitialParameters(s);
   parameters.put("name", s.getName());
   xmlWriter.startTag("ConstantReference", parameters);
   return true;
 }