Skip to content

Commit

Permalink
Merge pull request #63 from pj8/support-attributes
Browse files Browse the repository at this point in the history
Support Embed and ResourceParam
  • Loading branch information
yuki777 authored May 18, 2024
2 parents d32b74c + 01571d0 commit fe46fae
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
15 changes: 15 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
############################################################################
# Copyright 2024 Yuki Adachi https://github.com/yuki777
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
############################################################################
2 changes: 1 addition & 1 deletion src/PeekFileDefinitionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default class PeekFileDefinitionProvider implements vscode.DefinitionProv
resourceAppPaths: string[] = [];
resourcePagePaths: string[] = [];

public static readonly regexPattern = /(get|post|put|delete|resource|uri)\(['"](app|page):\/\/self\/(.*)['"]/;
public static readonly regexPattern = /(get|post|put|delete|resource|uri|ResourceParam|Embed)\(.*?(app|page):\/\/self\/(.*)['"]/;

constructor(targetFileExtensions: string[] = [], resourceAppPaths: string[] = [], resourcePagePaths: string[] = []) {
this.targetFileExtensions = targetFileExtensions;
Expand Down
5 changes: 4 additions & 1 deletion src/test/regexTest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @see PeekFileDefinitionProvider.regexPattern
const regexPattern = /(get|post|put|delete|resource|uri)\(['"](app|page):\/\/self\/(.*)['"]/;
const regexPattern = /(get|post|put|delete|resource|uri|ResourceParam|Embed)\(.*?(app|page):\/\/self\/(.*)['"]/;

function testRegexTrue(target) {
// Test
Expand Down Expand Up @@ -34,6 +34,9 @@ testRegexTrue("put('app://self/foo')");
testRegexTrue("delete('app://self/foo')");
testRegexTrue('resource("app://self/foo")');
testRegexTrue('uri("app://self/foo")');
testRegexTrue("#[ResourceParam(uri: 'app://self/user#ulid', param: 'userId')]");
testRegexTrue("#[Embed(rel: 'foo', src: 'app://self/foo{?ulid}')]");

testRegexFalse('resource("foo://self/foo")');
testRegexFalse('foo("app://self/foo")');
testRegexFalse('getFoo("app://self/foo")');

0 comments on commit fe46fae

Please sign in to comment.