Package com.redhat.ceylon.compiler.typechecker.tree

Examples of com.redhat.ceylon.compiler.typechecker.tree.Node


       
        ProducedReference refinedMember = ci.getType().getTypedReference(refined, typeArgs);
        ProducedReference refiningMember = ci.getType().getTypedReference(dec, typeArgs);
        Declaration refinedMemberDec = refinedMember.getDeclaration();
    Declaration refiningMemberDec = refiningMember.getDeclaration();
    Node typeNode = getTypeErrorNode(that);
    if (refinedMemberIsDynamicallyTyped(refinedMemberDec, refiningMemberDec)) {
          checkRefiningMemberDynamicallyTyped(refined, refiningMemberDec, typeNode);
        }
    else if (refiningMemberIsDynamicallyTyped(refinedMemberDec, refiningMemberDec)) {
          checkRefinedMemberDynamicallyTyped(refined, refinedMemberDec, typeNode);
View Full Code Here


                ProducedType refinedParameterType =
                    refinedMember.getTypedParameter(rparam).getFullType();
                ProducedType parameterType =
                    member.getTypedParameter(param).getFullType();
                Tree.Parameter parameter = pl.getParameters().get(i);
                Node typeNode = parameter;
                if (parameter instanceof Tree.ParameterDeclaration) {
                  Tree.Type type = ((Tree.ParameterDeclaration) parameter)
                      .getTypedDeclaration().getType();
                  if (type!=null) {
                    typeNode = type;
View Full Code Here

        pn.addError("annotations may not have callable parameters");
      }
      else {
        ProducedType pt = p.getType();
        if (pt!=null && isIllegalAnnotationParameterType(pt)) {
          Node errorNode = pn instanceof Tree.ValueParameterDeclaration ?
              ((Tree.ValueParameterDeclaration) pn).getTypedDeclaration().getType() : pn;
          errorNode.addError("illegal annotation parameter type: '" +
              pt.getProducedTypeName() + "'");
        }
        Tree.SpecifierOrInitializerExpression se = null;
        if (pn instanceof Tree.InitializerParameter) {
          se = ((Tree.InitializerParameter) pn).getSpecifierExpression();
View Full Code Here

    private static void checkVisibility(Node that,
            TypedDeclaration td) {
        ProducedType type = td.getType();
        if (type!=null) {
            Node typeNode = getTypeErrorNode(that);
            if (!isCompletelyVisible(td, type)) {
                typeNode.addError("type of declaration " + getName(td) +
                        " is not visible everywhere declaration is visible: '" +
                        type.getProducedTypeName(that.getUnit()) +
                        "' involves an unshared type declaration", 711);
            }
            if (!checkModuleVisibility(td, type)) {
                typeNode.addError("type of declaration " + getName(td) +
                        " that is visible outside this module comes from an imported module that is not re-exported: '" +
                        type.getProducedTypeName(that.getUnit()) +
                        "' involves an unexported type declaration", 712);
            }
        }
View Full Code Here

        }
    }

    //must be used *after* addLinkBetweenModuleAndNode has been set ie post ModuleVisitor visit
    public void addErrorToModule(Module module, String error) {
        Node node = moduleToNode.get(module);
        if (node != null) {
            node.addError(new ModuleDependencyAnalysisError(node, error));
        }
        else {
            //might happen if the faulty module is a compiled module
            System.err.println("This is a type checker bug, please report. " +
                    "\nExpecting to add error on non present module node: " + module.toString() + ". Error " + error);
View Full Code Here

            if (that.getVersion()==null) {
                that.addError("missing module version");
            }
            String version = getVersionString(that.getVersion());
            List<String> name;
            Node node;
            if (that.getImportPath()!=null) {
              name = getNameAsList(that.getImportPath());
              node = that.getImportPath();
            }
            else if (that.getQuotedLiteral()!=null) {
                String nameString = getNameString(that.getQuotedLiteral());
                name = asList(nameString.split("\\."));
                node = that.getQuotedLiteral();
            }
            else {
              name = Collections.emptyList();
              node = null;
            }
            if (name.isEmpty()) {
                that.addError("missing module name");
            }
            else if (name.get(0).equals(Module.DEFAULT_MODULE_NAME)) {
              if (that.getImportPath()!=null) {
                node.addError("reserved module name: 'default'");
              }
            }
            else if (name.size()==1 && name.get(0).equals("ceylon")) {
                if (that.getImportPath()!=null) {
                    node.addError("reserved module name: 'ceylon'");
                }
            }
            else if (name.size()>1 && name.get(0).equals("ceylon")
                    && name.get(1).equals("language")) {
                if (that.getImportPath()!=null) {
                    node.addError("the language module is imported implicitly");
                }
            }
            else {
                Module importedModule = moduleManager.getOrCreateModule(name,version);
                if (that.getImportPath()!=null) {
View Full Code Here

        unit.setFullPath(fullPath);
        unit.setRelativePath(relativePath);
        pkg.removeUnit(unit);
        pkg.addUnit(unit);
        super.visit(that);
        Node firstNonImportNode = null;
        int index = -1;
        for (Node d: that.getDeclarations()) {
            firstNonImportNode = d;
            index = d.getToken().getTokenIndex();
            break;
        }
        for (Tree.ModuleDescriptor md: that.getModuleDescriptors()) {
            if (index<0 || md.getToken().getTokenIndex()<index) {
                firstNonImportNode = md;
                index = md.getToken().getTokenIndex();
            }
            break;
        }
        for (Tree.PackageDescriptor pd: that.getPackageDescriptors()) {
            if (index<0 || pd.getToken().getTokenIndex()<index) {
                firstNonImportNode = pd;
                index = pd.getToken().getTokenIndex();
            }
            break;
        }
        if (firstNonImportNode!=null) {
            for (Tree.Import im: that.getImportList().getImports()) {
                if (im.getStopIndex()>firstNonImportNode.getStartIndex()) {
                    im.addError("import statement must occur before any declaration or descriptor");
                }
            }
        }
        boolean first=true;
View Full Code Here

        return sb.toString();
    }
   
    private Tree.DocLink findDocLink(final String docLinkText, Referenceable referenceable) {
        final Tree.DocLink[] docLinks = new Tree.DocLink[1];
        Node scopeNode = ceylonDocTool.getNode(referenceable);
        if (scopeNode != null) {
            scopeNode.visit(new Visitor() {
                @Override
                public void visit(Tree.DocLink docLink) {
                    String s1 = normalizeSpaces(docLinkText);
                    String s2 = normalizeSpaces(docLink.getText());
                    if (s1.equals(s2)) {
View Full Code Here

     * Returns the starting and ending line number of the given declaration
     * @param decl The declaration
     * @return [start, end]
     */
    protected int[] getDeclarationSrcLocation(Declaration decl) {
        Node node = modelNodeMap.get(decl);
        if (node == null) {
            return null;
        } else {
            return new int[] { node.getToken().getLine(), node.getEndToken().getLine() };
        }
    }
View Full Code Here

            return;
        }
       
        final Scope scope = d.getScope();
        final PhasedUnit unit = getUnit(d);
        final Node node = getNode(d);
        if (scope == null || unit == null || unit.getUnit() == null || node == null || !(d instanceof MethodOrValue)) {
            return;
        }
       
        List<ProducedType> documentedExceptions = new ArrayList<ProducedType>();
        for (Annotation annotation : d.getAnnotations()) {
            if (annotation.getName().equals("throws")) {
                String exceptionName = annotation.getPositionalArguments().get(0);
                Declaration exceptionDecl = scope.getMemberOrParameter(unit.getUnit(), exceptionName, null, false);
                if (exceptionDecl instanceof TypeDeclaration) {
                    documentedExceptions.add(((TypeDeclaration) exceptionDecl).getType());
                }
            }
        }
       
        final List<ProducedType> thrownExceptions = new ArrayList<ProducedType>();
        node.visitChildren(new Visitor() {
            @Override
            public void visit(Tree.Throw that) {
                Expression expression = that.getExpression();
                if (expression != null) {
                    thrownExceptions.add(expression.getTypeModel());
View Full Code Here

TOP

Related Classes of com.redhat.ceylon.compiler.typechecker.tree.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.