List of usage examples for org.eclipse.jdt.core JavaCore VERSION_1_4
String VERSION_1_4
To view the source code for org.eclipse.jdt.core JavaCore VERSION_1_4.
Click Source Link
From source file:boa.datagen.scm.AbstractCommit.java
License:Apache License
private Builder processChangeFile(String path, boolean parse, Writer astWriter, String revKey, String keyDelim) {// ww w. jav a2 s .c o m final ChangedFile.Builder fb = ChangedFile.newBuilder(); fb.setName(path); fb.setKind(FileKind.OTHER); final String lowerPath = path.toLowerCase(); if (lowerPath.endsWith(".txt")) fb.setKind(FileKind.TEXT); else if (lowerPath.endsWith(".xml")) fb.setKind(FileKind.XML); else if (lowerPath.endsWith(".jar") || lowerPath.endsWith(".class")) fb.setKind(FileKind.BINARY); else if (lowerPath.endsWith(".java") && parse) { final String content = getFileContents(path); fb.setKind(FileKind.SOURCE_JAVA_JLS2); if (!parseJavaFile(path, fb, content, JavaCore.VERSION_1_4, AST.JLS2, false, astWriter, revKey + keyDelim + path)) { if (debug) System.err.println("Found JLS2 parse error in: revision " + id + ": file " + path); fb.setKind(FileKind.SOURCE_JAVA_JLS3); if (!parseJavaFile(path, fb, content, JavaCore.VERSION_1_5, AST.JLS3, false, astWriter, revKey + keyDelim + path)) { if (debug) System.err.println("Found JLS3 parse error in: revision " + id + ": file " + path); fb.setKind(FileKind.SOURCE_JAVA_JLS4); if (!parseJavaFile(path, fb, content, JavaCore.VERSION_1_7, AST.JLS4, false, astWriter, revKey + keyDelim + path)) { if (debug) System.err.println("Found JLS4 parse error in: revision " + id + ": file " + path); //fb.setContent(content); fb.setKind(FileKind.SOURCE_JAVA_ERROR); try { astWriter.append(new Text(revKey + keyDelim + fb.getName()), new BytesWritable(ASTRoot.newBuilder().build().toByteArray())); } catch (IOException e) { e.printStackTrace(); } } else if (debug) System.err.println("Accepted JLS4: revision " + id + ": file " + path); } else if (debug) System.err.println("Accepted JLS3: revision " + id + ": file " + path); } else if (debug) System.err.println("Accepted JLS2: revision " + id + ": file " + path); } fb.setKey(revKey); return fb; }
From source file:boa.datagen.scm.AbstractCommit.java
License:Apache License
protected ChangedFile.Builder processChangeFile(final String path, final boolean attemptParse) { final ChangedFile.Builder fb = ChangedFile.newBuilder(); fb.setName(path);// www. j a va 2 s. com fb.setKind(FileKind.OTHER); final String lowerPath = path.toLowerCase(); if (lowerPath.endsWith(".txt")) fb.setKind(FileKind.TEXT); else if (lowerPath.endsWith(".xml")) fb.setKind(FileKind.XML); else if (lowerPath.endsWith(".jar") || lowerPath.endsWith(".class")) fb.setKind(FileKind.BINARY); else if (lowerPath.endsWith(".java") && attemptParse) { final String content = getFileContents(path); fb.setKind(FileKind.SOURCE_JAVA_JLS2); if (!parseJavaFile(path, fb, content, JavaCore.VERSION_1_4, AST.JLS2, false, null, null)) { if (debug) System.err.println("Found JLS2 parse error in: revision " + id + ": file " + path); fb.setKind(FileKind.SOURCE_JAVA_JLS3); if (!parseJavaFile(path, fb, content, JavaCore.VERSION_1_5, AST.JLS3, false, null, null)) { if (debug) System.err.println("Found JLS3 parse error in: revision " + id + ": file " + path); fb.setKind(FileKind.SOURCE_JAVA_JLS4); if (!parseJavaFile(path, fb, content, JavaCore.VERSION_1_7, AST.JLS4, false, null, null)) { if (debug) System.err.println("Found JLS4 parse error in: revision " + id + ": file " + path); //fb.setContent(content); fb.setKind(FileKind.SOURCE_JAVA_ERROR); } else if (debug) System.err.println("Accepted JLS4: revision " + id + ": file " + path); } else if (debug) System.err.println("Accepted JLS3: revision " + id + ": file " + path); } else if (debug) System.err.println("Accepted JLS2: revision " + id + ": file " + path); } return fb; }
From source file:com.google.cloud.tools.eclipse.appengine.newproject.JavaPackageValidator.java
License:Apache License
/** * Check if a string is a legal Java package name. *//*w ww. ja v a2 s.c o m*/ public static IStatus validate(String packageName) { if (packageName == null) { return new Status(IStatus.ERROR, PLUGIN_ID, 45, "null package name", null); } else if (packageName.isEmpty()) { // default package is allowed return Status.OK_STATUS; } else if (packageName.endsWith(".")) { // todo or allow this and strip the period return new Status(IStatus.ERROR, PLUGIN_ID, 46, MessageFormat.format("{0} ends with a period.", packageName), null); } else if (containsWhitespace(packageName)) { // very weird condition because validatePackageName allows internal white space return new Status(IStatus.ERROR, PLUGIN_ID, 46, MessageFormat.format("{0} contains whitespace.", packageName), null); } else { return JavaConventions.validatePackageName(packageName, JavaCore.VERSION_1_4, JavaCore.VERSION_1_4); } }
From source file:com.siteview.mde.internal.core.builders.BuildErrorReporter.java
License:Open Source License
private String findMatchingEE(String srcCompatibility, String clsCompatibility, boolean ee) { String executionEnv = null;/* w w w .j a v a2 s .c o m*/ String complaince = null; if (JavaCore.VERSION_1_1.equals(srcCompatibility) && JavaCore.VERSION_1_1.equals(clsCompatibility)) { executionEnv = JRE_1_1; complaince = JavaCore.VERSION_1_1; } else if (JavaCore.VERSION_1_2.equals(srcCompatibility) && JavaCore.VERSION_1_1.equals(clsCompatibility)) { executionEnv = J2SE_1_2; complaince = JavaCore.VERSION_1_2; } else if (JavaCore.VERSION_1_3.equals(srcCompatibility) && JavaCore.VERSION_1_1.equals(clsCompatibility)) { executionEnv = J2SE_1_3; complaince = JavaCore.VERSION_1_3; } else if (JavaCore.VERSION_1_3.equals(srcCompatibility) && JavaCore.VERSION_1_2.equals(clsCompatibility)) { executionEnv = J2SE_1_4; complaince = JavaCore.VERSION_1_4; } else if (JavaCore.VERSION_1_5.equals(srcCompatibility) && JavaCore.VERSION_1_5.equals(clsCompatibility)) { executionEnv = J2SE_1_5; complaince = JavaCore.VERSION_1_5; } else if (JavaCore.VERSION_1_6.equals(srcCompatibility) && JavaCore.VERSION_1_6.equals(clsCompatibility)) { executionEnv = JavaSE_1_6; complaince = JavaCore.VERSION_1_6; } else if (JavaCore.VERSION_1_7.equals(srcCompatibility) && JavaCore.VERSION_1_7.equals(clsCompatibility)) { executionEnv = JavaSE_1_7; complaince = JavaCore.VERSION_1_7; } if (ee) { return executionEnv; } return complaince; }
From source file:com.siteview.mde.internal.core.ClasspathComputer.java
License:Open Source License
/** * Sets compiler compliance options on the given project to match the default compliance settings * for the specified execution environment. Only sets options that do not already have an explicit * setting based on the given override flag. * <p>/*from w w w. j a v a 2 s . c o m*/ * If the specified execution environment is <code>null</code> and override is <code>true</code>, * all compliance options are removed from the options map before applying to the project. * </p> * @param project project to set compiler compliance options for * @param eeId execution environment identifier, or <code>null</code> * @param overrideExisting whether to override a setting if already present */ public static void setComplianceOptions(IJavaProject project, String eeId, boolean overrideExisting) { Map projectMap = project.getOptions(false); IExecutionEnvironment ee = null; Map options = null; if (eeId != null) { ee = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(eeId); if (ee != null) { options = ee.getComplianceOptions(); } } if (options == null) { if (overrideExisting && projectMap.size() > 0) { projectMap.remove(JavaCore.COMPILER_COMPLIANCE); projectMap.remove(JavaCore.COMPILER_SOURCE); projectMap.remove(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM); projectMap.remove(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER); projectMap.remove(JavaCore.COMPILER_PB_ENUM_IDENTIFIER); } else { return; } } else { String compliance = (String) options.get(JavaCore.COMPILER_COMPLIANCE); Iterator iterator = options.entrySet().iterator(); while (iterator.hasNext()) { Entry entry = (Entry) iterator.next(); String option = (String) entry.getKey(); String value = (String) entry.getValue(); if (JavaCore.VERSION_1_3.equals(compliance) || JavaCore.VERSION_1_4.equals(compliance)) { if (JavaCore.COMPILER_PB_ASSERT_IDENTIFIER.equals(option) || JavaCore.COMPILER_PB_ENUM_IDENTIFIER.equals(option)) { // for 1.3 & 1.4 projects, only override the existing setting if the default setting // is a greater severity than the existing setting setMinimumCompliance(projectMap, option, value, overrideExisting); } else { setCompliance(projectMap, option, value, overrideExisting); } } else { setCompliance(projectMap, option, value, overrideExisting); } } } project.setOptions(projectMap); }
From source file:cz.vutbr.fit.xhriba01.bc.jdt.ui.text.java.JavaCodeScanner.java
License:Open Source License
@Override protected List<IRule> createRules() { List<IRule> rules = new ArrayList<IRule>(); // Add rule for character constants. Token token = getToken(IJavaColorConstants.JAVA_STRING); rules.add(new SingleLineRule("'", "'", token, '\\')); //$NON-NLS-2$ //$NON-NLS-1$ Token defaultToken = getToken(IJavaColorConstants.JAVA_DEFAULT); // Add generic whitespace rule. rules.add(new WhitespaceRule(new JavaWhitespaceDetector(), defaultToken)); String version = getPreferenceStore().getString(SOURCE_VERSION); // Add JLS3 rule for /@\s*interface/ and /@\s*\w+/ token = getToken(ANNOTATION_COLOR_KEY); AnnotationRule atInterfaceRule = new AnnotationRule(getToken(IJavaColorConstants.JAVA_KEYWORD), token, JavaCore.VERSION_1_5, version); rules.add(atInterfaceRule);/*from w w w .j a v a 2 s . c om*/ fVersionDependentRules.add(atInterfaceRule); // Add word rule for new keywords, see bug 4077 JavaWordDetector wordDetector = new JavaWordDetector(); CombinedWordRule combinedWordRule = new CombinedWordRule(wordDetector, defaultToken); VersionedWordMatcher j14Matcher = new VersionedWordMatcher(defaultToken, JavaCore.VERSION_1_4, version); token = getToken(IJavaColorConstants.JAVA_KEYWORD); for (int i = 0; i < fgJava14Keywords.length; i++) j14Matcher.addWord(fgJava14Keywords[i], token); combinedWordRule.addWordMatcher(j14Matcher); fVersionDependentRules.add(j14Matcher); VersionedWordMatcher j15Matcher = new VersionedWordMatcher(defaultToken, JavaCore.VERSION_1_5, version); token = getToken(IJavaColorConstants.JAVA_KEYWORD); for (int i = 0; i < fgJava15Keywords.length; i++) j15Matcher.addWord(fgJava15Keywords[i], token); combinedWordRule.addWordMatcher(j15Matcher); fVersionDependentRules.add(j15Matcher); // Add rule for operators token = getToken(IJavaColorConstants.JAVA_OPERATOR); rules.add(new OperatorRule(token)); // Add rule for brackets token = getToken(IJavaColorConstants.JAVA_BRACKET); rules.add(new BracketRule(token)); // Add word rule for keyword 'return'. CombinedWordRule.WordMatcher returnWordRule = new CombinedWordRule.WordMatcher(); token = getToken(IJavaColorConstants.JAVA_KEYWORD_RETURN); returnWordRule.addWord(RETURN, token); combinedWordRule.addWordMatcher(returnWordRule); // Add word rule for keywords, types, and constants. CombinedWordRule.WordMatcher wordRule = new CombinedWordRule.WordMatcher(); token = getToken(IJavaColorConstants.JAVA_KEYWORD); for (int i = 0; i < fgKeywords.length; i++) wordRule.addWord(fgKeywords[i], token); for (int i = 0; i < fgTypes.length; i++) wordRule.addWord(fgTypes[i], token); for (int i = 0; i < fgConstants.length; i++) wordRule.addWord(fgConstants[i], token); combinedWordRule.addWordMatcher(wordRule); rules.add(combinedWordRule); setDefaultReturnToken(defaultToken); return rules; }
From source file:de.loskutov.bco.ui.JdtUtils.java
License:Open Source License
/** * Modified copy from JavaModelUtil.//from w w w .ja va2s . c om * @param javaElt * @return true, if corresponding java project has compiler setting to generate * bytecode for jdk 1.5 and above */ public static boolean is50OrHigher(IJavaElement javaElt) { IJavaProject project = javaElt.getJavaProject(); String option = project.getOption(JavaCore.COMPILER_COMPLIANCE, true); boolean result = JavaCore.VERSION_1_5.equals(option); if (result) { return result; } // probably > 1.5? result = JavaCore.VERSION_1_4.equals(option); if (result) { return false; } result = JavaCore.VERSION_1_3.equals(option); if (result) { return false; } result = JavaCore.VERSION_1_2.equals(option); if (result) { return false; } result = JavaCore.VERSION_1_1.equals(option); if (result) { return false; } // unknown = > 1.5 return true; }
From source file:de.tobject.findbugs.reporter.JdtUtils.java
License:Open Source License
/** * @param javaElt/*from w w w . j a v a2s . c o m*/ * @return true, if corresponding java project has compiler setting to * generate bytecode for jdk 1.5 and above */ private static boolean is50OrHigher(IJavaElement javaElt) { IJavaProject project = javaElt.getJavaProject(); String option = project.getOption(JavaCore.COMPILER_COMPLIANCE, true); boolean result = JavaCore.VERSION_1_5.equals(option); if (result) { return result; } // probably > 1.5? result = JavaCore.VERSION_1_4.equals(option); if (result) { return false; } result = JavaCore.VERSION_1_3.equals(option); if (result) { return false; } result = JavaCore.VERSION_1_2.equals(option); if (result) { return false; } result = JavaCore.VERSION_1_1.equals(option); if (result) { return false; } // unknown = > 1.5 return true; }
From source file:eu.artist.migration.modernization.uml2java.repackaged.gen.java.ui.launch.tabs.UML2JavaGeneralLaunchConfigurationTab.java
License:Open Source License
/** * Returns the default execution environment name. * /*from ww w . j ava 2s. c om*/ * @return The default execution environment name. */ private String getDefaultEEName() { IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall(); IExecutionEnvironment[] environments = JavaRuntime.getExecutionEnvironmentsManager() .getExecutionEnvironments(); if (defaultVM != null) { for (IExecutionEnvironment environment : environments) { IVMInstall eeDefaultVM = environment.getDefaultVM(); if (eeDefaultVM != null && defaultVM.getId().equals(eeDefaultVM.getId())) { return environment.getId(); } } } String defaultCC; if (defaultVM instanceof IVMInstall2) { defaultCC = JavaModelUtil.getCompilerCompliance((IVMInstall2) defaultVM, JavaCore.VERSION_1_4); } else { defaultCC = JavaCore.VERSION_1_4; } String result = "JavaSE-1.7"; //$NON-NLS-1$ for (IExecutionEnvironment environment : environments) { String eeCompliance = JavaModelUtil.getExecutionEnvironmentCompliance(environment); if (defaultCC.endsWith(eeCompliance)) { result = environment.getId(); break; } } return result; }
From source file:net.rim.ejde.internal.ui.launchers.BBJRETab.java
License:Open Source License
/** * Populate installed JRE ComboBox.Preserve the current selection. *//* w w w . jav a 2s . c o m*/ private void fillInstalledJREs() { String selectedItem = ""; int selectionIndex = -1; selectionIndex = _jreCombo.getSelectionIndex(); if (selectionIndex != -1) {// paranoia selectedItem = _jreCombo.getItems()[selectionIndex]; } List<IVMInstall> standins = VMUtils.getInstalledBBVMs(); IVMInstall[] installedVMs = (standins.toArray(new IVMInstall[standins.size()])); selectionIndex = -1;// find new index String[] jreLabels = new String[installedVMs.length]; String[] RECompliance = new String[installedVMs.length]; for (int i = 0; i < installedVMs.length; i++) { jreLabels[i] = installedVMs[i].getName(); if (selectedItem != null && jreLabels[i].equals(selectedItem)) { selectionIndex = i; } if (installedVMs[i] instanceof IVMInstall2) { RECompliance[i] = JavaModelUtil.getCompilerCompliance((IVMInstall2) installedVMs[i], JavaCore.VERSION_1_4); } else { RECompliance[i] = JavaCore.VERSION_1_4; } } _jreCombo.setItems(jreLabels); if (selectionIndex == -1) { _jreCombo.setText(getDefaultJREName()); } else { _jreCombo.select(selectionIndex); } }