Examples of GoPackageReference


Examples of ro.redeul.google.go.lang.psi.GoPackageReference

    public String[] getPackageImports() {

        List<String> packageImports = new ArrayList<String>();

        for (GoImportDeclaration importSpec : imports) {
            GoPackageReference packageReference = importSpec.getPackageReference();

            if (packageReference == null) {
                // If there is no package reference but the import path contains
                // a ".', treat it like a package reference were specfied.
                GoLiteralString importPath = importSpec.getImportPath();
                if (importPath != null) {
                    String path = importPath.getValue();
                    if (isDotImport(path)) {
                        path = findDefaultPackageName(path);
                    }
                    packageImports.add(path);
                }
                continue;
            }

            if (packageReference.isLocal() || packageReference.isBlank()) {
                continue;
            }

            packageImports.add(packageReference.getString());
        }

        return packageImports.toArray(new String[packageImports.size()]);
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoPackageReference

                    addTarget(declaration);
            }

            boolean isReferenceTo(GoImportDeclaration importDeclaration) {

                GoPackageReference packageReference = importDeclaration.getPackageReference();

                String packageName = null;
                if (packageReference != null && !(packageReference.isBlank() || packageReference.isLocal()))
                    packageName = packageReference.getString();
                else {
                    GoPackage goPackage = importDeclaration.getPackage();
                    packageName = goPackage != null ? goPackage.getName() : "";
                }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoPackageReference

* To change this template use File | Settings | File Templates.
*/
public class GoResolveUtil {

    public static boolean inSamePackage(GoQualifiedNameElement qualifiedElement, GoImportDeclaration importSpec) {
        GoPackageReference importedPackageReference = importSpec.getPackageReference();
        GoPackageReference elementReference = qualifiedElement.getPackageReference();

        GoLiteralString importPath = importSpec.getImportPath();
        if (importPath == null )
            return false;

        // import "a"; var x a.T;
        if (importedPackageReference == null && elementReference != null
            && elementReference.getString().equals(findDefaultPackageName(importPath.getValue()))) {
            return true;
        }

        // import . "a"; var x T; // T is defined inside package a
        if ( importedPackageReference != null && importedPackageReference.isLocal() && elementReference == null ) {
            return true;
        }

        // import x "a"; var x.T;
        return importedPackageReference != null && elementReference != null && elementReference.getString().equals(importedPackageReference.getString());

    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoPackageReference

    }

    @Override
    @NotNull
    public String getPackageAlias() {
        GoPackageReference packageReference = getPackageReference();

        if (packageReference == null) {
            return getPackageName();
        }

        if (packageReference.isBlank() || packageReference.isLocal()) {
            return "";
        }

        return packageReference.getString();
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoPackageReference

    public boolean processDeclarations(@NotNull PsiScopeProcessor processor,
                                       @NotNull ResolveState state, PsiElement lastParent,
                                       @NotNull PsiElement place) {

        // import _ "a"; ( no declarations are visible from this import )
        GoPackageReference packageReference = getPackageReference();
        if (packageReference != null && packageReference.isBlank()) {
            return true;
        }

        // import . "asdfaf" -> exports in the target package should act as declaration in the current one (but only if this is the initial state)
        if ( packageReference != null && packageReference.isLocal() && lastParent != null ) {
            GoPackage goPackage = getPackage();
            if ( goPackage != null )
                return goPackage.processDeclarations(processor, ResolveStates.packageExports(), null,  place);
        }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoPackageReference

        return getPackageAlias();
    }

    @Override
    public String getLookupTypeText() {
        GoPackageReference packageReference = getPackageReference();

        if (packageReference != null && !packageReference.isBlank() && !packageReference.isLocal()) {
            return "package alias";
        }

        return "package";
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.