Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add utilities for typescript ast #1159

Merged
merged 1 commit into from
Jul 22, 2016
Merged

Conversation

emma-mens
Copy link
Contributor

@emma-mens emma-mens commented Jun 21, 2016

'ast-utils.ts' provides typescript ast utility functions

@emma-mens emma-mens force-pushed the ast-utils branch 2 times, most recently from b9f77dc to 2802d4d Compare June 22, 2016 16:31
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

@emma-mens emma-mens force-pushed the ast-utils branch 2 times, most recently from bfc6260 to cf2d9d6 Compare June 27, 2016 17:05
@googlebot
Copy link

CLAs look good, thanks!

@emma-mens emma-mens force-pushed the ast-utils branch 3 times, most recently from 831fe06 to fda7fbd Compare July 1, 2016 01:03
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

@googlebot googlebot added cla: no and removed cla: yes labels Jul 1, 2016
@emma-mens emma-mens force-pushed the ast-utils branch 2 times, most recently from c8612c0 to 73a278d Compare July 1, 2016 17:45
@googlebot
Copy link

CLAs look good, thanks!

@googlebot googlebot added cla: yes and removed cla: no labels Jul 1, 2016
@emma-mens emma-mens force-pushed the ast-utils branch 2 times, most recently from 8d2b180 to d4d15aa Compare July 1, 2016 22:12
description: 'Generates a route/guard and template',

files: function(){
var fileList = getFiles.call(this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can rewrite this cleanly as:

  return getFiles
    .call(this)
    .filter(...);

@emma-mens emma-mens force-pushed the ast-utils branch 3 times, most recently from 46c965c to ab82133 Compare July 14, 2016 22:57
@@ -0,0 +1,53 @@
import * as ts from 'typescript';
import { InsertChange } from './change';
/**
Copy link
Contributor

@hansl hansl Jul 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: empty line before to separate.

@hansl
Copy link
Contributor

hansl commented Jul 15, 2016

Some nits but LGTM. @alxhub do you want to review too?

* @param kind (a valid index of ts.SyntaxKind enum, eg ts.SyntaxKind.ImportDeclaration)
* @return all nodes of kind kind, or [] if none is found
*/
export function findNodes (node: ts.Node, kind: number, arr: ts.Node[] = []): ts.Node[] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No space between function name and parameters.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The arr: ts.Node[] parameter here is a little messy. Since the function returns an array already, why not make it also allocate its own array and accumulate values into that?

@emma-mens emma-mens force-pushed the ast-utils branch 2 times, most recently from 131e58d to 81a193d Compare July 18, 2016 21:29
* @throw Error if toInsert is first occurence but fall back is not set
*/
export function insertAfterLastOccurrence(nodes: ts.Node[], toInsert: string, file: string,
fallbackPos?: number, syntaxKind?: ts.SyntaxKind): Change {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left align either with the first argument or indented with 4 spaces please.

@hansl
Copy link
Contributor

hansl commented Jul 20, 2016

LGTM. @alxhub ?

@hansl
Copy link
Contributor

hansl commented Jul 22, 2016

@emma-mens: Can you rebase this on top of master? I can help you

'ast-utils.ts' provides typescript ast utility functions
@hansl hansl merged commit 0cfc2bf into angular:master Jul 22, 2016
@emma-mens emma-mens deleted the ast-utils branch July 22, 2016 23:18
hansl added a commit that referenced this pull request Jul 26, 2016
'ast-utils.ts' provides typescript ast utility functions
hansl added a commit that referenced this pull request Jul 27, 2016
* build: use webpack for building apps.

This pull request replaces the underlying broccoli build system and then
replaces it with webpack as the build and bundler.

This will affect the following commands (however the user-level)
functionality should go unchanged (besides unimplemented flags which
will come after this PR.):

ng build (with --env flag and --watch flag supported)
ng serve (with --port flag supported)
ng test / ng e2e

The webpack configuration is blackboxed, and therefore users will not
see a webpack.config.js file in their repository.

Also this PR will bump the typescript version to 2.0 (beta).

Fixes #909 #1155 #882

* chore(lint) Corrected any eslint errors and cleaned up unused files

* chore(cleanup) additional cleanup tasks performed. Removed unneeded code, indentation causing linting errors, add back tsconfig sourcemapping, removed console logs, deleted material unused files.

* chore: remove bind from serve command

* chore: simplify test command

* chore: fix test warnings

* chore: revert whitespace changes

* chore: re-add mapRoot to tsconfig

* chore: remove unused import

* bugfix: fix broken tests

* fix: fix mobile-specific feature test

* bugfix: fix public folder test

* fix: fixes for path mappings, tests, and coverage (#1359)

* fix(): Multiple fixes for path mappings:

* Removed invalid test case that was throwing path mappings  tests because of a typescript bug.
* Readded PathsPlugin for Path Mappings
* Removed coverage preprocessor which was throwing bad type errors against ts code when it shouldn't be.
* Added sourcemap support for istanbul instrumenter. Coverage files are still being generated.

* fix: fix the way the build command runs for mobile tests

* fix: fix the way the build command runs for mobile tests

* fix: replaced promise based ng command with sh.exec to allow mappings test to run correctly against mobile

* fix: replaced promise based ng command with sh.exec to allow mappings test to run correctly against mobile

* fix: add environment configuration replacement (#1364)

* fix: add environment configuration replacement

* remove debuggers

* fix: move mobile test above config test because it relies on prod build from previous step

* fix: removed unneeded interface moved config paths

* fix(tests): re-enable sass/less/stylus tests (#1363)

* chore: remove systemjs (#1376)

* chore: remove vendor.ts (#1383)

* chore: remove material2 test option (#1385)

* fix(build): re-add support for sourceDir (#1378)

* chore(build): remove broccoli (#1386)

* chore: remove windows elevation check (#1384)

* fix(test): add missing sourceDir (#1387)

* fix: update node polyfill support properties for prod config to allow dev-server (aka ng serve) (#1395)

* chore(tests): add prod env e2e test (#1394)

* chore: cleanup of new files (#1388)

* fix(serve): disable HMR (#1402)

* chore: review docs (#1407)

* feat(env): decouple build from env file (#1404)

* fix: fix tsconfig for editors (#1420)

* chore: fix webpack branch after merge conflicts (#1423)

* fix: update to awesome-typescript-loader 2.1.0 (#1425)

* fix: update to awesome-typescript-loader 2.1.0 which fixes a few issues shimming typings libs in tsconfig.json

* fix: forgot to set libs in tsconfig blueprint

* chore(blueprints): remove module.id (#1426)

* feat: add host flag support for ng serve (#1442)

* feat(test): add karma plugin (#1437)

* chore(blueprints): re-add outDir (#1428)

* feat: use @types instead of typings (#1449)

* fix: make sourcemaps work in test (#1447)

* feat: add utilities for typescript ast (#1159) (#1453)

'ast-utils.ts' provides typescript ast utility functions
Splaktar pushed a commit to DevIntent/angular-cli that referenced this pull request Jul 31, 2016
'ast-utils.ts' provides typescript ast utility functions
Splaktar pushed a commit to DevIntent/angular-cli that referenced this pull request Jul 31, 2016
* build: use webpack for building apps.

This pull request replaces the underlying broccoli build system and then
replaces it with webpack as the build and bundler.

This will affect the following commands (however the user-level)
functionality should go unchanged (besides unimplemented flags which
will come after this PR.):

ng build (with --env flag and --watch flag supported)
ng serve (with --port flag supported)
ng test / ng e2e

The webpack configuration is blackboxed, and therefore users will not
see a webpack.config.js file in their repository.

Also this PR will bump the typescript version to 2.0 (beta).

Fixes angular#909 angular#1155 angular#882

* chore(lint) Corrected any eslint errors and cleaned up unused files

* chore(cleanup) additional cleanup tasks performed. Removed unneeded code, indentation causing linting errors, add back tsconfig sourcemapping, removed console logs, deleted material unused files.

* chore: remove bind from serve command

* chore: simplify test command

* chore: fix test warnings

* chore: revert whitespace changes

* chore: re-add mapRoot to tsconfig

* chore: remove unused import

* bugfix: fix broken tests

* fix: fix mobile-specific feature test

* bugfix: fix public folder test

* fix: fixes for path mappings, tests, and coverage (angular#1359)

* fix(): Multiple fixes for path mappings:

* Removed invalid test case that was throwing path mappings  tests because of a typescript bug.
* Readded PathsPlugin for Path Mappings
* Removed coverage preprocessor which was throwing bad type errors against ts code when it shouldn't be.
* Added sourcemap support for istanbul instrumenter. Coverage files are still being generated.

* fix: fix the way the build command runs for mobile tests

* fix: fix the way the build command runs for mobile tests

* fix: replaced promise based ng command with sh.exec to allow mappings test to run correctly against mobile

* fix: replaced promise based ng command with sh.exec to allow mappings test to run correctly against mobile

* fix: add environment configuration replacement (angular#1364)

* fix: add environment configuration replacement

* remove debuggers

* fix: move mobile test above config test because it relies on prod build from previous step

* fix: removed unneeded interface moved config paths

* fix(tests): re-enable sass/less/stylus tests (angular#1363)

* chore: remove systemjs (angular#1376)

* chore: remove vendor.ts (angular#1383)

* chore: remove material2 test option (angular#1385)

* fix(build): re-add support for sourceDir (angular#1378)

* chore(build): remove broccoli (angular#1386)

* chore: remove windows elevation check (angular#1384)

* fix(test): add missing sourceDir (angular#1387)

* fix: update node polyfill support properties for prod config to allow dev-server (aka ng serve) (angular#1395)

* chore(tests): add prod env e2e test (angular#1394)

* chore: cleanup of new files (angular#1388)

* fix(serve): disable HMR (angular#1402)

* chore: review docs (angular#1407)

* feat(env): decouple build from env file (angular#1404)

* fix: fix tsconfig for editors (angular#1420)

* chore: fix webpack branch after merge conflicts (angular#1423)

* fix: update to awesome-typescript-loader 2.1.0 (angular#1425)

* fix: update to awesome-typescript-loader 2.1.0 which fixes a few issues shimming typings libs in tsconfig.json

* fix: forgot to set libs in tsconfig blueprint

* chore(blueprints): remove module.id (angular#1426)

* feat: add host flag support for ng serve (angular#1442)

* feat(test): add karma plugin (angular#1437)

* chore(blueprints): re-add outDir (angular#1428)

* feat: use @types instead of typings (angular#1449)

* fix: make sourcemaps work in test (angular#1447)

* feat: add utilities for typescript ast (angular#1159) (angular#1453)

'ast-utils.ts' provides typescript ast utility functions
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants