Package com.facebook.swift.parser.model

Examples of com.facebook.swift.parser.model.Header


        Preconditions.checkState(!isBlank(thriftNamespace), "Thrift URI %s can not be translated to a namespace", thriftUri);
        final SwiftDocumentContext context = new SwiftDocumentContext(thriftUri, thriftNamespace, swiftGeneratorConfig, typeRegistry, typedefRegistry);

        final Document document = context.getDocument();
        final Header header = document.getHeader();

        String effectiveJavaNamespace = "java.swift";
        if (swiftGeneratorConfig.usePlainJavaNamespace()) {
            effectiveJavaNamespace = "java";
        }

        // Override takes precedence
        String javaPackage = swiftGeneratorConfig.getOverridePackage();
        // Otherwise fallback on package specified in .thrift file
        if (javaPackage == null) {
            javaPackage = header.getNamespace(effectiveJavaNamespace);
        }
        // Or the default if we don't have an override package or a package in the .thrift file
        if (javaPackage == null) {
            javaPackage = swiftGeneratorConfig.getDefaultPackage();
        }

        // If none of the above options get us a package to use, fail
        Preconditions.checkState(javaPackage != null, "thrift uri %s does not declare a '%s' namespace!", thriftUri, effectiveJavaNamespace);

        // Make a note that this document is a parent of all the documents included, directly or recursively
        parentDocuments.push(thriftUri);

        try {
            for (final String include : header.getIncludes()) {
                final URI includeUri = swiftGeneratorConfig.getInputBase().resolve(include);
                LOG.debug("Found {} included from {}.", includeUri, thriftUri);
                parseDocument(includeUri,
                              // If the includes should also generate code, pass the list of
                              // contexts down to the include parser, otherwise pass a null in
View Full Code Here


        Preconditions.checkState(!isBlank(thriftNamespace), "Thrift URI %s can not be translated to a namespace", thriftUri);
        final SwiftDocumentContext context = new SwiftDocumentContext(thriftUri, thriftNamespace, swiftGeneratorConfig, typeRegistry, typedefRegistry);

        final Document document = context.getDocument();
        final Header header = document.getHeader();

        String javaPackage = context.getJavaPackage();

        // Add a Constants type so that the Constants visitor can render is.
        typeRegistry.add(new SwiftJavaType(thriftNamespace, "Constants", javaPackage));

        // Make a note that this document is a parent of all the documents included, directly or recursively
        parentDocuments.push(thriftUri);

        try {
            for (final String include : header.getIncludes()) {
                final URI includeUri = swiftGeneratorConfig.getInputBase().resolve(include);
                LOG.debug("Found {} included from {}.", includeUri, thriftUri);
                parseDocument(includeUri,
                              // If the includes should also generate code, pass the list of
                              // contexts down to the include parser, otherwise pass a null in
View Full Code Here

        Preconditions.checkState(!isBlank(thriftNamespace), "Thrift URI %s can not be translated to a namespace", thriftUri);
        final SwiftDocumentContext context = new SwiftDocumentContext(thriftUri, thriftNamespace, swiftGeneratorConfig, typeRegistry, typedefRegistry);

        final Document document = context.getDocument();
        final Header header = document.getHeader();

        String javaPackage = context.getJavaPackage();

        // Make a note that this document is a parent of all the documents included, directly or recursively
        parentDocuments.push(thriftUri);

        try {
            for (final String include : header.getIncludes()) {
                final URI includeUri = swiftGeneratorConfig.getInputBase().resolve(include);
                LOG.debug("Found {} included from {}.", includeUri, thriftUri);
                parseDocument(includeUri,
                              // If the includes should also generate code, pass the list of
                              // contexts down to the include parser, otherwise pass a null in
View Full Code Here

        Preconditions.checkState(!isBlank(thriftNamespace), "Thrift URI %s can not be translated to a namespace", thriftUri);
        final SwiftDocumentContext context = new SwiftDocumentContext(thriftUri, thriftNamespace, swiftGeneratorConfig, typeRegistry, typedefRegistry);

        final Document document = context.getDocument();
        final Header header = document.getHeader();
        final String javaNamespace = Objects.firstNonNull(Objects.firstNonNull(swiftGeneratorConfig.getOverridePackage(),
                                                                               header.getNamespace("java")),
                                                          swiftGeneratorConfig.getDefaultPackage());
        Preconditions.checkState(!isBlank(javaNamespace), "thrift uri %s does not declare a java namespace!", thriftUri);

        for (final String include : header.getIncludes()) {
            final URI includeUri = swiftGeneratorConfig.getInputBase().resolve(include);
            LOG.debug("Found {} included from {}.", includeUri, thriftUri);
            parseDocument(includeUri,
                          // If the includes should also generate code, pass the list of
                          // contexts down to the include parser, otherwise pass a null in
View Full Code Here

        Preconditions.checkState(!isBlank(thriftNamespace), "Thrift URI %s can not be translated to a namespace", thriftUri);
        final SwiftDocumentContext context = new SwiftDocumentContext(thriftUri, thriftNamespace, swiftGeneratorConfig, typeRegistry, typedefRegistry);

        final Document document = context.getDocument();
        final Header header = document.getHeader();

        String javaPackage = context.getJavaPackage();

        // Add a Constants type so that the Constants visitor can render is.
        typeRegistry.add(new SwiftJavaType(thriftNamespace, "Constants", "Constants", javaPackage));

        // Make a note that this document is a parent of all the documents included, directly or recursively
        parentDocuments.push(thriftUri);

        try {
            for (final String include : header.getIncludes()) {
                final URI includeUri = swiftGeneratorConfig.getInputBase().resolve(include);
                LOG.debug("Found {} included from {}.", includeUri, thriftUri);
                parseDocument(includeUri,
                              // If the includes should also generate code, pass the list of
                              // contexts down to the include parser, otherwise pass a null in
View Full Code Here

        Preconditions.checkState(!isBlank(thriftNamespace), "Thrift URI %s can not be translated to a namespace", thriftUri);
        final SwiftDocumentContext context = new SwiftDocumentContext(thriftUri, thriftNamespace, swiftGeneratorConfig, typeRegistry, typedefRegistry);

        final Document document = context.getDocument();
        final Header header = document.getHeader();

        // Override takes precedence
        String javaNamespace = swiftGeneratorConfig.getOverridePackage();
        // Otherwise fallback on package specified in .thrift file
        if (javaNamespace == null) {
            javaNamespace = header.getNamespace("java");
        }
        // Or the default if we don't have an override package or a package in the .thrift file
        if (javaNamespace == null) {
            javaNamespace = swiftGeneratorConfig.getDefaultPackage();
        }

        // If none of the above options get us a package to use, fail
        Preconditions.checkState(javaNamespace != null, "thrift uri %s does not declare a java namespace!", thriftUri);

        // Make a note that this document is a parent of all the documents included, directly or recursively
        parentDocuments.push(thriftUri);

        try {
            for (final String include : header.getIncludes()) {
                final URI includeUri = swiftGeneratorConfig.getInputBase().resolve(include);
                LOG.debug("Found {} included from {}.", includeUri, thriftUri);
                parseDocument(includeUri,
                              // If the includes should also generate code, pass the list of
                              // contexts down to the include parser, otherwise pass a null in
View Full Code Here

TOP

Related Classes of com.facebook.swift.parser.model.Header

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.