Examples of GoNamesCache


Examples of ro.redeul.google.go.lang.stubs.GoNamesCache

        int caretOffset = editor.getCaretModel().getOffset();
        if (project == null) {
            return null;
        }

        GoNamesCache namesCache = GoNamesCache.getInstance(project);

        Set<String> imported = new HashSet<String>();
        for (GoImportDeclarations ids : file.getImportDeclarations()) {
            for (GoImportDeclaration id : ids.getDeclarations()) {
                String name = id.getPackageName();
                if (name != null && !id.getPackageAlias().isEmpty()) {
                    imported.add(name);
                }
            }
        }

        Data toImport = null;
        for (RangeHighlighter highlighter : getAllHighlighters(project)) {
            int start = highlighter.getStartOffset();
            int end = highlighter.getEndOffset();
            TextRange range = new TextRange(start, end);
            Object errorStripeTooltip = highlighter.getErrorStripeTooltip();
            if (!visibleRange.contains(range) ||
                editor.getFoldingModel().isOffsetCollapsed(start) ||
                !(errorStripeTooltip instanceof HighlightInfo)) {
                continue;
            }

            // if this a "Unresolved symbol" error
            HighlightInfo info = (HighlightInfo) errorStripeTooltip;
            if (info.getSeverity() != HighlightSeverity.ERROR ||
                !info.getDescription().contains("Unresolved symbol")) {
                continue;
            }

            GoLiteralIdentifier id = findElementOfClassAtRange(file, start, end, GoLiteralIdentifier.class);
            if (!isPackageUsage(id)) {
                continue;
            }

            if (id == null) {
                continue;
            }

            // packages exist
            String expectedPackage = id.getText();
            List<String> sdkPackages = getPackagesByName(
                    namesCache.getSdkPackages(), expectedPackage);
            List<String> projectPackages = getPackagesByName(
                    namesCache.getProjectPackages(), expectedPackage);
            if (imported.contains(expectedPackage) || sdkPackages.size() == 0 && projectPackages.size() == 0) {
                continue;
            }

            toImport = new Data(id, sdkPackages, projectPackages);
View Full Code Here

Examples of ro.redeul.google.go.lang.stubs.GoNamesCache

                                          @NotNull CompletionResultSet result) {

                Project project = params.getOriginalFile().getProject();

                //TODO: reevaluate this.
                GoNamesCache packageNamesCache = GoNamesCache.getInstance(project);
                Collection<String> goSdkPackages = packageNamesCache.getSdkPackages();

                for (String goPackage : goSdkPackages) {
                    result.addElement(
                            LookupElementBuilder.create(goPackage)
                                    .withIcon(PlatformIcons.PACKAGE_ICON)
                                    .withTypeText("via sdk")
                                    .withInsertHandler(ImportPathInsertHandler.INSTANCE));
                }

                Collection<String> goProjectPackages = packageNamesCache.getProjectPackages();

                for (String goPackage : goProjectPackages) {
                    if ( goPackage.equals("builtin"))
                        continue;
View Full Code Here

Examples of ro.redeul.google.go.lang.stubs.GoNamesCache

                return;
            }
        }

        GoFile goFile = (GoFile) file;
        GoNamesCache namesCache = GoNamesCache.getInstance(context.getProject());
        List<String> sdkPackages = getPackagesByName(namesCache.getSdkPackages(), packageName);
        List<String> projectPackages = getPackagesByName(namesCache.getProjectPackages(), packageName);
        new AddImportFix(sdkPackages, projectPackages, goFile, context.getEditor()).execute();
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.stubs.GoNamesCache

    public static final Map<Builtin, GoType> cachedTypes = new HashMap<Builtin, GoType>();

    public GoType getBuiltin(Builtin builtinType) {

        GoNamesCache namesCache = GoNamesCache.getInstance(myProject);

        GoType type = cachedTypes.get(builtinType);
        if (type == null) {
            Collection<GoFile> files = namesCache.getFilesByPackageName("builtin");

            for (GoFile file : files) {
                for (GoTypeDeclaration typeDeclaration : file.getTypeDeclarations()) {
                    for (GoTypeSpec spec : typeDeclaration.getTypeSpecs()) {
                        if (spec != null) {
View Full Code Here

Examples of ro.redeul.google.go.lang.stubs.GoNamesCache

    }

    @NotNull
    private GoType[] processBuiltinFunction(String functionName) {

        GoNamesCache namesCache = GoNamesCache.getInstance(getProject());

        GoExpr[] args = getArguments();
        GoPsiType typeArg = getTypeArgument();

        if (functionName.equals("new")) {
View Full Code Here

Examples of ro.redeul.google.go.lang.stubs.GoNamesCache

    @NotNull
    @Override
    protected GoType[] resolveTypes() {

        GoNamesCache namesCache = GoNamesCache.getInstance(getProject());
        return new GoType[]{
            types().fromPsiType(getAssertedType()),
            types().getBuiltin(GoTypes.Builtin.Bool)
        };
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.stubs.GoNamesCache

        return getPackageSearchScope(element);
    }

    private static SearchScope getPackageSearchScope(GoPsiElement element) {
        GoNamesCache namesCache = GoNamesCache.getInstance(element.getProject());
        String packageName = ((GoFile) element.getContainingFile()).getPackageName();
        Collection<GoFile> files = namesCache.getFilesByPackageName(packageName);
        return new LocalSearchScope(files.toArray(new PsiElement[files.size()]));
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.stubs.GoNamesCache

        GoLiteral literal = getLiteral();
        if (literal == null)
            return GoType.EMPTY_ARRAY;

        final GoTypes types = getInstance(getProject());
        GoNamesCache namesCache = GoNamesCache.getInstance(getProject());

        switch (literal.getType()) {
            case Bool:
                return new GoType[]{GoTypes.constant(GoTypeConstant.Kind.Boolean, literal.getValue())};
            case Int:
View Full Code Here

Examples of ro.redeul.google.go.lang.stubs.GoNamesCache

                return Collections.singleton(goFile);
            }

            List<GoFile> files = new ArrayList<GoFile>();
            String packageName = goFile.getPackageName();
            GoNamesCache namesCache = GoNamesCache.getInstance(goFile.getProject());
            for (GoFile file : namesCache.getFilesByPackageName(packageName)) {
                if (path.equals(getFilePath(file))) {
                    files.add(file);
                }
            }
View Full Code Here

Examples of ro.redeul.google.go.lang.stubs.GoNamesCache

        GoLiteralString importPath = element.getImportPath();
        if (importPath == null) {
            return ResolveResult.EMPTY_ARRAY;
        }

        GoNamesCache namesCache = GoNamesCache.getInstance(element.getProject());

        List<ResolveResult> files = new ArrayList<ResolveResult>();
        for (GoFile file : namesCache.getFilesByPackageImportPath(importPath.getValue())) {
            files.add(new PsiElementResolveResult(file.getOriginalFile()));
        }

        Collections.sort(files, new Comparator<ResolveResult>() {
            @Override
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.