Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

18
LINES

< > BotCompany Repo | #1005024 // tok_packageName

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3417L/20K).

1  
sS tok_packageName(LS tok) {
2  
  int i = jfind(tok, "package");
3  
  if (i < 0) ret "";
4  
  i += 2;
5  
  int j = jfind(tok, i, ";");
6  
  if (j < 0) ret "";
7  
  ret join(codeTokensOnly(subList(tok, i-1, j)));
8  
}
9  
10  
sS tok_packageName(S src) {
11  
  Producer<S> p = javaTokC_producer(src);
12  
  S t = p.next();
13  
  if (!eq(t, "package")) ret "";
14  
  new StringBuilder buf;
15  
  while (!eqOneOf(t = p.next(), null, ";"))
16  
    buf.append(t);
17  
  ret str(buf);
18  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1005024
Snippet name: tok_packageName
Eternal ID of this version: #1005024/2
Text MD5: edac13735d6154dc5edc38bd4360770f
Transpilation MD5: 97c48a88e5d7f33467e06395c1e5b397
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-04 22:48:58
Source code size: 440 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 565 / 925
Version history: 1 change(s)
Referenced in: [show references]