-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialize Custom Angular Validator. See
- Loading branch information
1 parent
b3d50ed
commit 60c9dcb
Showing
15 changed files
with
414 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="src" path="src/"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/bin | ||
/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>org.eclipse.angularjs.core</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.ManifestBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.SchemaBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
<nature>org.eclipse.pde.PluginNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/org.eclipse.core.resources.prefs | ||
/org.eclipse.m2e.core.prefs |
7 changes: 7 additions & 0 deletions
7
org.eclipse.angularjs.core.neon/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 | ||
org.eclipse.jdt.core.compiler.compliance=1.6 | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: %pluginName | ||
Bundle-Vendor: %pluginProvider | ||
Bundle-Localization: plugin | ||
Bundle-SymbolicName: org.eclipse.angularjs.core.neon;singleton:=true | ||
Bundle-Version: 1.2.0.qualifier | ||
Require-Bundle: org.eclipse.core.runtime, | ||
org.eclipse.wst.html.core;bundle-version="1.1.802", | ||
org.eclipse.wst.sse.core, | ||
org.eclipse.wst.xml.core, | ||
org.eclipse.angularjs.core;bundle-version="1.2.0", | ||
org.eclipse.core.resources, | ||
tern.core | ||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 | ||
Bundle-ActivationPolicy: lazy | ||
Bundle-Activator: org.eclipse.angularjs.internal.core.AngularCoreNeonPlugin | ||
Import-Package: com.eclipsesource.json;version="[0.9.4,0.9.5)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
source.. = src/ | ||
output.. = bin/ | ||
bin.includes = META-INF/,\ | ||
.,\ | ||
plugin.xml,\ | ||
plugin.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
############################################################################### | ||
# Copyright (c) 2013 Angelo Zerr and others. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Eclipse Public License v1.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.eclipse.org/legal/epl-v10.html | ||
# | ||
# Contributors: | ||
# Angelo Zerr <angelo.zerr@gmail.com> - Initial API and implementation | ||
############################################################################### | ||
pluginProvider=Angelo ZERR | ||
pluginName=Eclipse AngularJS Core | ||
|
||
angularNature=AngularJS Nature | ||
angularContentType=AngularJS Source File | ||
|
||
HTMLAngularValidator.name=HTML Angular Syntax Validator | ||
|
||
# Protractor | ||
ProtractorLaunchConfigurationDelegate.name=Protractor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?eclipse version="3.0"?> | ||
<!-- | ||
############################################################################### | ||
# Copyright (c) 2013 - 2016 Angelo Zerr and others. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Eclipse Public License v1.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.eclipse.org/legal/epl-v10.html | ||
# | ||
# Contributors: | ||
# Angelo Zerr <angelo.zerr@gmail.com> - Initial API and implementation | ||
############################################################################### | ||
--> | ||
<plugin> | ||
|
||
<extension point="org.eclipse.wst.html.core.customTagValidator"> | ||
<validator class="org.eclipse.angularjs.internal.core.validation.HTMLAngularTagValidator"></validator> | ||
</extension> | ||
<extension point="org.eclipse.wst.html.core.customAttributeValidator"> | ||
<validator class="org.eclipse.angularjs.internal.core.validation.HTMLAngularAttributeValidator"></validator> | ||
</extension> | ||
|
||
</plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>org.eclipse.angularjs.core.neon</artifactId> | ||
<packaging>eclipse-plugin</packaging> | ||
<parent> | ||
<groupId>fr.opensagres.angularjs</groupId> | ||
<artifactId>angularjs-eclipse</artifactId> | ||
<version>1.2.0-SNAPSHOT</version> | ||
</parent> | ||
</project> |
54 changes: 54 additions & 0 deletions
54
...se.angularjs.core.neon/src/org/eclipse/angularjs/internal/core/AngularCoreNeonPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Copyright (c) 2013-2014 Angelo ZERR. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation | ||
*/ | ||
package org.eclipse.angularjs.internal.core; | ||
|
||
import org.eclipse.core.runtime.Plugin; | ||
import org.osgi.framework.BundleContext; | ||
|
||
/** | ||
* Angular Core Plugin. | ||
* | ||
*/ | ||
public class AngularCoreNeonPlugin extends Plugin { | ||
|
||
public static final String PLUGIN_ID = "org.eclipse.angularjs.core.neon"; //$NON-NLS-1$ | ||
|
||
// The shared instance. | ||
private static AngularCoreNeonPlugin plugin; | ||
|
||
/** | ||
* The constructor. | ||
*/ | ||
public AngularCoreNeonPlugin() { | ||
super(); | ||
plugin = this; | ||
} | ||
|
||
@Override | ||
public void start(BundleContext context) throws Exception { | ||
super.start(context); | ||
} | ||
|
||
@Override | ||
public void stop(BundleContext context) throws Exception { | ||
plugin = null; | ||
super.stop(context); | ||
} | ||
|
||
/** | ||
* Returns the shared instance | ||
* | ||
* @return the shared instance | ||
*/ | ||
public static AngularCoreNeonPlugin getDefault() { | ||
return plugin; | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
org.eclipse.angularjs.core.neon/src/org/eclipse/angularjs/internal/core/Trace.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/** | ||
* Copyright (c) 2013-2014 Angelo ZERR. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation | ||
*/ | ||
package org.eclipse.angularjs.internal.core; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import org.eclipse.core.runtime.IStatus; | ||
import org.eclipse.core.runtime.Status; | ||
|
||
/** | ||
* Helper class to route trace output. | ||
*/ | ||
public class Trace { | ||
public static final byte CONFIG = 0; | ||
public static final byte INFO = 1; | ||
public static final byte WARNING = 2; | ||
public static final byte SEVERE = 3; | ||
public static final byte FINEST = 4; | ||
public static final byte FINER = 5; | ||
public static final byte PERFORMANCE = 6; | ||
public static final byte EXTENSION_POINT = 7; | ||
|
||
private static final String[] levelNames = new String[] { "CONFIG ", | ||
"INFO ", "WARNING", "SEVERE ", "FINER ", "FINEST ", "PERF ", | ||
"EXTENSION" }; | ||
|
||
private static final SimpleDateFormat sdf = new SimpleDateFormat( | ||
"dd/MM/yy HH:mm.ss.SSS"); | ||
|
||
private static Set<String> logged = new HashSet<String>(); | ||
|
||
/** | ||
* Trace constructor comment. | ||
*/ | ||
private Trace() { | ||
super(); | ||
} | ||
|
||
/** | ||
* Trace the given text. | ||
* | ||
* @param level | ||
* a trace level | ||
* @param s | ||
* a message | ||
*/ | ||
public static void trace(byte level, String s) { | ||
trace(level, s, null); | ||
} | ||
|
||
/** | ||
* Trace the given message and exception. | ||
* | ||
* @param level | ||
* a trace level | ||
* @param s | ||
* a message | ||
* @param t | ||
* a throwable | ||
*/ | ||
public static void trace(byte level, String s, Throwable t) { | ||
if (s == null) | ||
return; | ||
|
||
if (level == SEVERE) { | ||
if (!logged.contains(s)) { | ||
AngularCoreNeonPlugin | ||
.getDefault() | ||
.getLog() | ||
.log(new Status(IStatus.ERROR, | ||
AngularCoreNeonPlugin.PLUGIN_ID, s, t)); | ||
logged.add(s); | ||
} | ||
} | ||
|
||
if (!AngularCoreNeonPlugin.getDefault().isDebugging()) | ||
return; | ||
|
||
StringBuilder sb = new StringBuilder(AngularCoreNeonPlugin.PLUGIN_ID); | ||
sb.append(" "); | ||
sb.append(levelNames[level]); | ||
sb.append(" "); | ||
sb.append(sdf.format(new Date())); | ||
sb.append(" "); | ||
sb.append(s); | ||
System.out.println(sb.toString()); | ||
if (t != null) | ||
t.printStackTrace(); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...neon/src/org/eclipse/angularjs/internal/core/validation/AbstractHTMLAngularValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.eclipse.angularjs.internal.core.validation; | ||
|
||
import org.eclipse.angularjs.core.AngularProject; | ||
import org.eclipse.angularjs.core.utils.DOMUtils; | ||
import org.eclipse.angularjs.internal.core.Trace; | ||
import org.eclipse.core.resources.IFile; | ||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.jface.text.IDocument; | ||
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; | ||
import org.eclipse.wst.sse.core.internal.validate.ValidationMessage; | ||
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement; | ||
|
||
import tern.angular.modules.AngularModulesManager; | ||
import tern.angular.modules.Directive; | ||
import tern.angular.modules.Restriction; | ||
|
||
public abstract class AbstractHTMLAngularValidator { | ||
|
||
protected static final ValidationMessage IGNORE_VALIDATION_MESSAGE = new ValidationMessage("", 0, | ||
ValidationMessage.IGNORE); | ||
|
||
private AngularProject angularProject; | ||
|
||
public void init(IStructuredDocument doc) { | ||
this.angularProject = null; | ||
if (doc instanceof IDocument) { | ||
IFile file = DOMUtils.getFile((IDocument) doc); | ||
IProject project = file.getProject(); | ||
if (AngularProject.hasAngularNature(project)) { | ||
try { | ||
this.angularProject = AngularProject.getAngularProject(project); | ||
} catch (CoreException e) { | ||
Trace.trace(Trace.SEVERE, "Error while getting angular project", e); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public final boolean canValidate(IDOMElement target) { | ||
if (this.angularProject != null) { | ||
return doCanValidate(target); | ||
} | ||
return false; | ||
} | ||
|
||
protected Directive getDirective(String tagName, String attrName, Restriction restriction) { | ||
return AngularModulesManager.getInstance().getDirective(angularProject, tagName, attrName, restriction); | ||
} | ||
|
||
protected abstract boolean doCanValidate(IDOMElement target); | ||
} |
Oops, something went wrong.