Skip to content

Commit 44e1a86

Browse files
committed
Merge remote-tracking branch 'upstream/master' into lsp
2 parents f71de47 + c138cb2 commit 44e1a86

File tree

66 files changed

+1003
-514
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1003
-514
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Fix broken inline suggestion auto-trigger on Systemverfilog files if users dont have systemverilog extension installed and enabled"
4+
}

packages/amazonq/test/unit/codewhisperer/util/runtimeLanguageContext.test.ts

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import assert from 'assert'
7-
import { resetCodeWhispererGlobalVariables } from 'aws-core-vscode/test'
7+
import { resetCodeWhispererGlobalVariables, toTextDocument } from 'aws-core-vscode/test'
88
import { runtimeLanguageContext, RuntimeLanguageContext, PlatformLanguageId } from 'aws-core-vscode/codewhisperer'
99
import * as codewhispererClient from 'aws-core-vscode/codewhisperer'
1010
import { CodewhispererLanguage } from 'aws-core-vscode/shared'
@@ -61,6 +61,61 @@ describe('runtimeLanguageContext', function () {
6161
assert.strictEqual(actual, expected)
6262
})
6363
})
64+
65+
describe('test isLanguageSupported with document as the argument', function () {
66+
const cases: [string, boolean][] = [
67+
['helloJava.java', true],
68+
['helloPython.py', true],
69+
['helloJavascript.js', true],
70+
['helloJsx.jsx', true],
71+
['helloTypescript.ts', true],
72+
['helloTsx.tsx', true],
73+
['helloCsharp.cs', true],
74+
['helloC.c', true],
75+
['helloC.h', true],
76+
['helloCpp.cpp', true],
77+
['helloCpp.cc', true],
78+
['helloGo.go', true],
79+
['helloKotlin.kt', true],
80+
['helloPhp.php', true],
81+
['helloRuby.rb', true],
82+
['helloRust.rs', true],
83+
['helloScala.scala', true],
84+
['helloShellscript.sh', true],
85+
['helloSql.sql', true],
86+
['helloSystemVerilog.svh', true],
87+
['helloSystemVerilog.sv', true],
88+
['helloSystemVerilog.vh', true],
89+
['helloDart.dart', true],
90+
['helloLua.lua', true],
91+
['helloLua.wlua', true],
92+
['helloSwift.swift', true],
93+
['helloVue.vue', true],
94+
['helloPowerShell.ps1', true],
95+
['helloPowerShell.psm1', true],
96+
['helloR.r', true],
97+
['helloJson.json', true],
98+
['helloYaml.yaml', true],
99+
['helloYaml.yml', true],
100+
['helloTf.tf', true],
101+
['helloPlaintext.txt', false],
102+
['helloHtml.html', false],
103+
['helloCss.css', false],
104+
['helloUnknown', false],
105+
['helloFoo.foo', false],
106+
]
107+
108+
cases.forEach((tuple) => {
109+
const fileName = tuple[0]
110+
const expected = tuple[1]
111+
112+
it(`pass document ${fileName} as argument should first try determine by languageId then file extensions`, async function () {
113+
const doc = await toTextDocument('', fileName)
114+
const actual = languageContext.isLanguageSupported(doc)
115+
assert.strictEqual(actual, expected)
116+
})
117+
})
118+
})
64119
})
65120

66121
describe('test getLanguageContext', function () {

packages/core/src/auth/auth.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { Timeout } from '../shared/utilities/timeoutUtils'
1616
import { errorCode, isAwsError, isNetworkError, ToolkitError, UnknownError } from '../shared/errors'
1717
import { getCache, getCacheFileWatcher } from './sso/cache'
1818
import { isNonNullable, Mutable } from '../shared/utilities/tsUtils'
19-
import { builderIdStartUrl, SsoToken, truncateStartUrl } from './sso/model'
19+
import { SsoToken, truncateStartUrl } from './sso/model'
2020
import { SsoClient } from './sso/clients'
2121
import { getLogger } from '../shared/logger'
2222
import { CredentialsProviderManager } from './providers/credentialsProviderManager'
@@ -68,6 +68,7 @@ import { asStringifiedStack } from '../shared/telemetry/spans'
6868
import { withTelemetryContext } from '../shared/telemetry/util'
6969
import { DiskCacheError } from '../shared/utilities/cacheUtils'
7070
import { setContext } from '../shared/vscode/setContext'
71+
import { builderIdStartUrl, internalStartUrl } from './sso/constants'
7172

7273
interface AuthService {
7374
/**
@@ -189,7 +190,7 @@ export class Auth implements AuthService, ConnectionManager {
189190
}
190191

191192
public isInternalAmazonUser(): boolean {
192-
return this.isConnected() && this.startUrl === 'https://amzn.awsapps.com/start'
193+
return this.isConnected() && this.startUrl === internalStartUrl
193194
}
194195

195196
/**

packages/core/src/auth/connection.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import * as vscode from 'vscode'
66
import { Credentials } from '@aws-sdk/types'
77
import { Mutable } from '../shared/utilities/tsUtils'
8-
import { builderIdStartUrl, ClientRegistration, SsoToken, truncateStartUrl } from './sso/model'
8+
import { ClientRegistration, SsoToken, truncateStartUrl } from './sso/model'
99
import { SsoClient } from './sso/clients'
1010
import { CredentialsProviderManager } from './providers/credentialsProviderManager'
1111
import { fromString } from './providers/credentials'
@@ -17,6 +17,7 @@ import { withTelemetryContext } from '../shared/telemetry/util'
1717
import { AuthModifyConnection, telemetry } from '../shared/telemetry/telemetry'
1818
import { asStringifiedStack } from '../shared/telemetry/spans'
1919
import { getTelemetryReason, getTelemetryReasonDesc } from '../shared/errors'
20+
import { builderIdStartUrl } from './sso/constants'
2021

2122
/** Shows a warning message unless it is the same as the last one shown. */
2223
const warnOnce = onceChanged((s: string, url: string) => {

packages/core/src/auth/providers/sharedCredentialsProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ import {
2929
Profile,
3030
Section,
3131
} from '../credentials/sharedCredentials'
32-
import { builderIdStartUrl } from '../sso/model'
3332
import { SectionName, SharedCredentialsKeys } from '../credentials/types'
3433
import { SsoProfile, hasScopes, scopesSsoAccountAccess } from '../connection'
34+
import { builderIdStartUrl } from '../sso/constants'
3535

3636
const credentialSources = {
3737
ECS_CONTAINER: 'EcsContainer',

packages/core/src/auth/sso/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
* web, node, or vue.
99
*/
1010

11+
export const builderIdStartUrl = 'https://view.awsapps.com/start'
12+
export const internalStartUrl = 'https://amzn.awsapps.com/start'
13+
1114
export const ssoUrlFormatRegex =
1215
/^(https?:\/\/(.+)\.awsapps\.com\/start|https?:\/\/identitycenter\.amazonaws\.com\/ssoins-[\da-zA-Z]{16})\/?$/
1316

packages/core/src/auth/sso/model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { ssoAuthHelpUrl } from '../../shared/constants'
1616
import { openUrl } from '../../shared/utilities/vsCodeUtils'
1717
import { ToolkitError } from '../../shared/errors'
1818
import { isCloud9 } from '../../shared/extensionUtilities'
19+
import { builderIdStartUrl } from './constants'
1920

2021
export interface SsoToken {
2122
/**
@@ -88,7 +89,6 @@ export interface SsoProfile {
8889
readonly identifier?: string
8990
}
9091

91-
export const builderIdStartUrl = 'https://view.awsapps.com/start'
9292
export const trustedDomainCancellation = 'TrustedDomainCancellation'
9393

9494
const tryOpenHelpUrl = (url: vscode.Uri) =>

packages/core/src/auth/sso/ssoAccessTokenProvider.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,7 @@
66
import * as vscode from 'vscode'
77
import globals from '../../shared/extensionGlobals'
88
import { AuthorizationPendingException, SSOOIDCServiceException, SlowDownException } from '@aws-sdk/client-sso-oidc'
9-
import {
10-
SsoToken,
11-
ClientRegistration,
12-
isExpired,
13-
SsoProfile,
14-
builderIdStartUrl,
15-
openSsoPortalLink,
16-
isDeprecatedAuth,
17-
} from './model'
9+
import { SsoToken, ClientRegistration, isExpired, SsoProfile, openSsoPortalLink, isDeprecatedAuth } from './model'
1810
import { getCache } from './cache'
1911
import { hasProps, hasStringProps, RequiredProps, selectFrom } from '../../shared/utilities/tsUtils'
2012
import { OidcClient } from './clients'
@@ -46,6 +38,7 @@ import { NestedMap } from '../../shared/utilities/map'
4638
import { asStringifiedStack } from '../../shared/telemetry/spans'
4739
import { showViewLogsMessage } from '../../shared/utilities/messages'
4840
import _ from 'lodash'
41+
import { builderIdStartUrl } from './constants'
4942

5043
export const authenticationPath = 'sso/authenticated'
5144

packages/core/src/awsService/cloudWatchLogs/commands/viewLogStream.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import {
2424
import { prepareDocument, searchLogGroup } from './searchLogGroup'
2525
import { telemetry, Result } from '../../../shared/telemetry/telemetry'
2626
import { CancellationError } from '../../../shared/utilities/timeoutUtils'
27-
import { formatLocalized } from '../../../shared/utilities/textUtilities'
2827
import { cwlUriSchema } from '../cloudWatchLogsUtils'
28+
import { formatLocalized } from '../../../shared/datetime'
2929

3030
export async function viewLogStream(node: LogGroupNode, registry: LogDataRegistry): Promise<void> {
3131
await telemetry.cloudwatchlogs_open.run(async (span) => {

packages/core/src/awsService/cloudWatchLogs/document/textContent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
import { formatDateTimestamp } from '../../../shared/datetime'
67
import { CloudWatchLogsEvent, CloudWatchLogsGroupInfo } from '../registry/logDataRegistry'
7-
import { formatDateTimestamp } from '../../../shared/utilities/textUtilities'
88

99
export const timestampSpaceEquivalent = ' '
1010

0 commit comments

Comments
 (0)