Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function assertResult( result ){
const compileUnit = JavaParser.parse( result , {});
const clazz = compileUnit.types[0];
const fooSegment = clazz.bodyDeclarations.filter( e => e.name.identifier==="foo" )[0];
expect( fooSegment ).toBeTruthy();
const based = fooSegment.bodyDeclarations.filter( e => e.name && e.name.identifier==="BASED" )[0];
expect( based ).toBeTruthy();
// Check if BASED class has expected content.
const barSegment = based.bodyDeclarations.filter( e => e.name.identifier==="bar" )[0];
expect( barSegment ).toBeTruthy();
done();
}
});
function assertResult( result ){
const compileUnit = JavaParser.parse( result , {});
const values = collectAllValuesOfCollectionConstants( compileUnit );
expect( values.length ).toBe( 18 );
for( let i=0 ; i
function assertResult( result ){
const compilationUnit = JavaParser.parse( result , {} );
const clazz = compilationUnit.types[0];
const foo = clazz.bodyDeclarations.filter( e => e.name && e.name.identifier==="foo" )[0];
expect( foo ).toBeTruthy();
const bar = clazz.bodyDeclarations.filter( e => e.name && e.name.identifier==="bar" )[0];
expect( bar ).toBeTruthy();
done();
}
});
function assertResult( result ){
const compilationUnit = JavaParser.parse( result , {});
const resources = [];
createJavaParserNodeIterator( compilationUnit ).forEach(function( node ){
if( node.node==="TypeDeclaration" && node.name.identifier !== "EoarheAoiuno" && node.name.identifier !== "BASED" ){
resources.push( node );
}
});
const whitelist = [
"_abstract", "_assert", "_boolean", "_break", "_byte", "_case",
"_catch", "_char", "_class", "_const", "_continue", "_default",
"_double", "_do", "_else", "_enum", "_extends", "_false",
"_final", "_finally", "_float", "_for", "_goto", "_if",
"_implements", "_import", "_instanceof", "_int", "_interface", "_long",
"_native", "_new", "_null", "_package", "_private", "_protected",
"_public", "_return", "_short", "_static", "_strictfp", "_super",
"_switch", "_synchronized", "_this", "_throw", "_throws", "_transient",
"_true", "_try", "_void", "_volatile", "_while",
public refresh(document: vscode.TextDocument): void {
this.config = vscode.workspace.getConfiguration("treeview.java");
this.tree = {} as token.ITokenTree;
const raw = require("java-parser").parse(document.getText());
const lines = document.getText().split("\n");
if (raw.package) {
const nsParts: string[] = [];
let ns = raw.package.name;
while (ns.qualifier !== undefined) {
nsParts.push(ns.name.identifier);
ns = ns.qualifier;
}
nsParts.push(ns.identifier);
this.tree.namespace = nsParts.reverse().join(".");
}
if (raw.imports.length !== 0) {
this.tree.imports = [];
let importName = null;
postRun( res ){
res.unit.file = res.filePath || "???";
let cst;
try{
cst = javaParser( res.src );
}catch(ex){
if(analyze)
return;
let name = res.name || (res.unit && res.unit.name + "") || "???";
if( name.startsWith(DATA.projectPath) ){
name = name.substr(DATA.projectPath.length+1);
}
console.log(ex.message, ex.stack);
throw( name + ": " + (ex.message || ex) );
}
res.unit.process(cst);
}
function parse(text) {
const ast = javaParser.parse(text);
return ast;
}