/*
Creates an image descriptor for the given prefix and name in the JDT UI bundle. The path can contain variables
like $NL$. If no image could be found, the 'missing image descriptor' is returned.
772554
private static ImageDescriptor createUnManaged(String prefix, String name)
	{
		return create(prefix, name, true);
	}
76806
public Widget createAttributeWidget(Feature feature, AttributeDescriptor descriptor) {
		Attribute<?> attribute = feature.getAttributes().get(descriptor.getName());

		// Get a builder for the attribute
		// attribute.getValue is e.g. StringAttribute, ImageURLAttribute, ...
		AttributeWidgetBuilder builder = builders.get(attribute.getValue().getClass());
		if (builder == null) {
			builder = new DefaultAttributeWidgetBuilder();
		}

		// Build the widget and return it:
		return builder.buildAttributeWidget(attribute.getValue());
	}
790580
public ImageDescriptor image(SarlConstructor constructor) {
		if (constructor.isStatic()) {
			return this.images.forStaticConstructor();
		}
		return this.images.forConstructor(
				constructor.getVisibility(),
				this.adornments.get(this.jvmModelAssociations.getInferredConstructor(constructor)));
	}
72373
public ImageDescriptor image(SarlEvent event) {
		final JvmDeclaredType jvmElement = this.jvmModelAssociations.getInferredType(event);
		return this.images.forEvent(
				event.getVisibility(),
				this.adornments.get(jvmElement));
	}
1299338
private MavenArtifactDescriptor getMavenArtifactDescriptor(Dependency dependency, ScannerContext context) {
        DependencyCoordinates coordinates = new DependencyCoordinates(dependency);
        return getArtifactResolver(context).resolve(coordinates, context);
    }
957630
function createDir(srcPath, desPath) {
    var pathInfo = path.parse(desPath);
    var searchvalue = pathInfo.root[pathInfo.root.length - 1]
    var start = 0;
    var found = pathInfo.dir.indexOf(searchvalue);
    var subPath = '';
    var dirs = [];

    if (found != -1) {
        while (true) {
            subPath = pathInfo.dir.substr(start, found - start + 1);
            if (subPath != '') {
                dirs.push(subPath);
            }
            start = found + 1;
            found = pathInfo.dir.indexOf(searchvalue, start);
            if (found == -1) {
                if (start < pathInfo.dir.length) {
                    dirs.push(pathInfo.dir.substr(start));
                }
                break;
            }
        }
    }

    subPath = '';
    dirs.forEach(function (dir, num) {
        subPath += dir;
        if (!fs.existsSync(subPath)) {
            try {
                fs.mkdirSync(subPath);
            } catch (e) {
                if (e.code != 'EEXIST') {
                    console.log('[error] ', e);
                };
            }
            console.log('[info] create  dir:', subPath);
        }
        if (num == dirs.length - 1 && pathInfo.base != '') {
            copyFile(srcPath, desPath);
            //console.log('src file:', srcPath);
            //console.log('des file:', desPath);
        }
    });

}
343908
function processIcon({ filePath, relativePath }, destPathRoot) {

    // The patterns we're looking for. Only write the new file if all are met.
    const pureImportRegex = /^import pure from 'recompose\/pure';\s*\n/gm;
    const componentDeclRegex = /let (\w+) = \(props\) =>/;
    const pureWrapRegex = /^((\w+)) = pure\(\1\);\s*\n/gm;

    // We'll const the component declaration while we're at it
    const componentDeclReplacement = 'const $1 = (props) =>';

    const destPath = pathUtils.resolve(destPathRoot, relativePath);

    return fs.readFileAsync(filePath, { encoding: 'UTF8' })
        .then(sourceCode => {

            const pureImportMatch = sourceCode.match(pureImportRegex);
            const componentDeclMatch = sourceCode.match(componentDeclRegex);
            const pureWrapMatch = sourceCode.match(pureWrapRegex);

            if (!(pureImportMatch && componentDeclMatch && pureWrapMatch)) {
                // Could not make sense of this file
                return {
                    filePath,
                    relativePath,
                    error: 'Could not recognise the source',
                };
            }

            // Update the source
            const newSourceCode = sourceCode
                .replace(pureImportRegex, '')
                .replace(pureWrapRegex, '')
                .replace(componentDeclRegex, componentDeclReplacement);

            return fs.writeFileAsync(destPath, newSourceCode, { encoding: 'UTF8' })
                .then(() => ({
                    filePath,
                    relativePath,
                    success: true,
                    className: componentDeclMatch[1],
                }))
        });
}
547064
private String createNewIdentifier(ParseTreeNode productionPart, String suffix)
	    throws TreeException {
	String identifier = "";
	if (productionPart.hasChild("IDENTIFIER")) {
	    identifier = productionPart.getChild("IDENTIFIER").getText();
	} else if (productionPart.hasChild("STRING_LITERAL")) {
	    identifier = productionPart.getChild("STRING_LITERAL").getText();
	}
	return createIdentifierName(identifier, suffix);
    }
902628
function loadPresetDescriptor(descriptor) {
  return {
    type: "preset",
    options: loadDescriptor(descriptor).value,
    alias: descriptor.alias,
    loc: descriptor.loc,
    dirname: descriptor.dirname
  };
}
245881
function(imageIdentifier, options) {
        if (typeof imageIdentifier !== 'string' || imageIdentifier.length === 0) {
            throw new Error(
                '`imageIdentifier` must be a non-empty string, was "' + imageIdentifier + '"' +
                ' (' + typeof imageIdentifier + ')'
            );
        }

        options = options || {};

        return new ImageUrl({
            baseUrl: this.getHostForImageIdentifier(
                imageIdentifier,
                options.usePrimaryHost
            ),
            path: options.path,
            user: this.options.user,
            publicKey: this.options.publicKey,
            privateKey: this.options.privateKey,
            imageIdentifier: imageIdentifier
        });
    }
1322393
function (res, name, version) {
  //Options
  var imgPath, width;
  //RegExp
  var re = /^\d\.\d.\d$/;
  //Test version
  if (re.test(version)) {
    imgPath = path.join(dir, name + '.png');
    width = 76;
  } else if (version.length === 6) {
    imgPath = path.join(dir, name + '-larger.png');
    width = 80;
  } else if (version.length === 7) {
    imgPath = path.join(dir, name + '-larger.png');
    width = 77;
  } else {
    imgPath = path.join(dir, name + '-larger.png');
    width = 74;
  }

  //Create Image
  var base = gm(imgPath)
    .font(path.join(__dirname, 'fonts', 'Arial.ttf'))
    .fontSize(10)
    .fill('#ffffff')
    .drawText(width, 12, version);
  //Write Stream and send to client
  write(base, res);
}
576248
function createAPIJSON(symbols, filename) {

	var api = {
		"$schema-ref": "http://schemas.sap.com/sapui5/designtime/api.json/1.0"
	};

	if ( templateConf.version ) {
		api.version = templateConf.version.replace(/-SNAPSHOT$/,"");
	}
	if ( templateConf.uilib ) {
		api.library = templateConf.uilib;
	}

	api.symbols = [];
	// sort only a copy(!) of the symbols, otherwise the SymbolSet lookup is broken
	symbols.slice(0).sort(sortByAlias).forEach(function(symbol) {
		if ( isFirstClassSymbol(symbol) && !symbol.synthetic ) { // dump a symbol if it as a class symbol and if it is not a synthetic symbol
			api.symbols.push(createAPIJSON4Symbol(symbol, false));
		}
	});

	postProcessAPIJSON(api);

	fs.mkPath(path.dirname(filename));
	fs.writeFileSync(filename, JSON.stringify(api), 'utf8');
	info("  apiJson saved as " + filename);
}
1352867
public ImageDescriptor image(SarlSkill skill) {
		final JvmDeclaredType jvmElement = this.jvmModelAssociations.getInferredType(skill);
		return this.images.forSkill(
				skill.getVisibility(),
				this.adornments.get(jvmElement));
	}
1359672
public void createVendor(String name, String url) {
        vendor = new GoPluginDescriptor.Vendor(name, url);
    }
1022798
public static ClassDescriptor createClassDescriptorFromResourceName(String resourceName) {
        if (!isClassResource(resourceName)) {
            throw new IllegalArgumentException("Resource " + resourceName + " is not a class");
        }
        return createClassDescriptor(resourceName.substring(0, resourceName.length() - 6));
    }
754818
public void setImageUrlAttribute(String name, String value) {
		ensureAttributes();
		Attribute attribute = new ImageUrlAttribute(value);
		attribute.setEditable(isEditable(name));
		getAllAttributes().put(name, attribute);

	}
278919
public static Pair<Descriptor, String> fromFilename(Path directory, String name) {
        // tokenize the filename
        StringTokenizer st = new StringTokenizer(name, String.valueOf(separator));
        String nexttok;

        // all filenames must start with keyspace and column family
        String ksname = st.nextToken();
        String cfname = st.nextToken();

        // optional temporary marker
        nexttok = st.nextToken();
        boolean temporary = false;
        if (nexttok.equals(SSTable.TEMPFILE_MARKER)) {
            temporary = true;
            nexttok = st.nextToken();
        }

        // optional version string
        Version version = Version.LEGACY;
        if (Version.validate(nexttok)) {
            version = new Version(nexttok);
            nexttok = st.nextToken();
        }
        int generation = Integer.parseInt(nexttok);

        // component suffix
        String component = st.nextToken();
        directory = directory != null ? directory : new Path(".");
        return Pair.create(new Descriptor(version, directory, ksname, cfname, generation, temporary), component);
    }